44 static void map_scanline_generic();
45 static void map_1_dither_notable_1();
46 static void map_1_dither_table_8();
47 static void map_1_nodither_table_8();
48 static void map_2or3_dither_table_8();
49 static void map_1_nodither_notable_32();
50 static void map_2or3_nodither_table_8();
51 static void map_2or3_dither_notable_32();
52 static void map_2or3_nodither_notable_32();
53 static void map_1_mono_color_8();
54 static void map_1_mono_color_32();
55 static void MAG_scanline_generic();
56 static void MAG_1_dither_notable_1();
57 static void MAG_1_dither_table_8();
58 static void MAG_1_nodither_table_8();
59 static void MAG_1_nodither_notable_32();
60 static void MAG_2or3_dither_table_8();
61 static void MAG_2or3_nodither_table_8();
62 static void MAG_2or3_dither_notable_32();
63 static void MAG_2or3_nodither_notable_32();
64 static void MAG_1_mono_color_8();
65 static void MAG_1_mono_color_32();
67 static unsigned char LSBMask[9] = { 0x0, 0x1, 0x3, 0x7,
68 0xf, 0x1f, 0x3f, 0x7f, 0xff };
70 static unsigned char MSBMask[9] = { 0x00, 0x80, 0xc0, 0xe0,
71 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
78 image_information *img;
88 void (*mag_routine)();
89 } map_scanline_table[] =
94 { True, True, False, 1, map_1_dither_notable_1, MAG_1_dither_notable_1},
95 { True, True, True, 8, map_1_dither_table_8, MAG_1_dither_table_8},
96 { True, False,True, 8, map_1_nodither_table_8, MAG_1_nodither_table_8},
97 { True, False,False,32,map_1_nodither_notable_32, MAG_1_nodither_notable_32},
98 { False,True, True, 8, map_2or3_dither_table_8, MAG_2or3_dither_table_8},
99 { False,False,True, 8, map_2or3_nodither_table_8, MAG_2or3_nodither_table_8},
100 { False,True, False,32,map_2or3_dither_notable_32,MAG_2or3_dither_notable_32},
101 { False,False,False,32,map_2or3_nodither_notable_32,MAG_2or3_nodither_notable_32}};
107 table_present = False;
108 else table_present = True;
111 switch (img
->image->bits_per_pixel) {
121 fprintf(stderr,
"%s: Warning: Bits per pixel = %d\n",
125 for (i = 0; i <
COUNT_OF (map_scanline_table); i++) {
126 if (map_scanline_table[i].one_color == img
->mono_img &&
128 map_scanline_table[i].table_present == table_present &&
129 map_scanline_table[i].bpp == img
->image->bits_per_pixel) {
134 fprintf ( stderr,
"Special map_scanline routine used: map_");
137 fputs (
"1_", stderr );
138 else fputs (
"2or3_", stderr );
141 fputs (
"no", stderr );
142 fputs (
"dither_", stderr );
144 if (! table_present ) fputs (
"no", stderr );
145 fprintf ( stderr,
"table_%d (index %d)\n",
146 img
->image->bits_per_pixel, i );
165 #define DMAP(v,x,y) (divN[v] + (modN[v]>dm16[x][y] ? 1
: 0
) )
166 #define NDMAP(v) (divN[v])
168 #define DMAP_SETUP( img )
169 register int *divN = img->divN;
170 register int *modN = img->modN;
171 register array16 *dm16 = img->dm16
173 #define NDMAP_SETUP( img ) register int *divN = img->divN
175 #define IN_CMAP_SETUP( img ) register rle_pixel **in_cmap = img->in_cmap
177 #define LEVELS_SETUP( img )
178 register int levels = img->lvls;
179 register int levels_squared = img->lvls_squared
182 #define X_CMAP_SETUP( img ) cmap_info cmap_i; cmap_i = img->x_cmap;
186 map_scanline_generic (img, rgb, ncolors, given_width, stride, y, image)
187 image_information *img;
188 unsigned char *rgb[3];
201 register unsigned char *r;
203 register int width = given_width;
215 r += stride, col = ((col + 1) & 15), x ++) {
216 pixel =
DMAP(*r, col, row);
217 pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
219 XPutPixel (image, x, y, pixel);
225 for (x = 0; --width >= 0;
227 pixel = pixel_table[*r];
228 XPutPixel (image, x, y, pixel);
231 for (x = 0; --width >= 0;
234 pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
236 XPutPixel (image, x, y, pixel);
244 register unsigned char *g;
245 register unsigned char *b;
248 if (ncolors >= 3) b = rgb[2];
251 for (x = 0; --width >= 0;
252 r += stride, g += stride, b += stride,
253 col = ((col + 1) & 15), x ++ )
255 if (pixel_table != NULL)
257 [
DMAP(*r, col, row) +
258 DMAP(*g, col, row) * levels +
259 DMAP(*b, col, row) * levels_squared];
265 XPutPixel (image, x, y, pixel);
272 for (x = 0; --width >= 0;
273 r += stride, g += stride, b += stride, x++ ) {
274 if ( pixel_table != NULL) {
278 NDMAP(*b) * levels_squared];
283 XPutPixel (image, x, y, pixel);
290 MAG_scanline_generic( img, rle_x, rle_y, mag_size, x, y, width, height, image )
291 image_information *img;
303 register unsigned char *r;
306 int mag_y = mag_size;
308 register int row = (mag_size * rle_y - 1) % 16;
309 int x_mod_16 = (mag_size * rle_x) % 16;
310 unsigned char *rgb_line =
SAVED_RLE_ROW( img, rle_y ) + rle_x;
312 register unsigned long pixel;
315 while (--height >= 0) {
318 row = (row + 1) % 16;
328 pixel =
DMAP(*r, col++, row);
329 pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
331 XPutPixel (image, x, y, pixel);
343 pixel = pixel_table[*r];
344 XPutPixel (image, x, y, pixel);
356 pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
358 XPutPixel (image, x, y, pixel);
369 register unsigned char *g;
370 register unsigned char *b;
378 if ( pixel_table != NULL)
380 [
DMAP(*r, col, row) +
381 DMAP(*g, col, row) * levels +
382 DMAP(*b, col, row) * levels_squared];
388 XPutPixel (image, x++, y, pixel);
400 if ( pixel_table != NULL)
404 NDMAP(*b) * levels_squared];
409 XPutPixel (image, x++, y, pixel);
419 rgb_line += rgb_line_stride;
440 map_1_dither_table_8(img, rgb, ncolors, given_width, stride, y, image)
441 image_information *img;
442 unsigned char *rgb[3];
453 register unsigned char *r;
454 register unsigned char *pixel_ptr;
455 register int width = given_width;
461 pixel_ptr = ((
unsigned char *) image->data) + y * image->bytes_per_line;
463 while (--width >= 0) {
464 *pixel_ptr++ = pixel_table [
DMAP(*r, col, row) ];
467 col = ((col + 1) & 15);
473 MAG_1_dither_table_8( img, rle_x, rle_y, mag_size, x, y, width, height, image )
474 image_information *img;
484 register unsigned char *r;
485 register unsigned char *pixel_ptr;
487 int mag_y = mag_size;
489 register int row = (mag_size * rle_y - 1) % 16;
490 int x_mod_16 = (mag_size * rle_x) % 16;
491 unsigned char *line_ptr;
492 unsigned char *rgb_line =
SAVED_RLE_ROW( img, rle_y ) + rle_x;
495 line_ptr = ((
unsigned char *) image->data)+(y * image->bytes_per_line) + x;
497 while (--height >= 0) {
498 pixel_ptr = line_ptr;
500 row = (row + 1) % 16;
506 *pixel_ptr++ = pixel_table [
DMAP(*r, col++, row) ];
514 line_ptr += image->bytes_per_line;
517 rgb_line += rgb_line_stride;
540 map_2or3_dither_table_8 (img, rgb, ncolors, given_width, stride, y, image)
541 image_information *img;
542 unsigned char *rgb[3];
555 register unsigned char *r, *g, *b;
556 register unsigned char *pixel_ptr;
557 register int width = given_width;
563 if (ncolors >= 3) b = rgb[2];
565 pixel_ptr = ((
unsigned char *) image->data) + y * image->bytes_per_line;
567 while (--width >= 0) {
568 *pixel_ptr++ = pixel_table [
DMAP(*r, col, row) +
569 DMAP(*g, col, row) * levels +
570 DMAP(*b, col, row) * levels_squared];
574 col = ((col + 1) & 15);
579 MAG_2or3_dither_table_8 ( img, rle_x, rle_y, mag_size, x, y, width, height, image)
580 image_information *img;
592 register unsigned char *r, *g, *b;
593 register unsigned char *pixel_ptr;
595 int mag_y = mag_size;
597 register int row = (mag_size * rle_y - 1) % 16;
598 int x_mod_16 = (mag_size * rle_x) % 16;
599 unsigned char *line_ptr;
600 unsigned char *rgb_line =
SAVED_RLE_ROW( img, rle_y ) + rle_x;
603 line_ptr = ((
unsigned char *) image->data)+(y * image->bytes_per_line) + x;
605 while (--height >= 0) {
606 pixel_ptr = line_ptr;
608 row = (row + 1) % 16;
617 *pixel_ptr++ = pixel_table [
DMAP(*r, col, row) +
618 DMAP(*g, col, row) * levels +
619 DMAP(*b, col, row) * levels_squared];
628 line_ptr += image->bytes_per_line;
631 rgb_line += rgb_line_stride;
651 map_1_dither_notable_1 (img, rgb, ncolors, given_width, stride, y, image)
652 image_information *img;
653 unsigned char *rgb[3];
664 register unsigned char *r;
665 register unsigned char *pixel_ptr;
666 register int width = given_width;
672 pixel_ptr = ((
unsigned char *) image->data) + y * image->bytes_per_line;
674 if( BitmapBitOrder(
dpy) == MSBFirst ) {
676 *pixel_ptr >>= (8 - bit) & 7;
682 if (
DMAP(*r, col++, row) )
683 *pixel_ptr |= (
unsigned char) 0x1;
689 pixel_ptr++, col &= 15;
691 while ((width -= 8) >= 0) {
693 if (
DMAP(*r, col++, row) )
694 *pixel_ptr = (
unsigned char) 0x80;
696 if (
DMAP(*r, col++, row) )
697 *pixel_ptr |= (
unsigned char) 0x40;
699 if (
DMAP(*r, col++, row) )
700 *pixel_ptr |= (
unsigned char) 0x20;
702 if (
DMAP(*r, col++, row) )
703 *pixel_ptr |= (
unsigned char) 0x10;
705 if (
DMAP(*r, col++, row) )
706 *pixel_ptr |= (
unsigned char) 0x8;
708 if (
DMAP(*r, col++, row) )
709 *pixel_ptr |= (
unsigned char) 0x4;
711 if (
DMAP(*r, col++, row) )
712 *pixel_ptr |= (
unsigned char) 0x2;
714 if (
DMAP(*r, col++, row) )
715 *pixel_ptr |= (
unsigned char) 0x1;
725 unsigned char savebits;
727 savebits = *pixel_ptr &
LSBMask[8-width];
730 while (--width >= 0) {
732 if (
DMAP(*r, col++, row) )
733 *pixel_ptr |= (
unsigned char) 0x1;
736 *pixel_ptr <<= 8 - bit;
737 *pixel_ptr |= savebits;
741 while (--width >= 0) {
742 *pixel_ptr = (
unsigned char)(*pixel_ptr >> 1) | (
unsigned char)
743 ((
DMAP(*r, col, row)!= 0) ? 0x80: 0);
746 col = ((col + 1) & 15);
747 bit = ((bit + 1) & 7);
748 if (!bit) pixel_ptr++;
751 #define INC_RGB( stmt ) if ( --mag_x == 0
) {stmt; mag_x = mag_size; }
754 MAG_1_dither_notable_1 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
755 image_information *img;
763 register int col, bit;
764 register unsigned char *r;
765 register unsigned char *pixel_ptr;
768 register int row = (mag_size * rle_y - 1) % 16;
769 unsigned char *line_ptr;
770 unsigned char *rgb_line =
SAVED_RLE_ROW( img, rle_y ) + rle_x;
772 int x_mod_16 = (mag_size * rle_x) % 16;
774 int mag_y = mag_size;
775 int byte_order = BitmapBitOrder(
dpy);
777 line_ptr = ((
unsigned char *) image->data) +
778 (y * image->bytes_per_line) + x / 8;
780 while (--height >= 0) {
781 pixel_ptr = line_ptr;
786 row = (row + 1) % 16;
790 if( byte_order == MSBFirst ) {
792 *pixel_ptr >>= (8 - bit) & 7;
798 *pixel_ptr |=
DMAP(*r, col++, row)!=0;
813 while ((w -= 8) >= 0) {
814 *pixel_ptr = (
unsigned char) 0;
815 if (
DMAP(*r, col++, row) )
816 *pixel_ptr = (
unsigned char) 0x80;
818 if (
DMAP(*r, col++, row) )
819 *pixel_ptr |= (
unsigned char) 0x40;
821 if (
DMAP(*r, col++, row) )
822 *pixel_ptr |= (
unsigned char) 0x20;
824 if (
DMAP(*r, col++, row) )
825 *pixel_ptr |= (
unsigned char) 0x10;
827 if (
DMAP(*r, col++, row) )
828 *pixel_ptr |= (
unsigned char) 0x8;
830 if (
DMAP(*r, col++, row) )
831 *pixel_ptr |= (
unsigned char) 0x4;
833 if (
DMAP(*r, col++, row) )
834 *pixel_ptr |= (
unsigned char) 0x2;
836 if (
DMAP(*r, col++, row) )
837 *pixel_ptr |= (
unsigned char) 0x1;
846 unsigned char savebits;
848 savebits = *pixel_ptr &
LSBMask[8-w];
853 *pixel_ptr |= (
unsigned char)
854 (
DMAP(*r, col++, row) ? 0x1 : 0);
857 *pixel_ptr <<= 8 - bit;
858 *pixel_ptr |= savebits;
863 *pixel_ptr <<= (8 - bit) & 7;
868 if (
DMAP(*r, col++, row) )
869 *pixel_ptr |= (
unsigned char) 0x80;
877 while ((w -= 8) >= 0) {
878 *pixel_ptr = (
unsigned char) 0x0;
879 if (
DMAP(*r, col++, row) )
880 *pixel_ptr = (
unsigned char) 0x1;
882 if (
DMAP(*r, col++, row) )
883 *pixel_ptr |= (
unsigned char) 0x2;
885 if (
DMAP(*r, col++, row) )
886 *pixel_ptr |= (
unsigned char) 0x4;
888 if (
DMAP(*r, col++, row) )
889 *pixel_ptr |= (
unsigned char) 0x8;
891 if (
DMAP(*r, col++, row) )
892 *pixel_ptr |= (
unsigned char) 0x10;
894 if (
DMAP(*r, col++, row) )
895 *pixel_ptr |= (
unsigned char) 0x20;
897 if (
DMAP(*r, col++, row) )
898 *pixel_ptr |= (
unsigned char) 0x40;
900 if (
DMAP(*r, col++, row) )
901 *pixel_ptr |= (
unsigned char) 0x80;
911 unsigned char savebits = (
unsigned char )(*pixel_ptr >> 8 - w);
912 savebits <<= (
unsigned char)8 - w;
917 if (
DMAP(*r, col++, row))
918 *pixel_ptr |= (
unsigned char) 0x80;
921 *pixel_ptr >>= 8 - bit;
922 *pixel_ptr |= savebits;
925 line_ptr += image->bytes_per_line;
928 rgb_line += rgb_line_stride;
951 map_2or3_nodither_table_8 (img, rgb, ncolors, given_width, stride, y, image)
952 image_information *img;
953 unsigned char *rgb[3];
964 register unsigned char *r, *g, *b;
965 register unsigned char *pixel_ptr;
966 register int width = given_width;
970 if (ncolors >= 3) b = rgb[2];
972 pixel_ptr = ((
unsigned char *) image->data) + y * image->bytes_per_line;
974 while (--width >= 0) {
975 *pixel_ptr++ = pixel_table [
NDMAP(*r)
977 +
NDMAP(*b) * levels_squared];
985 MAG_2or3_nodither_table_8( img, rle_x, rle_y, mag_size, x, y, width, height, image )
986 image_information *img;
997 register unsigned char *r, *g, *b;
998 register unsigned char *pixel_ptr;
999 register unsigned char table_value;
1001 int mag_y = mag_size;
1003 unsigned char *line_ptr, *last_line;
1004 unsigned char *rgb_line, *last_rgb;
1009 last_line = line_ptr =
1010 ((
unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1012 while (--height >= 0) {
1013 if ( rgb_line == last_rgb && last_line != line_ptr )
1014 memcpy( line_ptr, last_line, width );
1017 pixel_ptr = line_ptr;
1025 table_value = pixel_table [
NDMAP(*r)
1026 +
NDMAP(*g) * levels
1027 +
NDMAP(*b) * levels_squared];
1028 while ( --w >= 0 ) {
1029 *pixel_ptr++ = table_value;
1035 pixel_table [
NDMAP(*r)
1036 +
NDMAP(*g) * levels
1037 +
NDMAP(*b) * levels_squared];
1041 last_line = line_ptr;
1042 last_rgb = rgb_line;
1044 line_ptr += image->bytes_per_line;
1047 rgb_line += rgb_line_stride;
1066 map_1_nodither_table_8 (img, rgb, ncolors, given_width, stride, y, image)
1067 image_information *img;
1068 unsigned char *rgb[3];
1078 register unsigned char * r;
1079 register unsigned char * pixel_ptr;
1080 register int width = given_width;
1084 pixel_ptr = ((
unsigned char *) image->data) + y * image->bytes_per_line;
1086 while (--width >= 0) {
1087 *pixel_ptr++ = pixel_table [
NDMAP(*r) ];
1093 MAG_1_nodither_table_8(img, rle_x, rle_y, mag_size, x, y, width, height, image)
1094 image_information *img;
1103 register unsigned char * r;
1104 register unsigned char * pixel_ptr;
1105 register unsigned char table_value;
1107 int mag_y = mag_size;
1109 unsigned char *line_ptr, *last_line;
1110 unsigned char *rgb_line, *last_rgb;
1115 last_line = line_ptr =
1116 ((
unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1118 while (--height >= 0) {
1119 if ( rgb_line == last_rgb && last_line != line_ptr )
1120 memcpy( line_ptr, last_line, width );
1123 pixel_ptr = line_ptr;
1128 table_value = pixel_table [
NDMAP(*r) ];
1130 *pixel_ptr++ = table_value;
1131 if ( --mag_x == 0 ){
1134 table_value = pixel_table [
NDMAP(*r) ];
1139 last_line = line_ptr;
1140 last_rgb = rgb_line;
1142 line_ptr += image->bytes_per_line;
1145 rgb_line += rgb_line_stride;
1163 map_1_mono_color_8 (img, rgb, ncolors, given_width, stride, y, image)
1164 image_information *img;
1165 unsigned char *rgb[3];
1174 register unsigned char * r;
1175 register unsigned char * pixel_ptr;
1176 register int width = given_width;
1180 pixel_ptr = ((
unsigned char *) image->data) + y * image->bytes_per_line;
1182 while (--width >= 0) {
1183 *pixel_ptr++ = pixel_table [ *r ];
1189 MAG_1_mono_color_8 (img, rle_x, rle_y, mag_size, x, y, width, height, image )
1190 image_information *img;
1198 register unsigned char * r;
1199 register unsigned char * pixel_ptr;
1200 register unsigned char table_value;
1202 int mag_y = mag_size;
1204 unsigned char *line_ptr, *last_line;
1205 unsigned char *rgb_line, *last_rgb;
1210 last_line = line_ptr =
1211 ((
unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1213 while (--height >= 0) {
1214 if ( rgb_line == last_rgb && last_line != line_ptr )
1215 memcpy( line_ptr, last_line, width );
1217 pixel_ptr = line_ptr;
1222 table_value = pixel_table [ *r ];
1224 *pixel_ptr++ = table_value;
1225 if ( --mag_x == 0 ){
1228 table_value = pixel_table [ *r ];
1233 last_line = line_ptr;
1234 last_rgb = rgb_line;
1236 line_ptr += image->bytes_per_line;
1239 rgb_line += rgb_line_stride;
1260 map_2or3_dither_table_32 ( img, rgb, ncolors, given_width, stride, y, image)
1261 image_information *img;
1262 unsigned char *rgb[3];
1270 register Pixel *pixel_table = img->pixel_table;
1272 LEVELS_SETUP( img );
1275 register unsigned char * r;
1276 register unsigned char *g;
1277 register unsigned char *b;
1278 register unsigned long pixval;
1279 register unsigned char * pixel_ptr;
1280 register int width = given_width;
1281 int byte_order = ImageByteOrder( dpy );
1288 if (ncolors >= 3) b = rgb[2];
1290 pixel_ptr = (
unsigned char *)image->data + y * image->bytes_per_line;
1292 while (--width >= 0) {
1294 pixval = pixel_table [DMAP(*r, col, row) +
1295 DMAP(*g, col, row) * levels +
1296 DMAP(*b, col, row) * levels_squared];
1297 if ( byte_order == MSBFirst )
1300 *pixel_ptr-- = pixval & 0xff;
1302 *pixel_ptr-- = pixval & 0xff;
1304 *pixel_ptr-- = pixval & 0xff;
1306 *pixel_ptr = pixval & 0xff;
1311 *pixel_ptr++ = pixval & 0xff;
1313 *pixel_ptr++ = pixval & 0xff;
1315 *pixel_ptr++ = pixval & 0xff;
1317 *pixel_ptr++ = pixval & 0xff;
1322 col = ((col + 1) & 15);
1332 MAG_2or3_dither_table_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1333 image_information *img;
1340 register Pixel *pixel_table = img->pixel_table;
1342 LEVELS_SETUP( img );
1344 register unsigned long pixval;
1345 register unsigned char * pixel_ptr;
1346 register unsigned char *r;
1347 register unsigned char *g;
1348 register unsigned char *b;
1350 register int row = (mag_size * rle_y - 1) % 16;
1352 int mag_y = mag_size;
1353 int x_mod_16 = (mag_size * rle_x) % 16;
1354 unsigned char *line_ptr;
1355 unsigned char *rgb_line = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1356 int rgb_line_stride = img->w * img->dpy_channels;
1357 int byte_order = ImageByteOrder( dpy );
1359 line_ptr = (
unsigned char *)
1360 ((image->data) + (y * image->bytes_per_line)) + 4 * x;
1362 while (--height >= 0) {
1363 pixel_ptr = line_ptr;
1365 row = (row + 1) % 16;
1371 if (img->dpy_channels >= 3) b += img->w;
1374 pixval = pixel_table [DMAP(*r, col, row) +
1375 DMAP(*g, col, row) * levels +
1376 DMAP(*b, col, row) * levels_squared];
1377 if ( byte_order == MSBFirst )
1380 *pixel_ptr-- = pixval & 0xff;
1382 *pixel_ptr-- = pixval & 0xff;
1384 *pixel_ptr-- = pixval & 0xff;
1386 *pixel_ptr = pixval & 0xff;
1391 *pixel_ptr++ = pixval & 0xff;
1393 *pixel_ptr++ = pixval & 0xff;
1395 *pixel_ptr++ = pixval & 0xff;
1397 *pixel_ptr++ = pixval & 0xff;
1407 line_ptr += image->bytes_per_line;
1410 rgb_line += rgb_line_stride;
1429 map_2or3_dither_notable_32 (img, rgb, ncolors, given_width, stride, y, image)
1430 image_information *img;
1431 unsigned char *rgb[3];
1442 register unsigned char *r;
1443 register unsigned char *g;
1444 register unsigned char *b;
1445 register unsigned long pixval;
1446 register unsigned char *pixel_ptr;
1447 register int width = given_width;
1448 int byte_order = ImageByteOrder(
dpy );
1455 if (ncolors >= 3) b = rgb[2];
1458 pixel_ptr = (
unsigned char *) ( image->data + y * image->bytes_per_line );
1460 while (--width >= 0) {
1464 DMAP(*b, col, row));
1465 if ( byte_order == MSBFirst )
1468 *pixel_ptr-- = pixval & 0xff;
1470 *pixel_ptr-- = pixval & 0xff;
1472 *pixel_ptr-- = pixval & 0xff;
1474 *pixel_ptr = pixval & 0xff;
1479 *pixel_ptr++ = pixval & 0xff;
1481 *pixel_ptr++ = pixval & 0xff;
1483 *pixel_ptr++ = pixval & 0xff;
1485 *pixel_ptr++ = pixval & 0xff;
1490 col = ((col + 1) & 15);
1494 MAG_2or3_dither_notable_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1495 image_information *img;
1503 register unsigned char *r, *g, *b;
1504 register unsigned long pixval;
1505 register unsigned char *pixel_ptr;
1506 register int row = (mag_size * rle_y - 1) % 16;
1509 int mag_y = mag_size;
1511 int x_mod_16 = (mag_size * rle_x) % 16;
1512 unsigned char *line_ptr;
1513 unsigned char *rgb_line =
SAVED_RLE_ROW( img, rle_y ) + rle_x;
1515 int byte_order = ImageByteOrder(
dpy );
1518 line_ptr = (
unsigned char *)
1519 (image->data + (y * image->bytes_per_line)) + 4 * x;
1521 while (--height >= 0) {
1522 pixel_ptr = line_ptr;
1524 row = (row + 1) % 16;
1535 DMAP(*b, col, row));
1536 if ( byte_order == MSBFirst )
1539 *pixel_ptr-- = pixval & 0xff;
1541 *pixel_ptr-- = pixval & 0xff;
1543 *pixel_ptr-- = pixval & 0xff;
1545 *pixel_ptr = pixval & 0xff;
1550 *pixel_ptr++ = pixval & 0xff;
1552 *pixel_ptr++ = pixval & 0xff;
1554 *pixel_ptr++ = pixval & 0xff;
1556 *pixel_ptr++ = pixval & 0xff;
1566 line_ptr += image->bytes_per_line;
1569 rgb_line += rgb_line_stride;
1590 map_2or3_nodither_notable_32 (img, rgb, ncolors, given_width, stride, y, image)
1591 image_information *img;
1592 unsigned char *rgb[3];
1601 register unsigned char *r;
1602 register unsigned char *g;
1603 register unsigned char *b;
1604 register unsigned long pixval;
1605 register unsigned char *pixel_ptr;
1606 register int width = given_width;
1607 int byte_order = ImageByteOrder(
dpy );
1612 if (ncolors >= 3) b = rgb[2];
1615 pixel_ptr = (
unsigned char *) ( image->data + y * image->bytes_per_line );
1617 while (--width >= 0) {
1620 if ( byte_order == MSBFirst )
1623 *pixel_ptr-- = pixval & 0xff;
1625 *pixel_ptr-- = pixval & 0xff;
1627 *pixel_ptr-- = pixval & 0xff;
1629 *pixel_ptr = pixval & 0xff;
1634 *pixel_ptr++ = pixval & 0xff;
1636 *pixel_ptr++ = pixval & 0xff;
1638 *pixel_ptr++ = pixval & 0xff;
1640 *pixel_ptr++ = pixval & 0xff;
1652 MAG_2or3_nodither_notable_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1653 image_information *img;
1662 register unsigned char *r, *g, *b;
1663 register unsigned long pixval;
1664 register unsigned char *pixel_ptr;
1665 unsigned long pixel_value;
1667 int mag_y = mag_size;
1669 unsigned char *line_ptr, *last_line;
1670 unsigned char *rgb_line, *last_rgb;
1672 int byte_order = ImageByteOrder(
dpy );
1677 last_line = line_ptr = (
unsigned char *)
1678 (image->data + (y * image->bytes_per_line)) + 4 * x;
1680 while (--height >= 0) {
1681 if ( rgb_line == last_rgb && last_line != line_ptr )
1682 memcpy( line_ptr, last_line, width *
sizeof(
long) );
1685 pixel_ptr = line_ptr;
1696 pixval = pixel_value;
1697 if ( byte_order == MSBFirst )
1700 *pixel_ptr-- = pixval & 0xff;
1702 *pixel_ptr-- = pixval & 0xff;
1704 *pixel_ptr-- = pixval & 0xff;
1706 *pixel_ptr = pixval & 0xff;
1711 *pixel_ptr++ = pixval & 0xff;
1713 *pixel_ptr++ = pixval & 0xff;
1715 *pixel_ptr++ = pixval & 0xff;
1717 *pixel_ptr++ = pixval & 0xff;
1728 last_line = line_ptr;
1729 last_rgb = rgb_line;
1731 line_ptr += image->bytes_per_line;
1734 rgb_line += rgb_line_stride;
1754 map_1_nodither_notable_32 (img, rgb, ncolors, given_width, stride, y, image)
1755 image_information *img;
1756 unsigned char *rgb[3];
1759 register int stride;
1765 register unsigned char *r;
1766 register unsigned long pixval;
1767 register unsigned char *pixel_ptr;
1768 register int width = given_width;
1769 int byte_order = ImageByteOrder(
dpy );
1774 pixel_ptr = (
unsigned char *) ( image->data + y * image->bytes_per_line );
1776 while (--width >= 0) {
1777 register int bw_value =
NDMAP(*r);
1780 if ( byte_order == MSBFirst )
1783 *pixel_ptr-- = pixval & 0xff;
1785 *pixel_ptr-- = pixval & 0xff;
1787 *pixel_ptr-- = pixval & 0xff;
1789 *pixel_ptr = pixval & 0xff;
1794 *pixel_ptr++ = pixval & 0xff;
1796 *pixel_ptr++ = pixval & 0xff;
1798 *pixel_ptr++ = pixval & 0xff;
1800 *pixel_ptr++ = pixval & 0xff;
1809 MAG_1_nodither_notable_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1810 image_information *img;
1819 register unsigned char *r;
1820 register unsigned long pixval;
1821 register unsigned char *pixel_ptr;
1822 unsigned long pixel_value;
1823 register int bw_value;
1826 register int mag_y = mag_size;
1827 unsigned char *line_ptr, *last_line;
1828 unsigned char *rgb_line, *last_rgb;
1830 int byte_order = ImageByteOrder(
dpy );
1835 last_line = line_ptr = (
unsigned char *)
1836 (image->data + (y * image->bytes_per_line)) + 4 * x;
1838 while (--height >= 0) {
1839 if ( rgb_line == last_rgb && last_line != line_ptr )
1840 memcpy( line_ptr, last_line, width *
sizeof(
long ) );
1843 pixel_ptr = line_ptr;
1848 bw_value =
NDMAP(*r);
1852 pixval = pixel_value;
1853 if ( byte_order == MSBFirst )
1856 *pixel_ptr-- = pixval & 0xff;
1858 *pixel_ptr-- = pixval & 0xff;
1860 *pixel_ptr-- = pixval & 0xff;
1862 *pixel_ptr = pixval & 0xff;
1867 *pixel_ptr++ = pixval & 0xff;
1869 *pixel_ptr++ = pixval & 0xff;
1871 *pixel_ptr++ = pixval & 0xff;
1873 *pixel_ptr++ = pixval & 0xff;
1880 bw_value =
NDMAP(*r);
1886 last_line = line_ptr;
1887 last_rgb = rgb_line;
1889 line_ptr += image->bytes_per_line;
1892 rgb_line += rgb_line_stride;
1911 map_1_mono_color_32 (img, rgb, ncolors, given_width, stride, y, image)
1912 image_information *img;
1913 unsigned char *rgb[3];
1916 register int stride;
1920 register unsigned char *r;
1921 register unsigned long pixval;
1922 register unsigned char *pixel_ptr;
1923 register int width = given_width;
1924 int byte_order = ImageByteOrder(
dpy );
1928 pixel_ptr = (
unsigned char *) ( image->data + y * image->bytes_per_line );
1930 while (--width >= 0) {
1932 if ( byte_order == MSBFirst )
1935 *pixel_ptr-- = pixval & 0xff;
1937 *pixel_ptr-- = pixval & 0xff;
1939 *pixel_ptr-- = pixval & 0xff;
1941 *pixel_ptr = pixval & 0xff;
1946 *pixel_ptr++ = pixval & 0xff;
1948 *pixel_ptr++ = pixval & 0xff;
1950 *pixel_ptr++ = pixval & 0xff;
1952 *pixel_ptr++ = pixval & 0xff;
1960 MAG_1_mono_color_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1961 image_information *img;
1969 register unsigned char *r;
1970 register unsigned char *pixel_ptr;
1971 register unsigned long pixval;
1972 unsigned long pixel_value;
1975 register int mag_y = mag_size;
1976 unsigned char *line_ptr, *last_line;
1977 unsigned char *rgb_line, *last_rgb;
1979 int byte_order = ImageByteOrder(
dpy );
1983 last_line = line_ptr = (
unsigned char *)
1984 (image->data + (y * image->bytes_per_line)) + 4 * x;
1986 while (--height >= 0) {
1987 if ( rgb_line == last_rgb && last_line != line_ptr )
1988 memcpy( line_ptr, last_line, width *
sizeof(
long ) );
1991 pixel_ptr = line_ptr;
1999 pixval = pixel_value;
2000 if ( byte_order == MSBFirst )
2003 *pixel_ptr-- = pixval & 0xff;
2005 *pixel_ptr-- = pixval & 0xff;
2007 *pixel_ptr-- = pixval & 0xff;
2009 *pixel_ptr = pixval & 0xff;
2014 *pixel_ptr++ = pixval & 0xff;
2016 *pixel_ptr++ = pixval & 0xff;
2018 *pixel_ptr++ = pixval & 0xff;
2020 *pixel_ptr++ = pixval & 0xff;
2031 last_line = line_ptr;
2032 last_rgb = rgb_line;
2034 line_ptr += image->bytes_per_line;
2037 rgb_line += rgb_line_stride;
2061 image_information *img;
2079 fprintf (stderr,
"%s: map_rgb_to_bw given %d colors\n",
2089 duff8( rowlen, *bw_row++ = *red++)
2092 duff8( rowlen, *bw_row++ = cmap[*red++])
2100 duff8( rowlen, *bw_row++ = ( 50 * *red++ + 50 * *green++ ) / 100)
2103 duff8( rowlen, *bw_row++ = (50 * cmap[0][*red++] +
2104 50 * cmap[1][*green++]) /100)
2114 duff8( rowlen, *bw_row++ = ( 35 * *red++ + 55 * *green++ +
2115 10 * *blue++ ) / 100)
2118 duff8( rowlen, *bw_row++ = ( 35 * cmap[0][*red++] +
2119 55 * cmap[1][*green++] +
2120 10 * cmap[2][*blue++] ) / 100)
2140 image_information *img;
2155 fprintf (stderr,
"%s: map_rgb_to_rgb given %d colors\n",
2161 while ( --ncolors >= 0 )
2168 duff8( w, *out++ = cmap[*in++] );
2175 while ( --ncolors >= 0 )
2177 if ( in_rows[0] != out_rows[0] )
2178 memcpy( out_rows[0], in_rows[0], rowlen );
2187 register image_information *img;
2190 img
->divN = (
int *) malloc ( 256 *
sizeof(
int) );
2192 img
->modN = (
int *) malloc ( 256 *
sizeof(
int) );
2198 fprintf( stderr,
"malloc error getting dither arrays\n");
2212 register Pixel high_bit;
2214 if (mask == 0)
return (0);
2216 high_bit = 0x80000000;
2218 for (shift = (32 - high_bit_index); (high_bit & mask) == 0; shift--) {
2231 register Pixel low_bit;
2233 if (mask == 0)
return (0);
2237 for (shift = 0; (low_bit & mask) == 0; shift++) {
void get_dither_arrays(register image_information *img)
static unsigned char LSBMask[9]
void choose_scanline_converter(image_information *img)
#define LEVELS_SETUP(img)
void map_rgb_to_rgb(image_information *img, rle_pixel **in_rows, rle_pixel **out_rows)
int shift_match_right(Pixel mask)
#define X_CMAP_SETUP(img)
#define duff8(counter, block)
#define SHIFT_MASK_PIXEL_32(r, g, b)
int shift_match_left(Pixel mask, int high_bit_index)
#define SAVED_RLE_ROW(img, y)
void map_rgb_to_bw(image_information *img, rle_pixel **rows, register rle_pixel *bw_row)
#define SHIFT_MASK_PIXEL(r, g, b)
VOID_FUNCTION * MAG_scanline
#define COUNT_OF(_array_)
VOID_FUNCTION * map_scanline