Rev 10 | Rev 8103 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 10 | Rev 7076 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | if(image==NULL) error("Image creation failure"); |
39 | if(image==NULL) error("Image creation failure"); |
40 | color_white=gdImageColorAllocate(image,255,255,255); |
40 | color_white=gdImageColorAllocate(image,255,255,255); |
41 | color_black=gdImageColorAllocate(image,0,0,0); |
41 | color_black=gdImageColorAllocate(image,0,0,0); |
42 | color_bounder=gdImageColorAllocate(image,1,2,3); |
42 | color_bounder=gdImageColorAllocate(image,1,2,3); |
43 | gdImageColorTransparent(image,color_white); |
43 | gdImageColorTransparent(image,color_white); |
44 | printf("Created image: %dx%d\n",xsize,ysize); |
44 | printf("Created image: %dx%d\n",xsize,ysize); |
45 | } |
45 | } |
46 | 46 | ||
47 | void saveimage() |
47 | void saveimage() |
48 | { |
48 | { |
49 | int xsize, ysize; |
49 | int xsize, ysize; |
Line 57... | Line 57... | ||
57 | if(*outfile) *outfile++=0; |
57 | if(*outfile) *outfile++=0; |
58 | outf=fopen(ff,"w"); if(outf==NULL) error("unable to create gif output."); |
58 | outf=fopen(ff,"w"); if(outf==NULL) error("unable to create gif output."); |
59 | printf("Output to %s.\n",ff); |
59 | printf("Output to %s.\n",ff); |
60 | if(compressratio==1) gdImageGif(image,outf); |
60 | if(compressratio==1) gdImageGif(image,outf); |
61 | else { |
61 | else { |
62 | gdImagePtr image2; |
62 | gdImagePtr image2; |
63 | int x2, y2; |
63 | int x2, y2; |
64 | x2=(xsize+1)/2; y2=(ysize+1)/2; |
64 | x2=(xsize+1)/2; y2=(ysize+1)/2; |
65 | image2=gdImageCreate(x2,y2); |
65 | image2=gdImageCreate(x2,y2); |
66 | white2=gdImageColorAllocate(image2,255,255,255); |
66 | white2=gdImageColorAllocate(image2,255,255,255); |
67 | gdImageColorTransparent(image2,white2); |
67 | gdImageColorTransparent(image2,white2); |
68 | gdImageCopyResized(image2,image,0,0,0,0,x2,y2,xsize,ysize); |
68 | gdImageCopyResized(image2,image,0,0,0,0,x2,y2,xsize,ysize); |
69 | gdImageGif(image2,outf); gdImageDestroy(image2); |
69 | gdImageGif(image2,outf); gdImageDestroy(image2); |
70 | } |
70 | } |
71 | fclose(outf); |
71 | fclose(outf); |
72 | gdImageDestroy(image); image=NULL; |
72 | gdImageDestroy(image); image=NULL; |
73 | } |
73 | } |
74 | 74 | ||
Line 78... | Line 78... | ||
78 | char *buf; |
78 | char *buf; |
79 | ch-=f->bc; x+=f->fh[ch].xstart; y+=f->fh[ch].ystart; |
79 | ch-=f->bc; x+=f->fh[ch].xstart; y+=f->fh[ch].ystart; |
80 | xlen=f->fh[ch].xmax; ylen=f->fh[ch].ymax; |
80 | xlen=f->fh[ch].xmax; ylen=f->fh[ch].ymax; |
81 | xsize=(xlen+7)/8; buf=f->data+f->fh[ch].start; |
81 | xsize=(xlen+7)/8; buf=f->data+f->fh[ch].start; |
82 | for(j=0;j<ylen;j++) for(i=0;i<xlen;i++) { |
82 | for(j=0;j<ylen;j++) for(i=0;i<xlen;i++) { |
83 | if((buf[j*xsize+(i>>3)]&(1<<(i&7)))!=0) |
83 | if((buf[j*xsize+(i>>3)]&(1<<(i&7)))!=0) |
84 | gdImageSetPixel(image,x+i,y+j,color); |
84 | gdImageSetPixel(image,x+i,y+j,color); |
85 | } |
85 | } |
86 | return f->fh[ch].w; |
86 | return f->fh[ch].w; |
87 | } |
87 | } |
88 | 88 | ||
89 |
|
89 | /* Make color according to string indication */ |
90 | void makecolor(char *p) |
90 | void makecolor(char *p) |
91 | { |
91 | { |
92 | int t, r,g,b; |
92 | int t, r,g,b; |
93 | char *p2; |
93 | char *p2; |
94 | 94 | ||
95 | p=find_word_start(p); r=g=b=0; |
95 | p=find_word_start(p); r=g=b=0; |
- | 96 | p2=strchr(p,','); |
|
96 |
|
97 | if(p2==NULL) { /* color name */ |
97 | *find_word_end(p)=0; |
98 | *find_word_end(p)=0; |
98 | t=search_list(colors,colorno,sizeof(colors[0]),p); |
99 | t=search_list(colors,colorno,sizeof(colors[0]),p); |
99 | if(t<0) return; |
100 | if(t<0) return; |
100 | r=colors[t].r; g=colors[t].g; b=colors[t].b; |
101 | r=colors[t].r; g=colors[t].g; b=colors[t].b; |
101 | } |
102 | } |
102 | else { |
103 | else { /* rgb values */ |
103 | *p2++=0; |
104 | *p2++=0; |
104 | r=atoi(p); p=find_word_start(p2); |
105 | r=atoi(p); p=find_word_start(p2); |
105 | p2=strchr(p,','); if(p2==NULL) p2=p+strlen(p); else *p2++=0; |
106 | p2=strchr(p,','); if(p2==NULL) p2=p+strlen(p); else *p2++=0; |
106 | g=atoi(p); b=atoi(p2); |
107 | g=atoi(p); b=atoi(p2); |
107 | } |
108 | } |
108 | t=getcolor(r,g,b); |
109 | t=getcolor(r,g,b); |
109 | if(t!=-1) currentcolor=t; |
110 | if(t!=-1) currentcolor=t; |
110 | } |
111 | } |