109 |
|
|
110 |
|
extern char *malloc(), *calloc(); |
111 |
|
|
112 |
– |
extern double pow(), log(); |
113 |
– |
|
112 |
|
Display *thedisplay; |
113 |
|
|
114 |
+ |
|
115 |
|
main(argc, argv) |
116 |
|
int argc; |
117 |
|
char *argv[]; |
234 |
|
getbestvis(); |
235 |
|
/* store image */ |
236 |
|
getras(); |
237 |
+ |
/* get size and position */ |
238 |
+ |
bzero((char *)&oursizhints, sizeof(oursizhints)); |
239 |
+ |
oursizhints.width = xmax; oursizhints.height = ymax; |
240 |
+ |
if (geometry != NULL) { |
241 |
+ |
i = XParseGeometry(geometry, &oursizhints.x, &oursizhints.y, |
242 |
+ |
(unsigned *)&oursizhints.width, |
243 |
+ |
(unsigned *)&oursizhints.height); |
244 |
+ |
if ((i&(WidthValue|HeightValue)) == (WidthValue|HeightValue)) |
245 |
+ |
oursizhints.flags |= USSize; |
246 |
+ |
else |
247 |
+ |
oursizhints.flags |= PSize; |
248 |
+ |
if ((i&(XValue|YValue)) == (XValue|YValue)) { |
249 |
+ |
oursizhints.flags |= USPosition; |
250 |
+ |
if (i & XNegative) |
251 |
+ |
oursizhints.x += DisplayWidth(thedisplay, |
252 |
+ |
ourscreen)-1-oursizhints.width-2*BORWIDTH; |
253 |
+ |
if (i & YNegative) |
254 |
+ |
oursizhints.y += DisplayHeight(thedisplay, |
255 |
+ |
ourscreen)-1-oursizhints.height-2*BORWIDTH; |
256 |
+ |
} |
257 |
+ |
} |
258 |
|
/* open window */ |
259 |
|
ourwinattr.border_pixel = ourblack; |
260 |
|
ourwinattr.background_pixel = ourwhite; |
261 |
|
ourwinattr.colormap = XCreateColormap(thedisplay, ourroot, |
262 |
|
ourvis.visual, AllocNone); |
263 |
< |
wind = XCreateWindow(thedisplay, ourroot, 0, 0, xmax, ymax, BORWIDTH, |
263 |
> |
wind = XCreateWindow(thedisplay, ourroot, oursizhints.x, oursizhints.y, |
264 |
> |
oursizhints.width, oursizhints.height, BORWIDTH, |
265 |
|
ourvis.depth, InputOutput, ourvis.visual, |
266 |
|
CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr); |
267 |
|
if (wind == 0) |
280 |
|
XDefineCursor(thedisplay, wind, XCreateFontCursor(thedisplay, |
281 |
|
XC_diamond_cross)); |
282 |
|
XStoreName(thedisplay, wind, fname == NULL ? progname : fname); |
283 |
< |
if (geometry != NULL) { |
263 |
< |
bzero((char *)&oursizhints, sizeof(oursizhints)); |
264 |
< |
i = XParseGeometry(geometry, &oursizhints.x, &oursizhints.y, |
265 |
< |
(unsigned *)&oursizhints.width, |
266 |
< |
(unsigned *)&oursizhints.height); |
267 |
< |
if ((i&(WidthValue|HeightValue)) == (WidthValue|HeightValue)) |
268 |
< |
oursizhints.flags |= USSize; |
269 |
< |
else { |
270 |
< |
oursizhints.width = xmax; |
271 |
< |
oursizhints.height = ymax; |
272 |
< |
oursizhints.flags |= PSize; |
273 |
< |
} |
274 |
< |
if ((i&(XValue|YValue)) == (XValue|YValue)) { |
275 |
< |
oursizhints.flags |= USPosition; |
276 |
< |
if (i & XNegative) |
277 |
< |
oursizhints.x += DisplayWidth(thedisplay, |
278 |
< |
ourscreen)-1-oursizhints.width-2*BORWIDTH; |
279 |
< |
if (i & YNegative) |
280 |
< |
oursizhints.y += DisplayHeight(thedisplay, |
281 |
< |
ourscreen)-1-oursizhints.height-2*BORWIDTH; |
282 |
< |
} |
283 |
> |
if (oursizhints.flags) |
284 |
|
XSetNormalHints(thedisplay, wind, &oursizhints); |
284 |
– |
} |
285 |
|
ourxwmhints.flags = InputHint|IconPixmapHint; |
286 |
|
ourxwmhints.input = True; |
287 |
|
ourxwmhints.icon_pixmap = XCreateBitmapFromData(thedisplay, |
308 |
|
} |
309 |
|
|
310 |
|
|
311 |
– |
eputs(s) |
312 |
– |
char *s; |
313 |
– |
{ |
314 |
– |
fputs(s, stderr); |
315 |
– |
} |
316 |
– |
|
317 |
– |
|
318 |
– |
quit(code) |
319 |
– |
int code; |
320 |
– |
{ |
321 |
– |
exit(code); |
322 |
– |
} |
323 |
– |
|
324 |
– |
|
311 |
|
static int |
312 |
|
viscmp(v1,v2) /* compare visual to see which is better, descending */ |
313 |
|
register XVisualInfo *v1, *v2; |
615 |
|
make_rpixmap(ourras, wind); |
616 |
|
redraw(0, 0, width, height); |
617 |
|
return(0); |
618 |
+ |
case '0': /* recenter origin */ |
619 |
+ |
if (xoff == 0 & yoff == 0) |
620 |
+ |
return(0); |
621 |
+ |
xoff = yoff = 0; |
622 |
+ |
XClearWindow(thedisplay, wind); |
623 |
+ |
redraw(0, 0, width, height); |
624 |
+ |
return(0); |
625 |
|
case ' ': /* clear */ |
626 |
|
redraw(box.xmin, box.ymin, box.xsiz, box.ysiz); |
627 |
|
return(0); |
733 |
|
return(-1); |
734 |
|
if (left == ll && right == lr && top == lt && bottom == lb) { |
735 |
|
copycolor(clr, lc); |
736 |
< |
return; |
736 |
> |
return(0); |
737 |
|
} |
738 |
|
for (y = top; y < bottom; y++) { |
739 |
|
if (getscan(y) == -1) |
762 |
|
quiterr("out of memory in getmono"); |
763 |
|
dp = ourdata - 1; |
764 |
|
for (y = 0; y < ymax; y++) { |
765 |
< |
if (getscan(y) < 0) |
773 |
< |
quiterr("seek error in getmono"); |
774 |
< |
normcolrs(scanline, xmax, scale); |
765 |
> |
getscan(y); |
766 |
|
add2icon(y, scanline); |
767 |
+ |
normcolrs(scanline, xmax, scale); |
768 |
|
err = 0; |
769 |
|
for (x = 0; x < xmax; x++) { |
770 |
|
if (!(x&7)) |
790 |
|
static short cerr[ICONSIZ]; |
791 |
|
static int ynext; |
792 |
|
static char *dp; |
793 |
+ |
COLR clr; |
794 |
|
register int err; |
795 |
|
register int x, ti; |
796 |
|
int errp; |
821 |
|
*++dp = 0; |
822 |
|
errp = err; |
823 |
|
ti = x*xmax/iconwidth; |
824 |
< |
err += normbright(scan[ti]) + cerr[x]; |
824 |
> |
copycolr(clr, scan[ti]); |
825 |
> |
normcolrs(clr, 1, scale); |
826 |
> |
err += normbright(clr) + cerr[x]; |
827 |
|
if (err > 127) |
828 |
|
err -= 255; |
829 |
|
else |
845 |
|
/* read and convert file */ |
846 |
|
dp = (unsigned long *)ourdata; |
847 |
|
for (y = 0; y < ymax; y++) { |
848 |
< |
if (getscan(y) < 0) |
849 |
< |
quiterr("seek error in getfull"); |
848 |
> |
getscan(y); |
849 |
> |
add2icon(y, scanline); |
850 |
|
if (scale) |
851 |
|
shiftcolrs(scanline, xmax, scale); |
852 |
|
colrs_gambs(scanline, xmax); |
858 |
– |
add2icon(y, scanline); |
853 |
|
if (ourras->image->blue_mask & 1) |
854 |
|
for (x = 0; x < xmax; x++) |
855 |
|
*dp++ = scanline[x][RED] << 16 | |
874 |
|
/* read and convert file */ |
875 |
|
dp = ourdata; |
876 |
|
for (y = 0; y < ymax; y++) { |
877 |
< |
if (getscan(y) < 0) |
878 |
< |
quiterr("seek error in getgrey"); |
877 |
> |
getscan(y); |
878 |
> |
add2icon(y, scanline); |
879 |
|
if (scale) |
880 |
|
shiftcolrs(scanline, xmax, scale); |
881 |
+ |
for (x = 0; x < xmax; x++) |
882 |
+ |
scanline[x][GRN] = normbright(scanline[x]); |
883 |
|
colrs_gambs(scanline, xmax); |
888 |
– |
add2icon(y, scanline); |
884 |
|
if (maxcolors < 256) |
885 |
|
for (x = 0; x < xmax; x++) |
886 |
< |
*dp++ = ((long)normbright(scanline[x]) * |
887 |
< |
maxcolors + 128) >> 8; |
886 |
> |
*dp++ = ((long)scanline[x][GRN] * |
887 |
> |
maxcolors + maxcolors/2) >> 8; |
888 |
|
else |
889 |
|
for (x = 0; x < xmax; x++) |
890 |
< |
*dp++ = normbright(scanline[x]); |
890 |
> |
*dp++ = scanline[x][GRN]; |
891 |
|
} |
892 |
|
for (x = 0; x < maxcolors; x++) |
893 |
|
clrtab[x][RED] = clrtab[x][GRN] = |
894 |
< |
clrtab[x][BLU] = (x*256+maxcolors/2)/maxcolors; |
894 |
> |
clrtab[x][BLU] = ((long)x*256 + 128)/maxcolors; |
895 |
|
} |
896 |
|
|
897 |
|
|
905 |
|
for (y = 0; y < ymax; y++) { |
906 |
|
if (getscan(y) < 0) |
907 |
|
quiterr("seek error in getmapped"); |
908 |
+ |
add2icon(y, scanline); |
909 |
|
if (scale) |
910 |
|
shiftcolrs(scanline, xmax, scale); |
911 |
|
colrs_gambs(scanline, xmax); |
916 |
– |
add2icon(y, scanline); |
912 |
|
cnt_colrs(scanline, xmax); |
913 |
|
} |
914 |
|
/* map pixels */ |