Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Macros | Functions | Variables
map_scan.c File Reference
#include "getx11.h"
Include dependency graph for map_scan.c:

Go to the source code of this file.

Macros

#define DMAP(v, x, y)   (divN[v] + (modN[v]>dm16[x][y] ? 1 : 0) )
 
#define NDMAP(v)   (divN[v])
 
#define DMAP_SETUP(img)
 
#define NDMAP_SETUP(img)   register int *divN = img->divN
 
#define IN_CMAP_SETUP(img)   register rle_pixel **in_cmap = img->in_cmap
 
#define LEVELS_SETUP(img)
 
#define X_CMAP_SETUP(img)   cmap_info cmap_i; cmap_i = img->x_cmap;
 
#define INC_RGB(stmt)   if ( --mag_x == 0 ) {stmt; mag_x = mag_size; }
 

Functions

static void map_scanline_generic ()
 
static void map_1_dither_notable_1 ()
 
static void map_1_dither_table_8 ()
 
static void map_1_nodither_table_8 ()
 
static void map_2or3_dither_table_8 ()
 
static void map_1_nodither_notable_32 ()
 
static void map_2or3_nodither_table_8 ()
 
static void map_2or3_dither_notable_32 ()
 
static void map_2or3_nodither_notable_32 ()
 
static void map_1_mono_color_8 ()
 
static void map_1_mono_color_32 ()
 
static void MAG_scanline_generic ()
 
static void MAG_1_dither_notable_1 ()
 
static void MAG_1_dither_table_8 ()
 
static void MAG_1_nodither_table_8 ()
 
static void MAG_1_nodither_notable_32 ()
 
static void MAG_2or3_dither_table_8 ()
 
static void MAG_2or3_nodither_table_8 ()
 
static void MAG_2or3_dither_notable_32 ()
 
static void MAG_2or3_nodither_notable_32 ()
 
static void MAG_1_mono_color_8 ()
 
static void MAG_1_mono_color_32 ()
 
void choose_scanline_converter (image_information *img)
 
static void map_scanline_generic (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_scanline_generic (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_1_dither_table_8 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_1_dither_table_8 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_2or3_dither_table_8 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_2or3_dither_table_8 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_1_dither_notable_1 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_1_dither_notable_1 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_2or3_nodither_table_8 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_2or3_nodither_table_8 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_1_nodither_table_8 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_1_nodither_table_8 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_1_mono_color_8 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_1_mono_color_8 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_2or3_dither_notable_32 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_2or3_dither_notable_32 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_2or3_nodither_notable_32 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_2or3_nodither_notable_32 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_1_nodither_notable_32 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_1_nodither_notable_32 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
static void map_1_mono_color_32 (image_information *img, rgb, int ncolors, int given_width, int stride, int y, XImage *image)
 
static void MAG_1_mono_color_32 (image_information *img, int rle_x, int rle_y, int mag_size, int x, int y, int width, int height, XImage *image)
 
void map_rgb_to_bw (image_information *img, rle_pixel **rows, rle_pixel *bw_row)
 
void map_rgb_to_rgb (image_information *img, rle_pixel **in_rows, rle_pixel **out_rows)
 
void get_dither_arrays (image_information *img)
 
int shift_match_left (Pixel mask, int high_bit_index)
 
int shift_match_right (Pixel mask)
 

Variables

static unsigned char LSBMask [9]
 

Macro Definition Documentation

#define DMAP (   v,
  x,
  y 
)    (divN[v] + (modN[v]>dm16[x][y] ? 1 : 0) )

Definition at line 165 of file map_scan.c.

#define DMAP_SETUP (   img)
Value:
register int *divN = img->divN;\
register int *modN = img->modN;\
register array16 *dm16 = img->dm16
static struct Image img
Definition: getami.c:71
int modN[256]
Definition: getap.c:80
int array16[16]
Definition: getx11.h:79
int dm16[16][16]
Definition: get_orion.c:48
int divN[256]
Definition: get_orion.c:51

Definition at line 168 of file map_scan.c.

#define IN_CMAP_SETUP (   img)    register rle_pixel **in_cmap = img->in_cmap

Definition at line 175 of file map_scan.c.

#define INC_RGB (   stmt)    if ( --mag_x == 0 ) {stmt; mag_x = mag_size; }

Definition at line 751 of file map_scan.c.

#define LEVELS_SETUP (   img)
Value:
register int levels = img->lvls; \
register int levels_squared = img->lvls_squared
static struct Image img
Definition: getami.c:71
#define levels
Definition: getmex.c:31

Definition at line 177 of file map_scan.c.

#define NDMAP (   v)    (divN[v])

Definition at line 166 of file map_scan.c.

#define NDMAP_SETUP (   img)    register int *divN = img->divN

Definition at line 173 of file map_scan.c.

#define X_CMAP_SETUP (   img)    cmap_info cmap_i; cmap_i = img->x_cmap;

Definition at line 182 of file map_scan.c.

Function Documentation

void choose_scanline_converter ( image_information img)

Definition at line 77 of file map_scan.c.

79 {
80  register int i;
81  register Boolean table_present;
82  static struct {
83  Boolean one_color;
84  Boolean dither;
85  Boolean table_present;
86  int bpp;
87  void (*routine)();
88  void (*mag_routine)();
89  } map_scanline_table[] =
90  {
91 
92  /* 1 color, dithr, Table, b/p, routine ptr */
93 
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},
98  { False,True, True, 8, map_2or3_dither_table_8, MAG_2or3_dither_table_8},
102 
105 
106  if (img->pixel_table == NULL)
107  table_present = False;
108  else table_present = True;
109 
110  if (img->mono_color)
111  switch (img->image->bits_per_pixel) {
112  case 32:
115  break;
116  case 8:
119  break;
120  default:
121  fprintf(stderr, "%s: Warning: Bits per pixel = %d\n",
122  progname, img->image->bits_per_pixel);
123  }
124  else
125  for (i = 0; i < COUNT_OF (map_scanline_table); i++) {
126  if (map_scanline_table[i].one_color == img->mono_img &&
127  map_scanline_table[i].dither == img->dither_img &&
128  map_scanline_table[i].table_present == table_present &&
129  map_scanline_table[i].bpp == img->image->bits_per_pixel) {
130  img->map_scanline = map_scanline_table[i].routine;
131  img->MAG_scanline = map_scanline_table[i].mag_routine;
132 
133  if ( verbose_flag ) {
134  fprintf ( stderr, "Special map_scanline routine used: map_");
135 
136  if ( img->mono_img )
137  fputs ( "1_", stderr );
138  else fputs ( "2or3_", stderr );
139 
140  if ( !img->dither_img )
141  fputs ( "no", stderr );
142  fputs ( "dither_", stderr );
143 
144  if (! table_present ) fputs ( "no", stderr );
145  fprintf ( stderr, "table_%d (index %d)\n",
146  img->image->bits_per_pixel, i );
147  }
148  break;
149  }
150  }
151 }
int Boolean
Definition: getx11.h:53
static void map_2or3_dither_table_8()
static void map_2or3_dither_notable_32()
static void map_1_dither_notable_1()
static void MAG_1_nodither_table_8()
static void MAG_1_mono_color_32()
static void MAG_2or3_dither_notable_32()
static void map_1_nodither_table_8()
static void MAG_2or3_nodither_notable_32()
Boolean verbose_flag
Definition: getx11.c:80
static void MAG_1_dither_notable_1()
static void map_1_mono_color_32()
static void map_2or3_nodither_notable_32()
Boolean mono_color
Definition: getx11.h:168
static void map_2or3_nodither_table_8()
Pixel * pixel_table
Definition: getx11.h:179
static void MAG_2or3_nodither_table_8()
static void map_1_mono_color_8()
static void MAG_1_dither_table_8()
static void map_1_nodither_notable_32()
static void MAG_2or3_dither_table_8()
XImage * image
Definition: getx11.h:129
static void MAG_scanline_generic()
Boolean mono_img
Definition: getx11.h:164
static void MAG_1_mono_color_8()
int i
Definition: rletorla.c:82
char progname[30]
Definition: rletorla.c:79
VOID_FUNCTION * MAG_scanline
Definition: getx11.h:144
#define COUNT_OF(_array_)
Definition: getx11.h:50
Boolean dither_img
Definition: getx11.h:165
static void map_1_dither_table_8()
VOID_FUNCTION * map_scanline
Definition: getx11.h:143
static void map_scanline_generic()
static void MAG_1_nodither_notable_32()
void get_dither_arrays ( image_information img)

Definition at line 2186 of file map_scan.c.

2188 {
2189  if (!img->divN)
2190  img->divN = (int *) malloc ( 256 * sizeof(int) );
2191  if (!img->modN)
2192  img->modN = (int *) malloc ( 256 * sizeof(int) );
2193  if (!img->dm16)
2194  img->dm16 = (array16 *) malloc ( 16 * 16 * sizeof(int) );
2195 
2196  if (!img->divN || !img->modN || !img->dm16 )
2197  {
2198  fprintf( stderr, "malloc error getting dither arrays\n");
2199  exit (1);
2200  }
2201 }
int array16[16]
Definition: getx11.h:79
void * malloc()
array16 * dm16
Definition: getx11.h:177
static void MAG_1_dither_notable_1 ( )
static
static void MAG_1_dither_notable_1 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 754 of file map_scan.c.

761 {
762  DMAP_SETUP( img );
763  register int col, bit;
764  register unsigned char *r;
765  register unsigned char *pixel_ptr;
766  register int mag_x;
767  register int w;
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;
771  int rgb_line_stride = img->w * img->dpy_channels;
772  int x_mod_16 = (mag_size * rle_x) % 16;
773  int x_mod_8 = x % 8;
774  int mag_y = mag_size;
775  int byte_order = BitmapBitOrder(dpy);
776 
777  line_ptr = ((unsigned char *) image->data) +
778  (y * image->bytes_per_line) + x / 8;
779 
780  while (--height >= 0) {
781  pixel_ptr = line_ptr;
782  w = width;
783  r = rgb_line;
784  mag_x = mag_size;
785 
786  row = (row + 1) % 16;
787  col = x_mod_16;
788  bit = x_mod_8;
789 
790  if( byte_order == MSBFirst ) {
791  /* we don't want to trash those good bits */
792  *pixel_ptr >>= (8 - bit) & 7;
793 
794  /* do first byte fragment */
795  while ( bit & 7 )
796  {
797  *pixel_ptr <<= 1;
798  *pixel_ptr |= DMAP(*r, col++, row)!=0;
799  w--;
800  INC_RGB( r++ );
801  bit++;
802  col &= 15;
803  }
804  if ( x_mod_8 )
805  pixel_ptr++;
806 
807  /* do the bulk of the line fast in eight bit chunks Gee I hope all
808  * this fits into your instruction cache... Or else we are
809  * forked.. You can get rid of 7 (col &= 15)'s if you make dm16
810  * a 32x16 array with duplicates in the second half of the columns.
811  * Then we don't have to worry about col overflowing in 8 ++'s
812  */
813  while ((w -= 8) >= 0) {
814  *pixel_ptr = (unsigned char) 0;
815  if ( DMAP(*r, col++, row) )
816  *pixel_ptr = (unsigned char) 0x80;
817  INC_RGB( r++ ); col &= 15;
818  if ( DMAP(*r, col++, row) )
819  *pixel_ptr |= (unsigned char) 0x40;
820  INC_RGB( r++ ); col &= 15;
821  if ( DMAP(*r, col++, row) )
822  *pixel_ptr |= (unsigned char) 0x20;
823  INC_RGB( r++ ); col &= 15;
824  if ( DMAP(*r, col++, row) )
825  *pixel_ptr |= (unsigned char) 0x10;
826  INC_RGB( r++ ); col &= 15;
827  if ( DMAP(*r, col++, row) )
828  *pixel_ptr |= (unsigned char) 0x8;
829  INC_RGB( r++ ); col &= 15;
830  if ( DMAP(*r, col++, row) )
831  *pixel_ptr |= (unsigned char) 0x4;
832  INC_RGB( r++ ); col &= 15;
833  if ( DMAP(*r, col++, row) )
834  *pixel_ptr |= (unsigned char) 0x2;
835  INC_RGB( r++ ); col &= 15;
836  if ( DMAP(*r, col++, row) )
837  *pixel_ptr |= (unsigned char) 0x1;
838  INC_RGB( r++ ); col &= 15;
839  pixel_ptr++;
840  }
841 
842  /* if w is non-zero then we have to finish up... */
843  w = 8 + w;
844  if ( w )
845  {
846  unsigned char savebits;
847 
848  savebits = *pixel_ptr & LSBMask[8-w];
849  bit = w;
850 
851  while (--w >= 0) {
852  *pixel_ptr <<= 1;
853  *pixel_ptr |= (unsigned char)
854  (DMAP(*r, col++, row) ? 0x1 : 0);
855  INC_RGB( r++ ); col &= 15;
856  }
857  *pixel_ptr <<= 8 - bit;
858  *pixel_ptr |= savebits;
859  }
860  }
861  else {
862  /* we don't want to trash those good bits */
863  *pixel_ptr <<= (8 - bit) & 7;
864 
865  /* do first byte fragment */
866  while ( col & 7 ) {
867  *pixel_ptr >>= 1;
868  if ( DMAP(*r, col++, row) )
869  *pixel_ptr |= (unsigned char) 0x80;
870  w--;
871  INC_RGB( r++ ); col &= 15;
872  }
873  if ( x_mod_8 )
874  pixel_ptr++;
875 
876  /* do the bulk of the line fast in eight bit chunks.. */
877  while ((w -= 8) >= 0) {
878  *pixel_ptr = (unsigned char) 0x0;
879  if ( DMAP(*r, col++, row) )
880  *pixel_ptr = (unsigned char) 0x1;
881  INC_RGB( r++ ); col &= 15;
882  if ( DMAP(*r, col++, row) )
883  *pixel_ptr |= (unsigned char) 0x2;
884  INC_RGB( r++ ); col &= 15;
885  if ( DMAP(*r, col++, row) )
886  *pixel_ptr |= (unsigned char) 0x4;
887  INC_RGB( r++ ); col &= 15;
888  if ( DMAP(*r, col++, row) )
889  *pixel_ptr |= (unsigned char) 0x8;
890  INC_RGB( r++ ); col &= 15;
891  if ( DMAP(*r, col++, row) )
892  *pixel_ptr |= (unsigned char) 0x10;
893  INC_RGB( r++ ); col &= 15;
894  if ( DMAP(*r, col++, row) )
895  *pixel_ptr |= (unsigned char) 0x20;
896  INC_RGB( r++ ); col &= 15;
897  if ( DMAP(*r, col++, row) )
898  *pixel_ptr |= (unsigned char) 0x40;
899  INC_RGB( r++ ); col &= 15;
900  if ( DMAP(*r, col++, row) )
901  *pixel_ptr |= (unsigned char) 0x80;
902  INC_RGB( r++ ); col &= 15;
903  pixel_ptr++;
904  }
905 
906  /* if w is negative then we have to finish up... */
907  w = 0 - w;
908 
909  if ( w )
910  {
911  unsigned char savebits = (unsigned char )(*pixel_ptr >> 8 - w);
912  savebits <<= (unsigned char)8 - w;
913  bit = w;
914 
915  while (--w >= 0) {
916  *pixel_ptr >>= 1;
917  if (DMAP(*r, col++, row))
918  *pixel_ptr |= (unsigned char) 0x80;
919  INC_RGB( r++ ); col &= 15;
920  }
921  *pixel_ptr >>= 8 - bit;
922  *pixel_ptr |= savebits;
923  }
924  }
925  line_ptr += image->bytes_per_line;
926  if ( --mag_y == 0 )
927  {
928  rgb_line += rgb_line_stride;
929  mag_y = mag_size;
930  }
931  }
932 }
Display * dpy
Definition: getx10.c:94
static unsigned char LSBMask[9]
Definition: map_scan.c:67
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static int x
Definition: getami.c:691
#define INC_RGB(stmt)
Definition: map_scan.c:751
static byte bit[9]
Definition: hilbert.c:52
#define DMAP_SETUP(img)
Definition: map_scan.c:168
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
static void MAG_1_dither_table_8 ( )
static
static void MAG_1_dither_table_8 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 473 of file map_scan.c.

480 {
481  register Pixel *pixel_table = img->pixel_table;
482  DMAP_SETUP( img );
483  register int col;
484  register unsigned char *r;
485  register unsigned char *pixel_ptr;
486  register int mag_x;
487  int mag_y = mag_size;
488  register int w;
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;
493  int rgb_line_stride = img->w * img->dpy_channels;
494 
495  line_ptr = ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
496 
497  while (--height >= 0) {
498  pixel_ptr = line_ptr;
499  w = width;
500  row = (row + 1) % 16;
501  col = x_mod_16;
502  r = rgb_line;
503  mag_x = mag_size;
504 
505  while (--w >= 0) {
506  *pixel_ptr++ = pixel_table [DMAP(*r, col++, row) ];
507  col &= 15;
508  if ( --mag_x == 0 )
509  {
510  r++;
511  mag_x = mag_size;
512  }
513  }
514  line_ptr += image->bytes_per_line;
515  if ( --mag_y == 0 )
516  {
517  rgb_line += rgb_line_stride;
518  mag_y = mag_size;
519  }
520  }
521 }
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define DMAP_SETUP(img)
Definition: map_scan.c:168
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
unsigned long Pixel
Definition: getx11.h:54
static void MAG_1_mono_color_32 ( )
static
static void MAG_1_mono_color_32 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 1960 of file map_scan.c.

1968 {
1969  register unsigned char *r;
1970  register unsigned char *pixel_ptr;
1971  register unsigned long pixval;
1972  unsigned long pixel_value;
1973  register int mag_x;
1974  register int w;
1975  register int mag_y = mag_size;
1976  unsigned char *line_ptr, *last_line;
1977  unsigned char *rgb_line, *last_rgb;
1978  int rgb_line_stride = img->w * img->dpy_channels;
1979  int byte_order = ImageByteOrder( dpy );
1980 
1981  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1982 
1983  last_line = line_ptr = (unsigned char *)
1984  (image->data + (y * image->bytes_per_line)) + 4 * x;
1985 
1986  while (--height >= 0) {
1987  if ( rgb_line == last_rgb && last_line != line_ptr )
1988  memcpy( line_ptr, last_line, width * sizeof( long ) );
1989  else
1990  {
1991  pixel_ptr = line_ptr;
1992  w = width;
1993  r = rgb_line;
1994  mag_x = mag_size;
1995 
1996  pixel_value = img->pixel_table[ *r ];
1997 
1998  while (--w >= 0) {
1999  pixval = pixel_value;
2000  if ( byte_order == MSBFirst )
2001  {
2002  pixel_ptr += 3;
2003  *pixel_ptr-- = pixval & 0xff;
2004  pixval >>= 8;
2005  *pixel_ptr-- = pixval & 0xff;
2006  pixval >>= 8;
2007  *pixel_ptr-- = pixval & 0xff;
2008  pixval >>= 8;
2009  *pixel_ptr = pixval & 0xff;
2010  pixel_ptr += 4;
2011  }
2012  else
2013  {
2014  *pixel_ptr++ = pixval & 0xff;
2015  pixval >>= 8;
2016  *pixel_ptr++ = pixval & 0xff;
2017  pixval >>= 8;
2018  *pixel_ptr++ = pixval & 0xff;
2019  pixval >>= 8;
2020  *pixel_ptr++ = pixval & 0xff;
2021  }
2022  if ( --mag_x == 0 )
2023  {
2024  r++;
2025  mag_x = mag_size;
2026 
2027  pixel_value = img->pixel_table[ *r ];
2028  }
2029  }
2030  }
2031  last_line = line_ptr;
2032  last_rgb = rgb_line;
2033 
2034  line_ptr += image->bytes_per_line;
2035  if ( --mag_y == 0 )
2036  {
2037  rgb_line += rgb_line_stride;
2038  mag_y = mag_size;
2039  }
2040  }
2041 }
Display * dpy
Definition: getx10.c:94
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
static void MAG_1_mono_color_8 ( )
static
static void MAG_1_mono_color_8 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 1189 of file map_scan.c.

1196 {
1197  register Pixel *pixel_table = img->pixel_table;
1198  register unsigned char * r;
1199  register unsigned char * pixel_ptr;
1200  register unsigned char table_value;
1201  register int mag_x;
1202  int mag_y = mag_size;
1203  register int w;
1204  unsigned char *line_ptr, *last_line;
1205  unsigned char *rgb_line, *last_rgb;
1206  int rgb_line_stride = img->w * img->dpy_channels;
1207 
1208  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1209 
1210  last_line = line_ptr =
1211  ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1212 
1213  while (--height >= 0) {
1214  if ( rgb_line == last_rgb && last_line != line_ptr )
1215  memcpy( line_ptr, last_line, width );
1216  else {
1217  pixel_ptr = line_ptr;
1218  w = width;
1219  r = rgb_line;
1220  mag_x = mag_size;
1221 
1222  table_value = pixel_table [ *r ];
1223  while (--w >= 0) {
1224  *pixel_ptr++ = table_value;
1225  if ( --mag_x == 0 ){
1226  r++;
1227  mag_x = mag_size;
1228  table_value = pixel_table [ *r ];
1229  }
1230  }
1231  }
1232 
1233  last_line = line_ptr;
1234  last_rgb = rgb_line;
1235 
1236  line_ptr += image->bytes_per_line;
1237  if ( --mag_y == 0 )
1238  {
1239  rgb_line += rgb_line_stride;
1240  mag_y = mag_size;
1241  }
1242  }
1243 }
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
unsigned long Pixel
Definition: getx11.h:54
static void MAG_1_nodither_notable_32 ( )
static
static void MAG_1_nodither_notable_32 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 1809 of file map_scan.c.

1817 {
1818  NDMAP_SETUP( 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;
1824  register int mag_x;
1825  register int w;
1826  register int mag_y = mag_size;
1827  unsigned char *line_ptr, *last_line;
1828  unsigned char *rgb_line, *last_rgb;
1829  int rgb_line_stride = img->w * img->dpy_channels;
1830  int byte_order = ImageByteOrder( dpy );
1831  X_CMAP_SETUP( img );
1832 
1833  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1834 
1835  last_line = line_ptr = (unsigned char *)
1836  (image->data + (y * image->bytes_per_line)) + 4 * x;
1837 
1838  while (--height >= 0) {
1839  if ( rgb_line == last_rgb && last_line != line_ptr )
1840  memcpy( line_ptr, last_line, width * sizeof( long ) );
1841  else
1842  {
1843  pixel_ptr = line_ptr;
1844  w = width;
1845  r = rgb_line;
1846  mag_x = mag_size;
1847 
1848  bw_value = NDMAP(*r);
1849  pixel_value = SHIFT_MASK_PIXEL_32(bw_value, bw_value, bw_value );
1850 
1851  while (--w >= 0) {
1852  pixval = pixel_value;
1853  if ( byte_order == MSBFirst )
1854  {
1855  pixel_ptr += 3;
1856  *pixel_ptr-- = pixval & 0xff;
1857  pixval >>= 8;
1858  *pixel_ptr-- = pixval & 0xff;
1859  pixval >>= 8;
1860  *pixel_ptr-- = pixval & 0xff;
1861  pixval >>= 8;
1862  *pixel_ptr = pixval & 0xff;
1863  pixel_ptr += 4;
1864  }
1865  else
1866  {
1867  *pixel_ptr++ = pixval & 0xff;
1868  pixval >>= 8;
1869  *pixel_ptr++ = pixval & 0xff;
1870  pixval >>= 8;
1871  *pixel_ptr++ = pixval & 0xff;
1872  pixval >>= 8;
1873  *pixel_ptr++ = pixval & 0xff;
1874  }
1875  if ( --mag_x == 0 )
1876  {
1877  r++;
1878  mag_x = mag_size;
1879 
1880  bw_value = NDMAP(*r);
1881  pixel_value =
1882  SHIFT_MASK_PIXEL_32(bw_value, bw_value, bw_value );
1883  }
1884  }
1885  }
1886  last_line = line_ptr;
1887  last_rgb = rgb_line;
1888 
1889  line_ptr += image->bytes_per_line;
1890  if ( --mag_y == 0 )
1891  {
1892  rgb_line += rgb_line_stride;
1893  mag_y = mag_size;
1894  }
1895  }
1896 }
Display * dpy
Definition: getx10.c:94
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static int x
Definition: getami.c:691
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
#define SHIFT_MASK_PIXEL_32(r, g, b)
Definition: getx11.h:70
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
static void MAG_1_nodither_table_8 ( )
static
static void MAG_1_nodither_table_8 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 1093 of file map_scan.c.

1100 {
1101  register Pixel *pixel_table = img->pixel_table;
1102  NDMAP_SETUP( img );
1103  register unsigned char * r;
1104  register unsigned char * pixel_ptr;
1105  register unsigned char table_value;
1106  register int mag_x;
1107  int mag_y = mag_size;
1108  register int w;
1109  unsigned char *line_ptr, *last_line;
1110  unsigned char *rgb_line, *last_rgb;
1111  int rgb_line_stride = img->w * img->dpy_channels;
1112 
1113  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1114 
1115  last_line = line_ptr =
1116  ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1117 
1118  while (--height >= 0) {
1119  if ( rgb_line == last_rgb && last_line != line_ptr )
1120  memcpy( line_ptr, last_line, width );
1121  else
1122  {
1123  pixel_ptr = line_ptr;
1124  w = width;
1125  r = rgb_line;
1126  mag_x = mag_size;
1127 
1128  table_value = pixel_table [ NDMAP(*r) ];
1129  while (--w >= 0) {
1130  *pixel_ptr++ = table_value;
1131  if ( --mag_x == 0 ){
1132  r++;
1133  mag_x = mag_size;
1134  table_value = pixel_table [ NDMAP(*r) ];
1135  }
1136  }
1137  }
1138 
1139  last_line = line_ptr;
1140  last_rgb = rgb_line;
1141 
1142  line_ptr += image->bytes_per_line;
1143  if ( --mag_y == 0 )
1144  {
1145  rgb_line += rgb_line_stride;
1146  mag_y = mag_size;
1147  }
1148  }
1149 }
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
unsigned long Pixel
Definition: getx11.h:54
static void MAG_2or3_dither_notable_32 ( )
static
static void MAG_2or3_dither_notable_32 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 1494 of file map_scan.c.

1501 {
1502  DMAP_SETUP( 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;
1507  register int col;
1508  register int mag_x;
1509  int mag_y = mag_size;
1510  register int w;
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;
1514  int rgb_line_stride = img->w * img->dpy_channels;
1515  int byte_order = ImageByteOrder( dpy );
1516  X_CMAP_SETUP( img );
1517 
1518  line_ptr = (unsigned char *)
1519  (image->data + (y * image->bytes_per_line)) + 4 * x;
1520 
1521  while (--height >= 0) {
1522  pixel_ptr = line_ptr;
1523  w = width;
1524  row = (row + 1) % 16;
1525  col = x_mod_16;
1526  r = rgb_line;
1527  mag_x = mag_size;
1528 
1529  g = b = r + img->w;
1530  if (img->dpy_channels >= 3) b += img->w;
1531 
1532  while (--w >= 0) {
1533  pixval = SHIFT_MASK_PIXEL(DMAP(*r, col, row),
1534  DMAP(*g, col, row),
1535  DMAP(*b, col, row));
1536  if ( byte_order == MSBFirst )
1537  {
1538  pixel_ptr += 3;
1539  *pixel_ptr-- = pixval & 0xff;
1540  pixval >>= 8;
1541  *pixel_ptr-- = pixval & 0xff;
1542  pixval >>= 8;
1543  *pixel_ptr-- = pixval & 0xff;
1544  pixval >>= 8;
1545  *pixel_ptr = pixval & 0xff;
1546  pixel_ptr += 4;
1547  }
1548  else
1549  {
1550  *pixel_ptr++ = pixval & 0xff;
1551  pixval >>= 8;
1552  *pixel_ptr++ = pixval & 0xff;
1553  pixval >>= 8;
1554  *pixel_ptr++ = pixval & 0xff;
1555  pixval >>= 8;
1556  *pixel_ptr++ = pixval & 0xff;
1557  }
1558  if ( --mag_x == 0 )
1559  {
1560  r++, g++, b++;
1561  mag_x = mag_size;
1562  }
1563  col++;
1564  col &= 15;
1565  }
1566  line_ptr += image->bytes_per_line;
1567  if ( --mag_y == 0 )
1568  {
1569  rgb_line += rgb_line_stride;
1570  mag_y = mag_size;
1571  }
1572  }
1573 }
static unsigned char g
Definition: getami.c:692
Display * dpy
Definition: getx10.c:94
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
static int x
Definition: getami.c:691
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define DMAP_SETUP(img)
Definition: map_scan.c:168
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
#define SHIFT_MASK_PIXEL(r, g, b)
Definition: getx11.h:64
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
static void MAG_2or3_dither_table_8 ( )
static
static void MAG_2or3_dither_table_8 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 579 of file map_scan.c.

587 {
588  register Pixel *pixel_table = img->pixel_table;
589  DMAP_SETUP( img );
590  LEVELS_SETUP( img );
591  register int col;
592  register unsigned char *r, *g, *b;
593  register unsigned char *pixel_ptr;
594  register int mag_x;
595  int mag_y = mag_size;
596  register int w;
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;
601  int rgb_line_stride = img->w * img->dpy_channels;
602 
603  line_ptr = ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
604 
605  while (--height >= 0) {
606  pixel_ptr = line_ptr;
607  w = width;
608  row = (row + 1) % 16;
609  col = x_mod_16;
610  mag_x = mag_size;
611 
612  r = rgb_line;
613  g = b = r + img->w;
614  if (img->dpy_channels >= 3) b += img->w;
615 
616  while (--w >= 0) {
617  *pixel_ptr++ = pixel_table [DMAP(*r, col, row) +
618  DMAP(*g, col, row) * levels +
619  DMAP(*b, col, row) * levels_squared];
620  col++;
621  col &= 15;
622  if ( --mag_x == 0 )
623  {
624  r++, g++, b++;
625  mag_x = mag_size;
626  }
627  }
628  line_ptr += image->bytes_per_line;
629  if ( --mag_y == 0 )
630  {
631  rgb_line += rgb_line_stride;
632  mag_y = mag_size;
633  }
634  }
635 }
static unsigned char g
Definition: getami.c:692
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
#define LEVELS_SETUP(img)
Definition: map_scan.c:177
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define levels
Definition: getmex.c:31
#define DMAP_SETUP(img)
Definition: map_scan.c:168
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
unsigned long Pixel
Definition: getx11.h:54
static void MAG_2or3_nodither_notable_32 ( )
static
static void MAG_2or3_nodither_notable_32 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 1652 of file map_scan.c.

1660 {
1661  NDMAP_SETUP( img );
1662  register unsigned char *r, *g, *b;
1663  register unsigned long pixval;
1664  register unsigned char *pixel_ptr;
1665  unsigned long pixel_value;
1666  register int mag_x;
1667  int mag_y = mag_size;
1668  register int w;
1669  unsigned char *line_ptr, *last_line;
1670  unsigned char *rgb_line, *last_rgb;
1671  int rgb_line_stride = img->w * img->dpy_channels;
1672  int byte_order = ImageByteOrder( dpy );
1673  X_CMAP_SETUP( img );
1674 
1675  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1676 
1677  last_line = line_ptr = (unsigned char *)
1678  (image->data + (y * image->bytes_per_line)) + 4 * x;
1679 
1680  while (--height >= 0) {
1681  if ( rgb_line == last_rgb && last_line != line_ptr )
1682  memcpy( line_ptr, last_line, width * sizeof(long) );
1683  else
1684  {
1685  pixel_ptr = line_ptr;
1686  w = width;
1687  r = rgb_line;
1688  mag_x = mag_size;
1689 
1690  g = b = r + img->w;
1691  if (img->dpy_channels >= 3) b += img->w;
1692 
1693  pixel_value = SHIFT_MASK_PIXEL_32(NDMAP(*r), NDMAP(*g), NDMAP(*b));
1694 
1695  while (--w >= 0) {
1696  pixval = pixel_value;
1697  if ( byte_order == MSBFirst )
1698  {
1699  pixel_ptr += 3;
1700  *pixel_ptr-- = pixval & 0xff;
1701  pixval >>= 8;
1702  *pixel_ptr-- = pixval & 0xff;
1703  pixval >>= 8;
1704  *pixel_ptr-- = pixval & 0xff;
1705  pixval >>= 8;
1706  *pixel_ptr = pixval & 0xff;
1707  pixel_ptr += 4;
1708  }
1709  else
1710  {
1711  *pixel_ptr++ = pixval & 0xff;
1712  pixval >>= 8;
1713  *pixel_ptr++ = pixval & 0xff;
1714  pixval >>= 8;
1715  *pixel_ptr++ = pixval & 0xff;
1716  pixval >>= 8;
1717  *pixel_ptr++ = pixval & 0xff;
1718  }
1719  if ( --mag_x == 0 )
1720  {
1721  r++, g++, b++;
1722  mag_x = mag_size;
1723  pixel_value = SHIFT_MASK_PIXEL_32(NDMAP(*r),
1724  NDMAP(*g), NDMAP(*b));
1725  }
1726  }
1727  }
1728  last_line = line_ptr;
1729  last_rgb = rgb_line;
1730 
1731  line_ptr += image->bytes_per_line;
1732  if ( --mag_y == 0 )
1733  {
1734  rgb_line += rgb_line_stride;
1735  mag_y = mag_size;
1736  }
1737  }
1738 }
static unsigned char g
Definition: getami.c:692
Display * dpy
Definition: getx10.c:94
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
static int x
Definition: getami.c:691
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
#define SHIFT_MASK_PIXEL_32(r, g, b)
Definition: getx11.h:70
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
static void MAG_2or3_nodither_table_8 ( )
static
static void MAG_2or3_nodither_table_8 ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 985 of file map_scan.c.

993 {
994  register Pixel *pixel_table = img->pixel_table;
995  NDMAP_SETUP( img );
996  LEVELS_SETUP( img );
997  register unsigned char *r, *g, *b;
998  register unsigned char *pixel_ptr;
999  register unsigned char table_value;
1000  register int mag_x;
1001  int mag_y = mag_size;
1002  register int w;
1003  unsigned char *line_ptr, *last_line;
1004  unsigned char *rgb_line, *last_rgb;
1005  int rgb_line_stride = img->w * img->dpy_channels;
1006 
1007  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1008 
1009  last_line = line_ptr =
1010  ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1011 
1012  while (--height >= 0) {
1013  if ( rgb_line == last_rgb && last_line != line_ptr )
1014  memcpy( line_ptr, last_line, width );
1015  else
1016  {
1017  pixel_ptr = line_ptr;
1018  w = width;
1019  r = rgb_line;
1020  mag_x = mag_size;
1021 
1022  g = b = r + img->w;
1023  if (img->dpy_channels >= 3) b += img->w;
1024 
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;
1030  if ( --mag_x == 0 )
1031  {
1032  r++, g++, b++;
1033  mag_x = mag_size;
1034  table_value =
1035  pixel_table [ NDMAP(*r)
1036  + NDMAP(*g) * levels
1037  + NDMAP(*b) * levels_squared];
1038  }
1039  }
1040  }
1041  last_line = line_ptr;
1042  last_rgb = rgb_line;
1043 
1044  line_ptr += image->bytes_per_line;
1045  if ( --mag_y == 0 )
1046  {
1047  rgb_line += rgb_line_stride;
1048  mag_y = mag_size;
1049  }
1050  }
1051 }
static unsigned char g
Definition: getami.c:692
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
#define LEVELS_SETUP(img)
Definition: map_scan.c:177
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define levels
Definition: getmex.c:31
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
unsigned long Pixel
Definition: getx11.h:54
static void MAG_scanline_generic ( )
static
static void MAG_scanline_generic ( image_information img,
int  rle_x,
int  rle_y,
int  mag_size,
int  x,
int  y,
int  width,
int  height,
XImage *  image 
)
static

Definition at line 290 of file map_scan.c.

298 {
299  register Pixel *pixel_table = img->pixel_table;
300  DMAP_SETUP( img );
301  LEVELS_SETUP( img );
302  register int col;
303  register unsigned char *r;
304  int save_x = x;
305  register int mag_x;
306  int mag_y = mag_size;
307  register int w;
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;
311  int rgb_line_stride = img->w * img->dpy_channels;
312  register unsigned long pixel;
313  X_CMAP_SETUP( img );
314 
315  while (--height >= 0) {
316  x = save_x;
317  w = width;
318  row = (row + 1) % 16;
319  col = x_mod_16;
320  r = rgb_line;
321  mag_x = mag_size;
322 
323  if ( img->dpy_channels == 1 ) {
324 
325  if ( img->dither_img )
326  while (--w >= 0)
327  {
328  pixel = DMAP(*r, col++, row);
329  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
330  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
331  XPutPixel (image, x, y, pixel);
332  if ( --mag_x == 0 )
333  {
334  r++;
335  mag_x = mag_size;
336  }
337  col &=15; x++;
338  }
339  else
340  if (img->mono_color)
341  while (--w >= 0)
342  {
343  pixel = pixel_table[*r];
344  XPutPixel (image, x, y, pixel);
345  if ( --mag_x == 0 )
346  {
347  r++;
348  mag_x = mag_size;
349  }
350  x++;
351  }
352  else
353  while (--w >= 0)
354  {
355  pixel = NDMAP(*r);
356  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
357  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
358  XPutPixel (image, x, y, pixel);
359  if ( --mag_x == 0 )
360  {
361  r++;
362  mag_x = mag_size;
363  }
364  x++;
365  }
366  }
367 
368  else {
369  register unsigned char *g;
370  register unsigned char *b;
371 
372  g = b = r + img->w;
373  if (img->dpy_channels >= 3) b += img->w;
374 
375  if ( img->dither_img )
376  while (--w >= 0)
377  {
378  if ( pixel_table != NULL)
379  pixel = pixel_table
380  [DMAP(*r, col, row) +
381  DMAP(*g, col, row) * levels +
382  DMAP(*b, col, row) * levels_squared];
383 
384  else pixel =
385  SHIFT_MASK_PIXEL (DMAP(*r, col, row),
386  DMAP(*g, col, row),
387  DMAP(*b, col, row));
388  XPutPixel (image, x++, y, pixel);
389  if ( --mag_x == 0 )
390  {
391  r++, g++, b++;
392  mag_x = mag_size;
393  }
394  col++;
395  col &= 15;
396  }
397  else
398  while (--w >= 0)
399  {
400  if ( pixel_table != NULL)
401  pixel = pixel_table
402  [NDMAP(*r) +
403  NDMAP(*g) * levels +
404  NDMAP(*b) * levels_squared];
405  else pixel = SHIFT_MASK_PIXEL (NDMAP(*r),
406  NDMAP(*g),
407  NDMAP(*b));
408 
409  XPutPixel (image, x++, y, pixel);
410  if ( --mag_x == 0 )
411  {
412  r++, g++, b++;
413  mag_x = mag_size;
414  }
415  }
416  }
417  if ( --mag_y == 0 )
418  {
419  rgb_line += rgb_line_stride;
420  mag_y = mag_size;
421  }
422  y++;
423  }
424 }
static unsigned char g
Definition: getami.c:692
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
int height
Definition: pgmtorle.c:51
#define LEVELS_SETUP(img)
Definition: map_scan.c:177
static int y
Definition: getami.c:691
Boolean mono_color
Definition: getx11.h:168
static unsigned char b
Definition: getami.c:692
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define levels
Definition: getmex.c:31
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define DMAP_SETUP(img)
Definition: map_scan.c:168
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
Colorindex * image
Definition: getmex.c:29
#define SHIFT_MASK_PIXEL(r, g, b)
Definition: getx11.h:64
Boolean dither_img
Definition: getx11.h:165
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
unsigned long Pixel
Definition: getx11.h:54
static void map_1_dither_notable_1 ( )
static
static void map_1_dither_notable_1 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 651 of file map_scan.c.

660 {
661  DMAP_SETUP( img );
662  register int col;
663  register int row;
664  register unsigned char *r;
665  register unsigned char *pixel_ptr;
666  register int width = given_width;
667  int bit;
668  row = y % 16;
669  col = bit = 0;
670  r = rgb[0];
671 
672  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
673 
674  if( BitmapBitOrder(dpy) == MSBFirst ) {
675  /* we don't want to trash those good bits */
676  *pixel_ptr >>= (8 - bit) & 7;
677 
678  /* do first byte fragment */
679  while ( col & 7 )
680  {
681  *pixel_ptr <<= 1;
682  if ( DMAP(*r, col++, row) )
683  *pixel_ptr |= (unsigned char) 0x1;
684  width--;
685  r += stride;
686  }
687  if ( bit )
688 
689  pixel_ptr++, col &= 15;
690 
691  while ((width -= 8) >= 0) {
692  *pixel_ptr = 0;
693  if ( DMAP(*r, col++, row) )
694  *pixel_ptr = (unsigned char) 0x80;
695  r += stride;
696  if ( DMAP(*r, col++, row) )
697  *pixel_ptr |= (unsigned char) 0x40;
698  r += stride;
699  if ( DMAP(*r, col++, row) )
700  *pixel_ptr |= (unsigned char) 0x20;
701  r += stride;
702  if ( DMAP(*r, col++, row) )
703  *pixel_ptr |= (unsigned char) 0x10;
704  r += stride;
705  if ( DMAP(*r, col++, row) )
706  *pixel_ptr |= (unsigned char) 0x8;
707  r += stride;
708  if ( DMAP(*r, col++, row) )
709  *pixel_ptr |= (unsigned char) 0x4;
710  r += stride;
711  if ( DMAP(*r, col++, row) )
712  *pixel_ptr |= (unsigned char) 0x2;
713  r += stride;
714  if ( DMAP(*r, col++, row) )
715  *pixel_ptr |= (unsigned char) 0x1;
716  r += stride;
717  col &= 15;
718  pixel_ptr++;
719  }
720 
721  /* if w is non-zero then we have to finish up... */
722  width = 8 + width;
723  if ( width )
724  {
725  unsigned char savebits;
726 
727  savebits = *pixel_ptr & LSBMask[8-width];
728  bit = width;
729 
730  while (--width >= 0) {
731  *pixel_ptr <<= 1;
732  if ( DMAP(*r, col++, row) )
733  *pixel_ptr |= (unsigned char) 0x1;
734  r += stride;
735  }
736  *pixel_ptr <<= 8 - bit;
737  *pixel_ptr |= savebits;
738  }
739  }
740  else
741  while (--width >= 0) {
742  *pixel_ptr = (unsigned char)(*pixel_ptr >> 1) | (unsigned char)
743  ((DMAP(*r, col, row)!= 0) ? 0x80: 0);
744 
745  r += stride;
746  col = ((col + 1) & 15);
747  bit = ((bit + 1) & 7);
748  if (!bit) pixel_ptr++;
749  }
750 }
Display * dpy
Definition: getx10.c:94
static unsigned char LSBMask[9]
Definition: map_scan.c:67
rle_pixel rgb[3]
Definition: wasatchrle.c:47
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
static byte bit[9]
Definition: hilbert.c:52
#define DMAP_SETUP(img)
Definition: map_scan.c:168
Colorindex * image
Definition: getmex.c:29
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
static void map_1_dither_table_8 ( )
static
static void map_1_dither_table_8 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 440 of file map_scan.c.

448 {
449  register Pixel *pixel_table = img->pixel_table;
450  DMAP_SETUP( img );
451  register int col;
452  register int row;
453  register unsigned char *r;
454  register unsigned char *pixel_ptr;
455  register int width = given_width;
456 
457  row = y % 16;
458  col = 0;
459  r = rgb[0];
460 
461  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
462 
463  while (--width >= 0) {
464  *pixel_ptr++ = pixel_table [ DMAP(*r, col, row) ];
465 
466  r += stride;
467  col = ((col + 1) & 15);
468  }
469 }
rle_pixel rgb[3]
Definition: wasatchrle.c:47
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define DMAP_SETUP(img)
Definition: map_scan.c:168
Colorindex * image
Definition: getmex.c:29
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
unsigned long Pixel
Definition: getx11.h:54
static void map_1_mono_color_32 ( )
static
static void map_1_mono_color_32 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 1911 of file map_scan.c.

1919 {
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 );
1925 
1926  r = rgb[0];
1927 
1928  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1929 
1930  while (--width >= 0) {
1931  pixval = img->pixel_table[ *r ];
1932  if ( byte_order == MSBFirst )
1933  {
1934  pixel_ptr += 3;
1935  *pixel_ptr-- = pixval & 0xff;
1936  pixval >>= 8;
1937  *pixel_ptr-- = pixval & 0xff;
1938  pixval >>= 8;
1939  *pixel_ptr-- = pixval & 0xff;
1940  pixval >>= 8;
1941  *pixel_ptr = pixval & 0xff;
1942  pixel_ptr += 4;
1943  }
1944  else
1945  {
1946  *pixel_ptr++ = pixval & 0xff;
1947  pixval >>= 8;
1948  *pixel_ptr++ = pixval & 0xff;
1949  pixval >>= 8;
1950  *pixel_ptr++ = pixval & 0xff;
1951  pixval >>= 8;
1952  *pixel_ptr++ = pixval & 0xff;
1953  }
1954  r += stride;
1955  }
1956 
1957 }
Display * dpy
Definition: getx10.c:94
rle_pixel rgb[3]
Definition: wasatchrle.c:47
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
Colorindex * image
Definition: getmex.c:29
static void map_1_mono_color_8 ( )
static
static void map_1_mono_color_8 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 1163 of file map_scan.c.

1172 {
1173  register Pixel *pixel_table = img->pixel_table;
1174  register unsigned char * r;
1175  register unsigned char * pixel_ptr;
1176  register int width = given_width;
1177 
1178  r = rgb[0];
1179 
1180  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
1181 
1182  while (--width >= 0) {
1183  *pixel_ptr++ = pixel_table [ *r ];
1184  r += stride;
1185  }
1186 
1187 }
rle_pixel rgb[3]
Definition: wasatchrle.c:47
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
Colorindex * image
Definition: getmex.c:29
unsigned long Pixel
Definition: getx11.h:54
static void map_1_nodither_notable_32 ( )
static
static void map_1_nodither_notable_32 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 1754 of file map_scan.c.

1763 {
1764  NDMAP_SETUP( img );
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 );
1770  X_CMAP_SETUP( img );
1771 
1772  r = rgb[0];
1773 
1774  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1775 
1776  while (--width >= 0) {
1777  register int bw_value = NDMAP(*r);
1778 
1779  pixval = SHIFT_MASK_PIXEL_32( bw_value, bw_value, bw_value );
1780  if ( byte_order == MSBFirst )
1781  {
1782  pixel_ptr += 3;
1783  *pixel_ptr-- = pixval & 0xff;
1784  pixval >>= 8;
1785  *pixel_ptr-- = pixval & 0xff;
1786  pixval >>= 8;
1787  *pixel_ptr-- = pixval & 0xff;
1788  pixval >>= 8;
1789  *pixel_ptr = pixval & 0xff;
1790  pixel_ptr += 4;
1791  }
1792  else
1793  {
1794  *pixel_ptr++ = pixval & 0xff;
1795  pixval >>= 8;
1796  *pixel_ptr++ = pixval & 0xff;
1797  pixval >>= 8;
1798  *pixel_ptr++ = pixval & 0xff;
1799  pixval >>= 8;
1800  *pixel_ptr++ = pixval & 0xff;
1801  }
1802 
1803  r += stride;
1804  }
1805 
1806 }
Display * dpy
Definition: getx10.c:94
rle_pixel rgb[3]
Definition: wasatchrle.c:47
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
#define SHIFT_MASK_PIXEL_32(r, g, b)
Definition: getx11.h:70
Colorindex * image
Definition: getmex.c:29
static void map_1_nodither_table_8 ( )
static
static void map_1_nodither_table_8 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 1066 of file map_scan.c.

1075 {
1076  register Pixel *pixel_table = img->pixel_table;
1077  NDMAP_SETUP( img );
1078  register unsigned char * r;
1079  register unsigned char * pixel_ptr;
1080  register int width = given_width;
1081 
1082  r = rgb[0];
1083 
1084  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
1085 
1086  while (--width >= 0) {
1087  *pixel_ptr++ = pixel_table [ NDMAP(*r) ];
1088  r += stride;
1089  }
1090 
1091 }
rle_pixel rgb[3]
Definition: wasatchrle.c:47
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
Colorindex * image
Definition: getmex.c:29
unsigned long Pixel
Definition: getx11.h:54
static void map_2or3_dither_notable_32 ( )
static
static void map_2or3_dither_notable_32 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 1429 of file map_scan.c.

1438 {
1439  DMAP_SETUP( img );
1440  register int col;
1441  register int row;
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 );
1449  X_CMAP_SETUP( img );
1450 
1451  row = y % 16;
1452  col = 0;
1453  r = rgb[0];
1454  g = rgb[1];
1455  if (ncolors >= 3) b = rgb[2];
1456  else b = rgb[1];
1457 
1458  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1459 
1460  while (--width >= 0) {
1461 
1462  pixval = SHIFT_MASK_PIXEL (DMAP(*r, col, row),
1463  DMAP(*g, col, row),
1464  DMAP(*b, col, row));
1465  if ( byte_order == MSBFirst )
1466  {
1467  pixel_ptr += 3;
1468  *pixel_ptr-- = pixval & 0xff;
1469  pixval >>= 8;
1470  *pixel_ptr-- = pixval & 0xff;
1471  pixval >>= 8;
1472  *pixel_ptr-- = pixval & 0xff;
1473  pixval >>= 8;
1474  *pixel_ptr = pixval & 0xff;
1475  pixel_ptr += 4;
1476  }
1477  else
1478  {
1479  *pixel_ptr++ = pixval & 0xff;
1480  pixval >>= 8;
1481  *pixel_ptr++ = pixval & 0xff;
1482  pixval >>= 8;
1483  *pixel_ptr++ = pixval & 0xff;
1484  pixval >>= 8;
1485  *pixel_ptr++ = pixval & 0xff;
1486  }
1487  r += stride;
1488  g += stride;
1489  b += stride;
1490  col = ((col + 1) & 15);
1491  }
1492 }
static unsigned char g
Definition: getami.c:692
Display * dpy
Definition: getx10.c:94
rle_pixel rgb[3]
Definition: wasatchrle.c:47
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define DMAP_SETUP(img)
Definition: map_scan.c:168
Colorindex * image
Definition: getmex.c:29
#define SHIFT_MASK_PIXEL(r, g, b)
Definition: getx11.h:64
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
static void map_2or3_dither_table_8 ( )
static
static void map_2or3_dither_table_8 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 540 of file map_scan.c.

549 {
550  register Pixel *pixel_table = img->pixel_table;
551  DMAP_SETUP( img );
552  LEVELS_SETUP( img );
553  register int col;
554  register int row;
555  register unsigned char *r, *g, *b;
556  register unsigned char *pixel_ptr;
557  register int width = given_width;
558 
559  row = y % 16;
560  col = 0;
561  r = rgb[0];
562  g = b = rgb[1];
563  if (ncolors >= 3) b = rgb[2];
564 
565  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
566 
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];
571  r += stride;
572  g += stride;
573  b += stride;
574  col = ((col + 1) & 15);
575  }
576 }
static unsigned char g
Definition: getami.c:692
rle_pixel rgb[3]
Definition: wasatchrle.c:47
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
#define LEVELS_SETUP(img)
Definition: map_scan.c:177
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
Pixel * pixel_table
Definition: getx11.h:179
#define levels
Definition: getmex.c:31
#define DMAP_SETUP(img)
Definition: map_scan.c:168
Colorindex * image
Definition: getmex.c:29
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
unsigned long Pixel
Definition: getx11.h:54
static void map_2or3_nodither_notable_32 ( )
static
static void map_2or3_nodither_notable_32 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 1590 of file map_scan.c.

1599 {
1600  NDMAP_SETUP( img );
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 );
1608  X_CMAP_SETUP( img );
1609 
1610  r = rgb[0];
1611  g = rgb[1];
1612  if (ncolors >= 3) b = rgb[2];
1613  else b = rgb[1];
1614 
1615  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1616 
1617  while (--width >= 0) {
1618 
1619  pixval = SHIFT_MASK_PIXEL_32(NDMAP(*r), NDMAP(*g), NDMAP(*b));
1620  if ( byte_order == MSBFirst )
1621  {
1622  pixel_ptr += 3;
1623  *pixel_ptr-- = pixval & 0xff;
1624  pixval >>= 8;
1625  *pixel_ptr-- = pixval & 0xff;
1626  pixval >>= 8;
1627  *pixel_ptr-- = pixval & 0xff;
1628  pixval >>= 8;
1629  *pixel_ptr = pixval & 0xff;
1630  pixel_ptr += 4;
1631  }
1632  else
1633  {
1634  *pixel_ptr++ = pixval & 0xff;
1635  pixval >>= 8;
1636  *pixel_ptr++ = pixval & 0xff;
1637  pixval >>= 8;
1638  *pixel_ptr++ = pixval & 0xff;
1639  pixval >>= 8;
1640  *pixel_ptr++ = pixval & 0xff;
1641  }
1642 
1643  r += stride;
1644  g += stride;
1645  b += stride;
1646 
1647  }
1648 
1649 }
static unsigned char g
Definition: getami.c:692
Display * dpy
Definition: getx10.c:94
rle_pixel rgb[3]
Definition: wasatchrle.c:47
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
#define SHIFT_MASK_PIXEL_32(r, g, b)
Definition: getx11.h:70
Colorindex * image
Definition: getmex.c:29
static void map_2or3_nodither_table_8 ( )
static
static void map_2or3_nodither_table_8 ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 951 of file map_scan.c.

960 {
961  register Pixel *pixel_table = img->pixel_table;
962  NDMAP_SETUP( img );
963  LEVELS_SETUP( img );
964  register unsigned char *r, *g, *b;
965  register unsigned char *pixel_ptr;
966  register int width = given_width;
967 
968  r = rgb[0];
969  g = b = rgb[1];
970  if (ncolors >= 3) b = rgb[2];
971 
972  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
973 
974  while (--width >= 0) {
975  *pixel_ptr++ = pixel_table [ NDMAP(*r)
976  + NDMAP(*g) * levels
977  + NDMAP(*b) * levels_squared];
978  r += stride;
979  g += stride;
980  b += stride;
981  }
982 }
static unsigned char g
Definition: getami.c:692
rle_pixel rgb[3]
Definition: wasatchrle.c:47
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
#define LEVELS_SETUP(img)
Definition: map_scan.c:177
static int y
Definition: getami.c:691
static unsigned char b
Definition: getami.c:692
Pixel * pixel_table
Definition: getx11.h:179
#define levels
Definition: getmex.c:31
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
Colorindex * image
Definition: getmex.c:29
unsigned long Pixel
Definition: getx11.h:54
void map_rgb_to_bw ( image_information img,
rle_pixel **  rows,
rle_pixel bw_row 
)

Definition at line 2060 of file map_scan.c.

2065 {
2066  register rle_pixel *red;
2067  register rle_pixel *green;
2068  register rle_pixel *blue;
2069 
2070  rle_pixel **map;
2071  int ncolors;
2072  int rowlen;
2073 
2074  map = img->in_cmap;
2075  ncolors = img->img_channels;
2076  rowlen = img->w;
2077 
2078  if (ncolors < 1) {
2079  fprintf (stderr, "%s: map_rgb_to_bw given %d colors\n",
2080  progname, ncolors);
2081  exit (1);
2082  }
2083 
2084  switch (ncolors) {
2085 
2086  case 1:
2087  red = rows[0];
2088  if ( !map || img->mono_color )
2089  duff8( rowlen, *bw_row++ = *red++)
2090  else {
2091  register rle_pixel *cmap = map[0];
2092  duff8( rowlen, *bw_row++ = cmap[*red++])
2093  }
2094  break;
2095 
2096  case 2:
2097  red = rows[0];
2098  green = rows[1];
2099  if ( !map )
2100  duff8( rowlen, *bw_row++ = ( 50 * *red++ + 50 * *green++ ) / 100)
2101  else {
2102  register rle_pixel **cmap = map;
2103  duff8( rowlen, *bw_row++ = (50 * cmap[0][*red++] +
2104  50 * cmap[1][*green++]) /100)
2105  }
2106  break;
2107 
2108  default:
2109  case 3:
2110  red = rows[0];
2111  green = rows[1];
2112  blue = rows[2];
2113  if ( !map )
2114  duff8( rowlen, *bw_row++ = ( 35 * *red++ + 55 * *green++ +
2115  10 * *blue++ ) / 100)
2116  else {
2117  register rle_pixel **cmap = map;
2118  duff8( rowlen, *bw_row++ = ( 35 * cmap[0][*red++] +
2119  55 * cmap[1][*green++] +
2120  10 * cmap[2][*blue++] ) / 100)
2121  }
2122  break;
2123  }
2124 }
static unsigned char blue[256]
Definition: rastorle.c:71
short map[3][256]
Definition: getap.c:115
Boolean mono_color
Definition: getx11.h:168
static unsigned char green[256]
Definition: rastorle.c:71
#define duff8(counter, block)
Definition: getx11.h:196
rle_pixel ** rows
Definition: rletopaint.c:57
unsigned char rle_pixel
Definition: rle.h:56
rle_pixel ** in_cmap
Definition: getx11.h:171
char progname[30]
Definition: rletorla.c:79
rle_pixel ** cmap
Definition: get4d.c:47
static unsigned char red[256]
Definition: rastorle.c:71
void map_rgb_to_rgb ( image_information img,
rle_pixel **  in_rows,
rle_pixel **  out_rows 
)

Definition at line 2139 of file map_scan.c.

2142 {
2143  register rle_pixel *in, *out, *cmap;
2144  register int w;
2145  rle_pixel **map;
2146  int ncolors;
2147  int rowlen;
2148 
2149  map = img->in_cmap;
2150  ncolors = img->img_channels;
2151  rowlen = img->w;
2152 
2153  if ( ncolors < 1 )
2154  {
2155  fprintf (stderr, "%s: map_rgb_to_rgb given %d colors\n",
2156  progname, ncolors);
2157  exit (1);
2158  }
2159 
2160  if ( map )
2161  while ( --ncolors >= 0 )
2162  {
2163  in = in_rows[0];
2164  out = out_rows[0];
2165  cmap = map[0];
2166  w = rowlen;
2167 
2168  duff8( w, *out++ = cmap[*in++] );
2169 
2170  in_rows++;
2171  out_rows++;
2172  map++;
2173  }
2174  else
2175  while ( --ncolors >= 0 )
2176  {
2177  if ( in_rows[0] != out_rows[0] )
2178  memcpy( out_rows[0], in_rows[0], rowlen );
2179 
2180  in_rows++;
2181  out_rows++;
2182  }
2183 }
rle_pixel ** in_rows
Definition: unexp.c:20
short map[3][256]
Definition: getap.c:115
#define duff8(counter, block)
Definition: getx11.h:196
rle_pixel ** out_rows
Definition: unexp.c:21
unsigned char rle_pixel
Definition: rle.h:56
rle_pixel ** in_cmap
Definition: getx11.h:171
char progname[30]
Definition: rletorla.c:79
rle_pixel ** cmap
Definition: get4d.c:47
static void map_scanline_generic ( )
static
static void map_scanline_generic ( image_information img,
rgb  ,
int  ncolors,
int  given_width,
int  stride,
int  y,
XImage *  image 
)
static

Definition at line 186 of file map_scan.c.

194 {
195  register Pixel *pixel_table = img->pixel_table;
196  DMAP_SETUP( img );
197  LEVELS_SETUP( img );
198  register int x;
199  register int col;
200  register int row;
201  register unsigned char *r;
202  register long pixel;
203  register int width = given_width;
204  X_CMAP_SETUP( img );
205 
206  row = y % 16;
207  col = 0;
208  r = rgb[0];
209 
210  if (ncolors == 1) {
211 
212  if ( img->dither_img ) {
213  for (x = 0;
214  --width >= 0;
215  r += stride, col = ((col + 1) & 15), x ++) {
216  pixel = DMAP(*r, col, row);
217  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
218  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
219  XPutPixel (image, x, y, pixel);
220  }
221  }
222 
223  else {
224  if (img->mono_color)
225  for (x = 0; --width >= 0;
226  r += stride, x ++) {
227  pixel = pixel_table[*r];
228  XPutPixel (image, x, y, pixel);
229  }
230  else
231  for (x = 0; --width >= 0;
232  r += stride, x ++) {
233  pixel = NDMAP(*r);
234  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
235  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
236  XPutPixel (image, x, y, pixel);
237  }
238  }
239 
240 
241  }
242 
243  else {
244  register unsigned char *g;
245  register unsigned char *b;
246 
247  g = b = rgb[1];
248  if (ncolors >= 3) b = rgb[2];
249 
250  if ( img->dither_img ) {
251  for (x = 0; --width >= 0;
252  r += stride, g += stride, b += stride,
253  col = ((col + 1) & 15), x ++ )
254  {
255  if (pixel_table != NULL)
256  pixel = pixel_table
257  [DMAP(*r, col, row) +
258  DMAP(*g, col, row) * levels +
259  DMAP(*b, col, row) * levels_squared];
260 
261  else pixel = SHIFT_MASK_PIXEL(DMAP(*r, col, row),
262  DMAP(*g, col, row),
263  DMAP(*b, col, row));
264 
265  XPutPixel (image, x, y, pixel);
266  }
267 
268  }
269 
270  else {
271 
272  for (x = 0; --width >= 0;
273  r += stride, g += stride, b += stride, x++ ) {
274  if ( pixel_table != NULL) {
275  pixel = pixel_table
276  [NDMAP(*r) +
277  NDMAP(*g) * levels +
278  NDMAP(*b) * levels_squared];
279  }
280  else {
281  pixel = SHIFT_MASK_PIXEL (NDMAP(*r), NDMAP(*g), NDMAP(*b));
282  }
283  XPutPixel (image, x, y, pixel);
284  }
285  }
286  }
287 }
static unsigned char g
Definition: getami.c:692
rle_pixel rgb[3]
Definition: wasatchrle.c:47
#define NDMAP(v)
Definition: map_scan.c:166
int width
Definition: pgmtorle.c:51
static unsigned char r
Definition: getami.c:692
#define LEVELS_SETUP(img)
Definition: map_scan.c:177
static int y
Definition: getami.c:691
Boolean mono_color
Definition: getx11.h:168
static unsigned char b
Definition: getami.c:692
static int x
Definition: getami.c:691
Pixel * pixel_table
Definition: getx11.h:179
#define levels
Definition: getmex.c:31
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define DMAP_SETUP(img)
Definition: map_scan.c:168
Colorindex * image
Definition: getmex.c:29
#define SHIFT_MASK_PIXEL(r, g, b)
Definition: getx11.h:64
Boolean dither_img
Definition: getx11.h:165
int row
Definition: rle.c:27
#define DMAP(v, x, y)
Definition: map_scan.c:165
unsigned long Pixel
Definition: getx11.h:54
int shift_match_left ( Pixel  mask,
int  high_bit_index 
)

Definition at line 2205 of file map_scan.c.

2210 {
2211  register int shift;
2212  register Pixel high_bit;
2213 
2214  if (mask == 0) return (0);
2215 
2216  high_bit = 0x80000000;
2217 
2218  for (shift = (32 - high_bit_index); (high_bit & mask) == 0; shift--) {
2219  high_bit >>= 1;
2220  }
2221  return (shift);
2222 }
static unsigned mask
Definition: mcut.c:162
unsigned long Pixel
Definition: getx11.h:54
int shift_match_right ( Pixel  mask)

Definition at line 2227 of file map_scan.c.

2229 {
2230  register int shift;
2231  register Pixel low_bit;
2232 
2233  if (mask == 0) return (0);
2234 
2235  low_bit = 1;
2236 
2237  for (shift = 0; (low_bit & mask) == 0; shift++) {
2238  low_bit <<= 1;
2239  }
2240  return (shift);
2241 }
static unsigned mask
Definition: mcut.c:162
unsigned long Pixel
Definition: getx11.h:54

Variable Documentation

unsigned char LSBMask[9]
static
Initial value:
= { 0x0, 0x1, 0x3, 0x7,
0xf, 0x1f, 0x3f, 0x7f, 0xff }

Definition at line 67 of file map_scan.c.