66 #include "/sys/ins/base.ins.c"
67 #include "/sys/ins/gpr.ins.c"
68 #include "/sys/ins/error.ins.c"
69 #include "/sys/ins/pad.ins.c"
71 #define RASTERSIZE 1023
72 #define COLMAP_OFFSET 16
74 #define sysdebug if ((status.all)!=0
) error_$print(status)
78 #define DMAP(v,x,y) (modN[v]>dm16[x][y] ? divN[v] + 1
: divN[v])
101 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff };
131 short namelen, tok_count;
134 set_sbrk_size( 1000000 );
139 "% b%- l%- r%- w%- n%- g%-gamma!f x%-left!d y%-top!d t%-text!s file%s",
153 fprintf( stderr,
"getap: %s is not an RLE file\n", fname );
157 fprintf( stderr,
"getap: malloc failed\n" );
161 fprintf( stderr,
"getap: input file is empty\n" );
185 if (bw_flag) gray_flag = true;
207 if (!borrow_mode) gpr_$acquire_display( status ) ;
208 gpr_$load_font_file(
"nonie.r.16", (
short) 10, font_id, status );
209 gpr_$set_text_font( font_id, status );
210 gpr_$set_text_background_value( (
int) -1, status );
211 gpr_$set_text_value( (
int) 17, status );
212 gpr_$inq_text_extent( *text, (
short) strlen(text),
214 middle = (hdr.xmax/2) - (size.x_size/2);
216 gpr_$move( middle, (
short)(hdr.ymax-15), status);
217 gpr_$text( *text, (
short) strlen(text), status);
218 if (!borrow_mode) gpr_$release_display( status ) ;
222 if (!borrow_mode) gpr_$acquire_display( status ) ;
223 gpr_$enable_input( gpr_$keystroke, keyset, status ) ;
224 obs = gpr_$event_wait ( event, key, position, status ) ;
225 if (!borrow_mode) gpr_$release_display( status ) ;
226 if ( (event == gpr_$keystroke) && ( (key ==
'd') || (key ==
'D') ) )
230 gpr_$inq_bitmap( bitmap, status ) ;
232 gpr_$allocate_attribute_block(attribs,status);
234 header[0].n_sects = 8;
235 header[0].pixel_size = 1;
236 header[0].allocated_size = 0;
237 header[0].bytes_per_line = 0;
238 header[0].bytes_per_sect = 0;
239 dump_size.x_size = 1024;
240 dump_size.y_size = 1024;
241 gpr_$open_bitmap_file(gpr_$create,
"screen_dump",(
short)11,version,
242 dump_size,(
short)1,header,attribs,dump_bitmap,created,status);
245 gpr_$set_bitmap(dump_bitmap,status);
247 gpr_$inq_color_map((
int)0,256,color_map,status);
249 gpr_$set_bitmap_file_color_map(dump_bitmap,0,256,color_map,status);
251 dump_window.window_base.x_coord = 0;
252 dump_window.window_base.y_coord = 0;
253 dump_window.window_size.x_size = 1024;
254 dump_window.window_size.y_size = 1024;
255 gpr_$set_imaging_format(gpr_$interactive, status );
257 gpr_$pixel_blt(bitmap,dump_window,dump_window.window_base,status);
259 gpr_$set_imaging_format(gpr_$imaging_512x512x24, status );
264 fprintf(stderr,
"getap: Could not open bitmap file screen_dump - ");
265 error_$print(status);
270 pad_$dm_cmd ((
short)1,
"CPO /COM/CPSCR SCREEN_DUMP -GPR", (
short)31, status ) ;
274 if ( (event == gpr_$keystroke) && ( (key ==
'p') || (key ==
'P') && (!borrow_mode) ) )
276 pad_$dm_cmd ((
short)1,
"WP", (
short)2, status ) ;
280 while ( !( (event == gpr_$keystroke) && ( (key ==
'q') || (key ==
'Q') ) ) );
283 gpr_$set_imaging_format(gpr_$interactive, status );
288 gpr_$acquire_display( status ) ;
289 gpr_$set_color_map((
int)0,8,color_map,status);
290 gpr_$release_display( status ) ;
300 gpr_$bitmap_desc_t main_bitmap;
305 gpr_$init(gpr_$borrow, 1, size, 7, main_bitmap, status );
308 gpr_$set_imaging_format( gpr_$imaging_512x512x24, status );
310 if (status.all != status_$ok)
312 fprintf(stderr,
"getap: Wrong hardware?\n");
323 gpr_$color_vector_t colmap;
332 for (i=0; i < 256; i++)
336 value = (((
hdr.cmap[i]>> 8) & 0xFF) << 16);
337 value |= (((
hdr.cmap[i+map_offset] >> 8) & 0xFF) << 8);
338 value |= ((
hdr.cmap[i+2*map_offset] >> 8) & 0xFF);
346 for (i = 0; i < 256; i++)
348 intgam = (
int)(0.5 + 255 * pow( i / 255.0, 1.0/
gam ));
350 value |= (intgam << 8);
351 value |= (intgam << 16);
357 for (i=0; i < 256; i++)
368 gpr_$set_color_map( (
int) 0, 256, colmap, status );
377 int i, j, k, l, planes, map_offset;
381 static gpr_$color_vector_t colmap;
382 gpr_$display_config_t config;
391 for (i=0; i < 256; i++)
396 map[1][i] = ((
hdr.cmap[i+map_offset] >> 8) & 0xFF);
397 map[2][i] = ((
hdr.cmap[i+2*map_offset] >> 8) & 0xFF);
404 for (i = 0; i < 256; i++)
406 intgam = (
int)(0.5 + 255 * pow( i / 255.0, 1.0/
gam ));
414 for (i=0; i < 256; i++)
423 gpr_$inq_config( config, status );
424 if ((config == gpr_$color_1024x1024x4) ||
425 (config == gpr_$color_1024x800x4) ||
426 (config == gpr_$color2_1024x800x4)) four_flag = true;
427 if ((config == gpr_$bw_800x1024) ||
428 (config == gpr_$bw_1024x800) ||
429 (config == gpr_$bw_1280x1024)) bw_flag = true;
436 for(i = 0; i < 8; i++) {
437 colmap[i] = ((i%2) * 255) << 16;
438 colmap[i] |= (((i/2)%2) * 255) << 8;
439 colmap[i] |= (((i/4)%2) * 255);
443 gpr_$acquire_display( status );
444 gpr_$inq_color_map((
int)0,8,color_map,status);
445 gpr_$set_color_map( (
int)0, 8, colmap, status );
446 gpr_$release_display( status );
452 bwdithermap( 8, gam, colmap, divN, modN, dm16);
454 for(i = 0; i < 8; i++) {
461 gpr_$acquire_display( status );
462 gpr_$inq_color_map((
int)0,8,color_map,status);
463 gpr_$set_color_map( (
int)0, 8, colmap, status );
464 gpr_$release_display( status );
473 for(i = 0; i < 216; i++) {
474 colmap[i] = ((i%6) * 51) << 16;
475 colmap[i] |= (((i/6)%6) * 51) << 8;
476 colmap[i] |= (((i/36)%6) * 51);
480 gpr_$acquire_display( status );
483 gpr_$release_display( status );
490 bwdithermap( 240, gam, colmap, divN, modN, dm16);
492 for(i = 0; i < 240; i++) {
499 gpr_$acquire_display( status );
502 gpr_$release_display( status );
506 bwdithermap( 2, gam, colmap, divN, modN, dm16);
511 setup_scr(hsize,vsize)
515 gpr_$color_vector_t colmap;
516 gpr_$attribute_desc_t hidden_desc;
519 name_$pname_t output_file;
521 pad_$window_desc_t window_shape;
522 static gpr_$bitmap_desc_t main_bitmap;
524 static stream_$id_t out_stream;
528 window_shape.top = 0;
529 window_shape.left = 0;
540 window_shape.width = (
short)hsize + w;
541 window_shape.height = (
short)vsize + h;
543 pad_$create_window(
"", (
short) 0, pad_$transcript, (
short) 1,
544 window_shape, out_stream, status );
546 if ( no_border_flag ) pad_$set_border( out_stream, (
short) 1, false, status );
548 window_shape.top = top;
549 window_shape.left = left;
550 pad_$set_full_window( out_stream, (
short) 1, window_shape, status );
552 pad_$set_auto_close( out_stream, (
short) 1, true, status );
559 gpr_$init(gpr_$direct,
567 gpr_$set_auto_refresh( true, status );
569 gpr_$set_obscured_opt( gpr_$block_if_obs, status );
571 gpr_$acquire_display( status ) ;
574 gpr_$set_bitmap(main_bitmap,status);
575 gpr_$clear( gpr_$black, status );
577 gpr_$release_display( status );
585 gpr_$window_t dest_box;
586 unsigned char *redptr, *grnptr, *bluptr;
589 dest_box.window_base.x_coord = 0;
590 dest_box.window_base.y_coord = 511 - y;
591 dest_box.window_size.x_size = 511;
592 dest_box.window_size.y_size = 1;
607 dest_pixels[i] = (gpr_$pixel_value_t) ((*redptr) << 16);
608 dest_pixels[i] |= (gpr_$pixel_value_t) ((*grnptr) << 8);
609 dest_pixels[i] |= (gpr_$pixel_value_t) (*bluptr);
610 redptr++; grnptr++; bluptr++;
612 gpr_$write_pixels( dest_pixels, dest_box, status );
623 register unsigned char *r, *g, *b;
624 register int i, col, row;
625 gpr_$window_t dest_box;
640 for ( row = y % 16, col = 0, i = 0;
641 i <= n; i++, r++, g++, b++, col = ((col + 1) & 15) )
642 dest_pixels[i] =
DMAP(map[0][*r], col, row) +
643 DMAP(map[1][*g], col, row) * 2 +
644 DMAP(map[2][*b], col, row) * 4;
646 dest_box.window_base.x_coord = hdr.xmin;
647 dest_box.window_base.y_coord = hdr.ymax - y;
648 dest_box.window_size.x_size = hdr.xmin + hdr.xmax + 1;
649 dest_box.window_size.y_size = 1;
651 gpr_$acquire_display( status ) ;
652 gpr_$write_pixels( dest_pixels, dest_box, status );
653 gpr_$release_display( status );
664 register unsigned char *r, *g, *b;
665 register int i, col, row;
666 gpr_$window_t dest_box;
681 for ( row = y % 16, col = 0, i = 0;
682 i <= n; i++, r++, g++, b++, col = ((col + 1) & 15) )
683 dest_pixels[i] =
DMAP(map[0][*r], col, row) +
684 DMAP(map[1][*g], col, row) * 6 +
687 dest_box.window_base.x_coord = hdr.xmin;
688 dest_box.window_base.y_coord = hdr.ymax - y;
689 dest_box.window_size.x_size = hdr.xmin + hdr.xmax + 1;
690 dest_box.window_size.y_size = 1;
692 gpr_$acquire_display( status ) ;
693 gpr_$write_pixels( dest_pixels, dest_box, status );
694 gpr_$release_display( status );
705 register unsigned char *r, *g, *b;
706 register int i, col, row;
707 gpr_$window_t dest_box;
710 gpr_$pixel_value_t B = 0, W = 1;
731 for ( row = y % 16, col = 0, i = 0;
732 i <= n; i++, r++, g++, b++, col = ((col + 1) & 15) )
735 pixel = (35*
map[0][*r] + 55*
map[1][*g] + 10*
map[2][*b]) / 100;
736 if (pixel < 0) pixel += 256;
737 dest_pixels[i] = ((
DMAP(pixel, col, row) > 0) ? W : B);
742 for ( row = y % 16, col = 0, i = 0;
743 i <= n; i++, r++, g++, b++, col = ((col + 1) & 15) )
746 pixel = (35*
map[0][*r] + 55*
map[1][*g] + 10*
map[2][*b]) / 100;
747 if (pixel < 0) pixel += 256;
750 pixel = ((~pixel) & 0xFF);
754 dest_pixels[i] =
DMAP(pixel, col, row);
762 dest_box.window_base.x_coord = hdr.xmin;
763 dest_box.window_base.y_coord = hdr.ymax - y;
764 dest_box.window_size.x_size = hdr.xmin + hdr.xmax + 1;
765 dest_box.window_size.y_size = 1;
767 gpr_$acquire_display( status ) ;
768 gpr_$write_pixels( dest_pixels, dest_box, status );
769 gpr_$release_display( status );
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
void make_square(double N, divN, modN, magic)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
gpr_ $bmf_group_header_array_t header
gpr_ $color_vector_t color_map
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
int rle_getrow(rle_hdr *the_hdr, scanline)
gpr_ $attribute_desc_t attribs
int scanargs(int argc, char **argv, const char *format,...)
gpr_ $window_t dump_window
gpr_ $bitmap_desc_t bitmap
gpr_ $bitmap_desc_t dump_bitmap
gpr_ $position_t position
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)