23 #define MAX(i,j) ( (i) > (j) ? (i) : (j) )
24 #define MIN(i,j) ( (i) < (j) ? (i) : (j) )
83 FILE * infile = stdin;
86 int gtflag = 0, slowflag = 0, gflag = 0, iflag = 0;
93 "% D%- f%- GS%- g%-disp_gamma!F iI%-image_gamma!F n%- \n\
94 p%-xpos!dypos!d s%-xsize!dysize!d w%- file%s",
113 gt = strncmp( vbuff+4,
"GT", 2 ) == 0 ||
114 strncmp( vbuff+4,
"PI", 2 ) == 0;
129 char *var = getenv(
"HOME" );
134 if ( var != NULL && *var !=
'\0' )
136 sprintf( buf,
"%s/.gamma", var );
137 if ( (gamfile = fopen( buf,
"r" )) != NULL )
139 fscanf( gamfile,
"%f", &flt_gam );
148 bitsavail = getgdesc(GD_BITS_NORM_SNG_GREEN);
156 get_pic( infile, infname );
165 get_pic( infile, infname )
171 unsigned char *scan[3];
181 fprintf(stderr,
"%s: Error reading setup information from %s\n",
182 hdr.cmd, infname ? infname :
"stdin");
212 for (i = 0; i < 3; i++)
213 scan[i] = (
unsigned char *) malloc(
x_size);
226 for (i = 0; i <
x_size; i++) {
227 scan[2][i] =
cmap[2][scan[0][i]];
228 scan[1][i] =
cmap[1][scan[0][i]];
229 scan[0][i] =
cmap[0][scan[0][i]];
235 for (i = 0; i <
x_size; i++) {
236 scan[2][i] =
cmap[2][scan[1][i]];
237 scan[1][i] =
cmap[1][scan[1][i]];
238 scan[0][i] =
cmap[0][scan[0][i]];
243 for (i = 0; i <
x_size; i++) {
244 scan[2][i] =
cmap[2][scan[2][i]];
245 scan[1][i] =
cmap[1][scan[1][i]];
246 scan[0][i] =
cmap[0][scan[0][i]];
261 pack_rect_scanline( scan,
x_size,
264 pack_rgb_scanline( scan,
x_size,
271 for (i = 0; i < 3; i++)
281 w_xpos =
MIN( w_xpos, XMAXSCREEN - w_xsize );
282 w_ypos =
MIN( w_ypos, YMAXSCREEN - w_ysize);
306 if ( infname ) wintitle( infname );
318 mapcolor((i+128),(i*2),(i*2),(i*2));
328 unqdevice( INPUTCHANGE );
332 qdevice( LEFTMOUSE );
333 qdevice( LEFTALTKEY );
334 qdevice( RIGHTALTKEY );
341 qenter( REDRAW, window_number );
351 long window_x_size, window_y_size, window_x_origin, window_y_origin;
352 int x_min, x_max, y_min, y_max, x_start, y_start, x_end, y_end, x_len;
353 long x_origin, y_origin, new_x_center, new_y_center;
354 int x_center, y_center, saved_x_center, saved_y_center;
357 register unsigned char *y_ptr;
360 x_center = saved_x_center =
x_size / 2;
361 y_center = saved_y_center =
y_size / 2;
366 event = qread( &data );
368 printf(
"event %d, data %d\n", event, data );
376 mapcolor((i+128),colmap[i][0],colmap[i][1],colmap[i][2]);
381 winset( window_number );
391 getorigin( &x_origin, &y_origin );
394 RGBcolor( 128, 128, 128 );
398 lrectwrite( 0, 0, x_size-1, y_size-1, rect_image );
403 RGBcolor( 128, 128, 128 );
410 getsize( &window_x_size, &window_y_size );
411 x_min = x_center - window_x_size/2;
412 x_max = x_min + (window_x_size-1);
413 y_min = y_center - window_y_size/2;
414 y_max = y_min + (window_y_size-1);
417 ortho2( x_min - .5, x_max + .5, y_min - .5, y_max + .5 );
420 x_start =
MAX( x_min, 0 );
421 y_start =
MAX( y_min, 0 );
422 x_end =
MIN( x_max, x_size-1 );
423 y_end =
MIN( y_max, y_size-1 );
424 x_len = x_end - x_start + 1;
429 y_ptr = rgb_image + y_start*x_size*3 + x_start;
431 y <= y_end && (y%16 != 0 || qtest() != REDRAW);
432 y++, y_ptr += x_size * 3 )
434 cmov2i( x_start, y );
436 y_ptr, y_ptr + x_size, y_ptr + x_size * 2 );
451 if ( getbutton(RIGHTSHIFTKEY) || getbutton(LEFTSHIFTKEY) )
453 x_center = saved_x_center;
454 y_center = saved_y_center;
455 qenter( REDRAW, window_number );
457 else if ( getbutton(CTRLKEY) )
459 saved_x_center = x_center;
460 saved_y_center = y_center;
464 x_center = x_size / 2;
465 y_center = y_size / 2;
466 qenter( REDRAW, window_number );
478 getorigin( &x_origin, &y_origin );
479 new_x_center = getvaluator( MOUSEX ) - x_origin + x_min;
480 new_y_center = getvaluator( MOUSEY ) - y_origin + y_min;
481 if ( new_x_center >= x_start &&
482 new_x_center <= x_end &&
483 new_y_center >= y_start &&
484 new_y_center <= y_end )
486 x_center = new_x_center;
487 y_center = new_y_center;
488 qenter( REDRAW, window_number );
507 pack_rect_scanline( rgb, n, line )
508 unsigned char *rgb[3];
513 register long *dest = line;
517 register unsigned char *r, *g, *b;
519 for ( i = 0, r = rgb[0], g = rgb[1], b = rgb[2];
520 i < n; i++, r++, g++, b++ )
522 *dest++ = *r + (*g<<8) + (*b<<16);
526 register unsigned char *bw;
528 for ( i = 0, bw = rgb[0]; i < n; i++, bw++ )
529 *dest++ = *bw + (*bw<<8) + (*bw<<16);
542 pack_rgb_scanline( rgb, n, lines )
543 unsigned char *rgb[3];
545 unsigned char *lines;
549 register unsigned char *src, *dest;
551 for ( chnl = 0, dest = lines; chnl < 3; chnl++ )
553 src = rgb[
bwflag ? 0 : chnl ];
554 for ( i = 0; i < n; i++ )
566 convertgreylevels(
void)
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
void rle_debug(int on_off)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
int rle_getrow(rle_hdr *the_hdr, scanline)
void rgb_to_bw(rle_pixel *red_row, rle_pixel *green_row, rle_pixel *blue_row, rle_pixel *bw_row, int rowlen)
int scanargs(int argc, char **argv, const char *format,...)
rle_pixel ** buildmap(rle_hdr *the_hdr, int minmap, double orig_gamma, double new_gamma)
unsigned long * rect_image
#define RLE_CLR_BIT(glob, bit)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
unsigned char * rgb_image