/*************************************************************************** pnmtools.c - routines for creating pnm images. ------------------- begin : Sat Oct 14 2000 copyright : (C) 2000 by pnm2ppa project email : ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include "pnmtools.h" /* setpixel(x,y,color) writes a pixel with bytecode color at (x,y)*/ void setpixel(int x,int y, unsigned char color ) { int charidx; if( y < BitMap_topline || y >= BitMap_bottomline ) return; if( x < 0 || x >= BitMap_Width ) return; charidx = (y-BitMap_topline)*BitMap_Width+x; color_bitmap[charidx] = color ; } /*setplus(x,y,s) writes a black "+" of size s centered at (x,y) */ void setplus(int x,int y,int s) { int i; for(i=0; i='0' ) for(xo=0; xo<5; xo++) for(yo=0; yo<8; yo++) if((charmap[c-'0'][xo]>>yo)&1) setblock(x+xo*s,y+yo*s,s); if(c<='Z' && c>='A') for(xo=0; xo<5; xo++) for(yo=0; yo<8; yo++) if((charmap[c-'A'+10][xo]>>yo)&1) setblock(x+xo*s,y+yo*s,s); if(c=='-') for(xo=0; xo<5; xo++) for(yo=0; yo<8; yo++) if((charmap[36][xo]>>yo)&1) setblock(x+xo*s,y+yo*s,s); if(c=='+') for(xo=0; xo<5; xo++) for(yo=0; yo<8; yo++) if((charmap[37][xo]>>yo)&1) setblock(x+xo*s,y+yo*s,s); } /* setstring(x,y,*p,s) writes the string *p starting at (x,y), in characters of size s. The letters of the string must belong to the alphabet (0-9,A-Z,+,-) supported by setchar() */ void setstring(int x,int y,char* s,int size) { char* p; int xo; for(xo=0, p=s; *p; xo+=((6*size)+1), p++) setchar(x+xo,y,*p,size); } /* like setstring, but writes vertically downwards*/ void setstringv(int x,int y,char* s,int size) { char* p; int yo; for(yo=0, p=s; *p; yo+=((7*size)+1), p++) setchar(x,y+yo,*p,size); } /* setCG(x,y) writes a "centering symbol" at (x,y) */ void setCG(int x,int y) { int xo,yo,zo; for(xo=0; xo<=50; xo++) { yo=sqrt(50.0*50.0-xo*xo); setpixel(x+xo,y+yo,1); setpixel(x+yo,y+xo,1); setpixel(x-1-xo,y-1-yo,1); setpixel(x-1-yo,y-1-xo,1); setpixel(x+xo,y-1-yo,1); setpixel(x-1-xo,y+yo,1); for(zo=0; zo=Width) return; if(y=BitMap_bottomline) return; for(i=0; i