Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Macros | Functions | Variables
getap.c File Reference
#include <stdio.h>
#include <math.h>
#include "rle.h"
#include "/sys/ins/base.ins.c"
#include "/sys/ins/gpr.ins.c"
#include "/sys/ins/error.ins.c"
#include "/sys/ins/pad.ins.c"
Include dependency graph for getap.c:

Go to the source code of this file.

Macros

#define RASTERSIZE   1023
 
#define COLMAP_OFFSET   16
 
#define sysdebug   if ((status.all)!=0) error_$print(status)
 
#define DMAP(v, x, y)   (modN[v]>dm16[x][y] ? divN[v] + 1 : divN[v])
 

Functions

 main (int argc, char **argv)
 
 borrow_setup ()
 
 borrow_color_map ()
 
 window_color_map ()
 
 setup_scr (int hsize, int vsize)
 
 put_line_borrow (int y)
 
 put_line4 (int y)
 
 put_line8 (int y)
 
 put_linebw (int y)
 

Variables

rle_pixel ** rows
 
int dm16 [16][16]
 
int modN [256]
 
int divN [256]
 
float gam = 2.0
 
int inverse_flag = false
 
int gray_flag = false
 
int borrow_mode = false
 
int linear_flag = false
 
int gam_flag = true
 
int four_flag = false
 
int bw_flag = false
 
int x_flag = false
 
int y_flag = false
 
int no_border_flag = false
 
int left = 0
 
int top = 0
 
gpr_ $pixel_value_t dest_pixels [1023]
 
gpr_ $offset_t size
 
short font_id
 
short middle
 
status_ $t status
 
gpr_ $keyset_t keyset
 
char key
 
gpr_ $position_t position
 
boolean obs
 
gpr_ $event_t event
 
gpr_ $version_t version
 
gpr_ $offset_t dump_size
 
gpr_ $window_t dump_window
 
gpr_ $attribute_desc_t attribs
 
gpr_ $bitmap_desc_t bitmap
 
gpr_ $bitmap_desc_t dump_bitmap
 
boolean created
 
gpr_ $bmf_group_header_array_t header
 
gpr_ $color_vector_t color_map
 
short map [3][256]
 
rle_hdr hdr
 

Macro Definition Documentation

#define COLMAP_OFFSET   16

Definition at line 72 of file getap.c.

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

Definition at line 78 of file getap.c.

#define RASTERSIZE   1023

Definition at line 71 of file getap.c.

#define sysdebug   if ((status.all)!=0) error_$print(status)

Definition at line 74 of file getap.c.

Function Documentation

borrow_color_map ( )

Definition at line 318 of file getap.c.

References rle_hdr::cmap, rle_hdr::cmaplen, gam, gam_flag, hdr, and rle_hdr::ncmap.

319 {
320  unsigned int value;
321  unsigned int intgam;
322  int i, map_offset;
323  gpr_$color_vector_t colmap;
324 
325  if ( hdr.ncmap ) /* Must read color map */
326  {
327  map_offset = 1 << hdr.cmaplen;
328 
329  /* This needs more thought; handle ncmap = 1, etc. */
330  if (hdr.ncmap == 3)
331 
332  for (i=0; i < 256; i++)
333  {
334  /* This is bogus, we need to index cmap!... */
335 
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);
339  colmap[i] = value;
340  }
341  }
342  else
343  {
344  if (gam_flag)
345  {
346  for (i = 0; i < 256; i++)
347  {
348  intgam = (int)(0.5 + 255 * pow( i / 255.0, 1.0/gam ));
349  value = intgam;
350  value |= (intgam << 8);
351  value |= (intgam << 16);
352  colmap[i] = value;
353  }
354  }
355  else
356  { /* Default is linear map */
357  for (i=0; i < 256; i++)
358  {
359  value = (i << 16);
360  value |= (i << 8);
361  value |= i;
362  colmap[i] = value;
363  }
364  }
365  }
366 
367 
368  gpr_$set_color_map( (int) 0, 256, colmap, status );
369  sysdebug;
370 }
status_ $t status
Definition: getap.c:99
rle_map * cmap
Definition: rle.h:112
short colmap[128][3]
Definition: get4d.c:37
float gam
Definition: getap.c:81
#define sysdebug
Definition: getap.c:74
rle_hdr hdr
Definition: getap.c:118
int
Definition: getami.c:848
int ncmap
Definition: rle.h:100
int cmaplen
Definition: rle.h:100
int gam_flag
Definition: getap.c:87
int i
Definition: rletorla.c:82
const char * value
Definition: rleClock.c:574
borrow_setup ( )

Definition at line 297 of file getap.c.

298 {
299  gpr_$offset_t size;
300  gpr_$bitmap_desc_t main_bitmap; /* Master bitmap */
301 
302  size.x_size = 1024;
303  size.y_size = 1024; /* GPR will shrink to fit */
304 
305  gpr_$init(gpr_$borrow, 1, size, 7, main_bitmap, status );
306  sysdebug;
307 
308  gpr_$set_imaging_format( gpr_$imaging_512x512x24, status );
309  sysdebug;
310  if (status.all != status_$ok)
311  {
312  fprintf(stderr, "getap: Wrong hardware?\n");
313  exit(-1);
314  }
315 }
status_ $t status
Definition: getap.c:99
#define sysdebug
Definition: getap.c:74
gpr_ $offset_t size
Definition: getap.c:96
main ( int  argc,
char **  argv 
)

Definition at line 120 of file getap.c.

123 {
124  int i;
125  short len;
126  int row;
127  unsigned n;
128  char * fname = NULL;
129  char * text = NULL;
130  int text_flag = 0;
131  short namelen, tok_count;
132  char gstring[20];
133 
134  set_sbrk_size( 1000000 );
135 
136  hdr = *rle_hdr_init( (rle_hdr *)NULL );
137 
138  if (! scanargs( argc, argv,
139  "% b%- l%- r%- w%- n%- g%-gamma!f x%-left!d y%-top!d t%-text!s file%s",
142  &x_flag, &left, &y_flag, &top, &text_flag, &text, &fname ))
143  exit( 1 );
144  rle_names( &hdr, cmd_name( argv ), fname, 0 );
145  hdr.rle_file = rle_open_f(hdr.cmd, fname, "r");
146 
147  switch( (int) rle_get_setup( &hdr ) )
148  {
149  case 0:
150  break; /* successful open */
151  case -1: /* not an RLE file */
152  case -4: /* or header is short */
153  fprintf( stderr, "getap: %s is not an RLE file\n", fname );
154  exit(-4);
155  break;
156  case -2:
157  fprintf( stderr, "getap: malloc failed\n" );
158  exit(-2);
159  break;
160  case -3:
161  fprintf( stderr, "getap: input file is empty\n" );
162  exit(-3);
163  break;
164  }
165 
166 /* RLE_CLR_BIT( hdr, RLE_ALPHA ); /* No alpha channel */
167 
168  rle_row_alloc( &hdr, &rows );
169 
170  if (borrow_mode)
171  {
172  borrow_setup();
173  borrow_color_map();
174  if (hdr.ymax > 511)
175  hdr.ymax = 511;
176  }
177  else
178  {
181  if (hdr.ymax > RASTERSIZE)
182  hdr.ymax = RASTERSIZE;
183  }
184 
185  if (bw_flag) gray_flag = true;
186 
187  for (i = hdr.ymin; i <= hdr.ymax; i++)
188  {
189  rle_getrow( &hdr, rows );
190  if (borrow_mode)
191  put_line_borrow(i);
192  else
193  {
194  if (gray_flag)
195  put_linebw(i);
196  else
197  {
198  if (four_flag)
199  put_line4(i);
200  else
201  put_line8(i);
202  }
203  }
204  }
205  if (text_flag)
206  {
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),
213  size, status );
214  middle = (hdr.xmax/2) - (size.x_size/2);
215  if (middle < 0) middle=0;
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 ) ;
219  }
220  do
221  {
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') ) )
227  {
228  if (borrow_mode)
229  {
230  gpr_$inq_bitmap( bitmap, status ) ;
231  sysdebug;
232  gpr_$allocate_attribute_block(attribs,status);
233  sysdebug;
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,
243  if (status.all == 0)
244  {
245  gpr_$set_bitmap(dump_bitmap,status);
246  sysdebug;
247  gpr_$inq_color_map((int)0,256,color_map,status);
248  sysdebug;
249  gpr_$set_bitmap_file_color_map(dump_bitmap,0,256,color_map,status);
250  sysdebug;
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 );
256  sysdebug;
257  gpr_$pixel_blt(bitmap,dump_window,dump_window.window_base,status);
258  sysdebug;
259  gpr_$set_imaging_format(gpr_$imaging_512x512x24, status );
260  sysdebug;
261  }
262  else
263  {
264  fprintf(stderr, "getap: Could not open bitmap file screen_dump - ");
265  error_$print(status);
266  }
267  }
268  else
269  {
270  pad_$dm_cmd ((short)1, "CPO /COM/CPSCR SCREEN_DUMP -GPR", (short)31, status ) ;
271  sysdebug;
272  }
273  }
274  if ( (event == gpr_$keystroke) && ( (key == 'p') || (key == 'P') && (!borrow_mode) ) )
275  {
276  pad_$dm_cmd ((short)1, "WP", (short)2, status ) ;
277  sysdebug;
278  }
279  }
280  while ( !( (event == gpr_$keystroke) && ( (key == 'q') || (key == 'Q') ) ) );
281  if (borrow_mode)
282  {
283  gpr_$set_imaging_format(gpr_$interactive, status );
284  sysdebug;
285  }
286  if (!borrow_mode && four_flag)
287  {
288  gpr_$acquire_display( status ) ;
289  gpr_$set_color_map((int)0,8,color_map,status);
290  gpr_$release_display( status ) ;
291  }
292 }
gpr_ $version_t version
Definition: getap.c:106
status_ $t status
Definition: getap.c:99
boolean obs
Definition: getap.c:104
window_color_map()
Definition: getap.c:375
gpr_ $offset_t dump_size
Definition: getap.c:107
char key
Definition: getap.c:102
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
Definition: rle_row_alc.c:56
put_line8(int y)
Definition: getap.c:661
int linear_flag
Definition: getap.c:86
gpr_ $bmf_group_header_array_t header
Definition: getap.c:113
int gray_flag
Definition: getap.c:83
gpr_ $color_vector_t color_map
Definition: getap.c:114
int borrow_mode
Definition: getap.c:84
int x_flag
Definition: getap.c:90
boolean created
Definition: getap.c:112
int y_flag
Definition: getap.c:91
gpr_ $attribute_desc_t attribs
Definition: getap.c:109
char * fname[3]
Definition: show3.c:31
int ymin
Definition: rle.h:100
rle_pixel ** rows
Definition: getap.c:77
int four_flag
Definition: getap.c:88
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
const char * cmd
Definition: rle.h:133
float gam
Definition: getap.c:81
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
Definition: rle.h:96
int xmax
Definition: rle.h:100
gpr_ $event_t event
Definition: getap.c:105
#define sysdebug
Definition: getap.c:74
borrow_color_map()
Definition: getap.c:318
int top
Definition: getap.c:94
short middle
Definition: getap.c:98
gpr_ $window_t dump_window
Definition: getap.c:108
put_linebw(int y)
Definition: getap.c:702
int left
Definition: getap.c:93
setup_scr(int hsize, int vsize)
Definition: getap.c:511
int no_border_flag
Definition: getap.c:92
put_line_borrow(int y)
Definition: getap.c:581
rle_hdr hdr
Definition: getap.c:118
short font_id
Definition: getap.c:97
int inverse_flag
Definition: getap.c:82
int ymax
Definition: rle.h:100
put_line4(int y)
Definition: getap.c:620
gpr_ $bitmap_desc_t bitmap
Definition: getap.c:110
gpr_ $bitmap_desc_t dump_bitmap
Definition: getap.c:111
gpr_ $keyset_t keyset
Definition: getap.c:100
int gam_flag
Definition: getap.c:87
int i
Definition: rletorla.c:82
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
gpr_ $offset_t size
Definition: getap.c:96
gpr_ $position_t position
Definition: getap.c:103
borrow_setup()
Definition: getap.c:297
char * cmd_name(char **argv)
Definition: cmd_name.c:31
int row
Definition: rle.c:27
int bw_flag
Definition: getap.c:89
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
FILE * rle_file
Definition: rle.h:114
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267
#define RASTERSIZE
Definition: getap.c:71
put_line4 ( int  y)

Definition at line 620 of file getap.c.

622 {
623  register unsigned char *r, *g, *b;
624  register int i, col, row;
625  gpr_$window_t dest_box;
626  int n = hdr.xmax;
627 
628  r = rows[RLE_RED];
629  if (hdr.ncolors == 3)
630  {
631  g = rows[RLE_GREEN];
632  b = rows[RLE_BLUE];
633  }
634  else
635  {
636  g = rows[0];
637  b = rows[0];
638  }
639 
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;
645 
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;
650 
651  gpr_$acquire_display( status ) ;
652  gpr_$write_pixels( dest_pixels, dest_box, status );
653  gpr_$release_display( status );
654 
655 }
status_ $t status
Definition: getap.c:99
static unsigned char g
Definition: getami.c:692
int xmin
Definition: rle.h:100
static unsigned char r
Definition: getami.c:692
short map[3][256]
Definition: getap.c:115
#define RLE_GREEN
Definition: rle.h:63
#define RLE_BLUE
Definition: rle.h:64
static int y
Definition: getami.c:691
rle_pixel ** rows
Definition: getap.c:77
static unsigned char b
Definition: getami.c:692
#define RLE_RED
Definition: rle.h:62
int xmax
Definition: rle.h:100
#define DMAP(v, x, y)
Definition: getap.c:78
rle_hdr hdr
Definition: getap.c:118
int ymax
Definition: rle.h:100
gpr_ $pixel_value_t dest_pixels[1023]
Definition: getap.c:95
int i
Definition: rletorla.c:82
int row
Definition: rle.c:27
int ncolors
Definition: rle.h:100
put_line8 ( int  y)

Definition at line 661 of file getap.c.

663 {
664  register unsigned char *r, *g, *b;
665  register int i, col, row;
666  gpr_$window_t dest_box;
667  int n = hdr.xmax;
668 
669  r = rows[RLE_RED];
670  if (hdr.ncolors == 3)
671  {
672  g = rows[RLE_GREEN];
673  b = rows[RLE_BLUE];
674  }
675  else
676  {
677  g = rows[0];
678  b = rows[0];
679  }
680 
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 +
685  DMAP(map[2][*b], col, row) * 36 + COLMAP_OFFSET;
686 
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;
691 
692  gpr_$acquire_display( status ) ;
693  gpr_$write_pixels( dest_pixels, dest_box, status );
694  gpr_$release_display( status );
695 
696 }
status_ $t status
Definition: getap.c:99
static unsigned char g
Definition: getami.c:692
int xmin
Definition: rle.h:100
static unsigned char r
Definition: getami.c:692
short map[3][256]
Definition: getap.c:115
#define RLE_GREEN
Definition: rle.h:63
#define RLE_BLUE
Definition: rle.h:64
static int y
Definition: getami.c:691
rle_pixel ** rows
Definition: getap.c:77
static unsigned char b
Definition: getami.c:692
#define RLE_RED
Definition: rle.h:62
int xmax
Definition: rle.h:100
#define DMAP(v, x, y)
Definition: getap.c:78
rle_hdr hdr
Definition: getap.c:118
int ymax
Definition: rle.h:100
gpr_ $pixel_value_t dest_pixels[1023]
Definition: getap.c:95
int i
Definition: rletorla.c:82
#define COLMAP_OFFSET
Definition: getap.c:72
int row
Definition: rle.c:27
int ncolors
Definition: rle.h:100
put_line_borrow ( int  y)

Definition at line 581 of file getap.c.

583 {
584  int i;
585  gpr_$window_t dest_box;
586  unsigned char *redptr, *grnptr, *bluptr;
587 
588 
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;
593 
594  redptr = rows[RLE_RED];
595  if (hdr.ncolors == 3)
596  {
597  grnptr = rows[RLE_GREEN];
598  bluptr = rows[RLE_BLUE];
599  }
600  else /* If only one channel, get all from same one */
601  {
602  grnptr = rows[0];
603  bluptr = rows[0];
604  }
605  for (i = hdr.xmin; i <= hdr.xmax; i++)
606  {
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++;
611  }
612  gpr_$write_pixels( dest_pixels, dest_box, status );
613  sysdebug;
614 }
status_ $t status
Definition: getap.c:99
int xmin
Definition: rle.h:100
#define RLE_GREEN
Definition: rle.h:63
#define RLE_BLUE
Definition: rle.h:64
static int y
Definition: getami.c:691
rle_pixel ** rows
Definition: getap.c:77
#define RLE_RED
Definition: rle.h:62
int xmax
Definition: rle.h:100
#define sysdebug
Definition: getap.c:74
rle_hdr hdr
Definition: getap.c:118
gpr_ $pixel_value_t dest_pixels[1023]
Definition: getap.c:95
int i
Definition: rletorla.c:82
int ncolors
Definition: rle.h:100
put_linebw ( int  y)

Definition at line 702 of file getap.c.

704 {
705  register unsigned char *r, *g, *b;
706  register int i, col, row;
707  gpr_$window_t dest_box;
708  int pixel;
709  int n = hdr.xmax;
710  gpr_$pixel_value_t B = 0, W = 1;
711 
712  r = rows[RLE_RED];
713  if (hdr.ncolors == 3)
714  {
715  g = rows[RLE_GREEN];
716  b = rows[RLE_BLUE];
717  }
718  else
719  {
720  g = rows[0];
721  b = rows[0];
722  }
723 
724  if (bw_flag)
725  {
726  if (inverse_flag)
727  {
728  B = 1; W = 0; /* Swap meaning of Black and White */
729  }
730 
731  for ( row = y % 16, col = 0, i = 0;
732  i <= n; i++, r++, g++, b++, col = ((col + 1) & 15) )
733  {
734  /* Convert to BW (uses YIQ/percentage xformation) */
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);
738  }
739  }
740  else
741  {
742  for ( row = y % 16, col = 0, i = 0;
743  i <= n; i++, r++, g++, b++, col = ((col + 1) & 15) )
744  {
745  /* Convert to BW (uses YIQ/percentage xformation) */
746  pixel = (35*map[0][*r] + 55*map[1][*g] + 10*map[2][*b]) / 100;
747  if (pixel < 0) pixel += 256;
748  if (inverse_flag)
749  {
750  pixel = ((~pixel) & 0xFF); /* Swap meaning of Black and White */
751  }
752  if (four_flag)
753  {
754  dest_pixels[i] = DMAP(pixel, col, row);
755  }
756  else
757  {
758  dest_pixels[i] = DMAP(pixel, col, row) + COLMAP_OFFSET;
759  }
760  }
761  }
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;
766 
767  gpr_$acquire_display( status ) ;
768  gpr_$write_pixels( dest_pixels, dest_box, status );
769  gpr_$release_display( status );
770 
771 }
status_ $t status
Definition: getap.c:99
static unsigned char g
Definition: getami.c:692
int xmin
Definition: rle.h:100
static unsigned char r
Definition: getami.c:692
short map[3][256]
Definition: getap.c:115
#define RLE_GREEN
Definition: rle.h:63
#define RLE_BLUE
Definition: rle.h:64
static int y
Definition: getami.c:691
rle_pixel ** rows
Definition: getap.c:77
static unsigned char b
Definition: getami.c:692
static unsigned int B[32]
Definition: getami.c:98
int four_flag
Definition: getap.c:88
#define RLE_RED
Definition: rle.h:62
int xmax
Definition: rle.h:100
#define DMAP(v, x, y)
Definition: getap.c:78
rle_hdr hdr
Definition: getap.c:118
int inverse_flag
Definition: getap.c:82
int ymax
Definition: rle.h:100
gpr_ $pixel_value_t dest_pixels[1023]
Definition: getap.c:95
int i
Definition: rletorla.c:82
#define COLMAP_OFFSET
Definition: getap.c:72
int row
Definition: rle.c:27
int bw_flag
Definition: getap.c:89
int ncolors
Definition: rle.h:100
setup_scr ( int  hsize,
int  vsize 
)

Definition at line 511 of file getap.c.

513 {
514  gpr_$offset_t size;
515  gpr_$color_vector_t colmap;
516  gpr_$attribute_desc_t hidden_desc;
517  unsigned int value;
518  int i;
519  name_$pname_t output_file;
520  short len, w, h;
521  pad_$window_desc_t window_shape;
522  static gpr_$bitmap_desc_t main_bitmap;
523  short fontid;
524  static stream_$id_t out_stream;
525 
526  /* Open a separate window to display the results */
527 
528  window_shape.top = 0;
529  window_shape.left = 0;
530  if ( !no_border_flag )
531  {
532  w = 11;
533  h = 34;
534  }
535  else
536  {
537  w = 1;
538  h = 1;
539  }
540  window_shape.width = (short)hsize + w;
541  window_shape.height = (short)vsize + h;
542 
543  pad_$create_window( "", (short) 0, pad_$transcript, (short) 1,
544  window_shape, out_stream, status );
545 
546  if ( no_border_flag ) pad_$set_border( out_stream, (short) 1, false, status );
547 
548  window_shape.top = top;
549  window_shape.left = left;
550  pad_$set_full_window( out_stream, (short) 1, window_shape, status );
551 
552  pad_$set_auto_close( out_stream, (short) 1, true, status );
553 
554  size.x_size = 1024; /* GPR will shrink to fit */
555  size.y_size = 1024;
556 
557  /* Initialize the graphics primitives package */
558 
559  gpr_$init(gpr_$direct,
560  out_stream, /* "unit" */
561  size, /* size of the initial bitmap */
562  7, /* identifier of the heightest
563  numbered bitmap plane */
564  main_bitmap, /* resulting bitmap descriptor */
565  status);
566 
567  gpr_$set_auto_refresh( true, status ); /* all yours, DM. */
568 
569  gpr_$set_obscured_opt( gpr_$block_if_obs, status );
570 
571  gpr_$acquire_display( status ) ;
572 
573  /* set the new bitmap descriptor to be the 'current bitmap' */
574  gpr_$set_bitmap(main_bitmap,status);
575  gpr_$clear( gpr_$black, status );
576 
577  gpr_$release_display( status );
578 }
status_ $t status
Definition: getap.c:99
short colmap[128][3]
Definition: get4d.c:37
int top
Definition: getap.c:94
int left
Definition: getap.c:93
int no_border_flag
Definition: getap.c:92
int i
Definition: rletorla.c:82
gpr_ $offset_t size
Definition: getap.c:96
const char * value
Definition: rleClock.c:574
window_color_map ( )

Definition at line 375 of file getap.c.

References bw_flag, rle_hdr::cmap, rle_hdr::cmaplen, divN, dm16, four_flag, gam, gam_flag, gray_flag, hdr, make_square(), map, modN, and rle_hdr::ncmap.

376 {
377  int i, j, k, l, planes, map_offset;
378  unsigned int value;
379  unsigned int intgam;
380  status_$t status;
381  static gpr_$color_vector_t colmap;
382  gpr_$display_config_t config;
383 
384  if ( hdr.ncmap ) /* Must read color map */
385  {
386  map_offset = 1 << hdr.cmaplen;
387 
388  /* This needs more thought; handle ncmap = 1, etc. */
389  if (hdr.ncmap == 3)
390 
391  for (i=0; i < 256; i++)
392  {
393  /* This is bogus, we need to index cmap!... */
394 
395  map[0][i] = ((hdr.cmap[i]>> 8) & 0xFF);
396  map[1][i] = ((hdr.cmap[i+map_offset] >> 8) & 0xFF);
397  map[2][i] = ((hdr.cmap[i+2*map_offset] >> 8) & 0xFF);
398  }
399  }
400  else
401  {
402  if (gam_flag)
403  {
404  for (i = 0; i < 256; i++)
405  {
406  intgam = (int)(0.5 + 255 * pow( i / 255.0, 1.0/gam ));
407  map[0][i] = intgam;
408  map[1][i] = intgam;
409  map[2][i] = intgam;
410  }
411  }
412  else
413  { /* Default is linear map */
414  for (i=0; i < 256; i++)
415  {
416  map[0][i] = i;
417  map[1][i] = i;
418  map[2][i] = i;
419  }
420  }
421  }
422 
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;
430 
431  if (four_flag && !bw_flag && !gray_flag)
432  {
433  /*
434  * Set up the 4-bit color map entries.
435  */
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);
440  }
441 
442  /* Save DM window colors */
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 );
447 
448  make_square( 2.0, divN, modN, dm16 );
449  }
450  else if (four_flag && !bw_flag && gray_flag)
451  {
452  bwdithermap( 8, gam, colmap, divN, modN, dm16);
453 
454  for(i = 0; i < 8; i++) {
455  j = colmap[i];
456  colmap[i] = j << 16;
457  colmap[i] |= j << 8;
458  colmap[i] |= j;
459  }
460  /* Save DM window colors */
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 );
465 
466  }
467  else if (!bw_flag && !gray_flag)
468  {
469  /*
470  * Set up the 8 bit color map entries. We don't yet know the location
471  * in the map at which each will reside, so init it to 0.
472  */
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);
477  }
478 
479  /* Offset from DM window colors */
480  gpr_$acquire_display( status );
481  gpr_$set_color_map( (int) COLMAP_OFFSET, 256 - COLMAP_OFFSET,
482  colmap, status );
483  gpr_$release_display( status );
484 
485  /* Compute tables */
486  make_square( 6.0, divN, modN, dm16 );
487  }
488  else if (!bw_flag)
489  {
490  bwdithermap( 240, gam, colmap, divN, modN, dm16);
491 
492  for(i = 0; i < 240; i++) {
493  j = colmap[i];
494  colmap[i] = j << 16;
495  colmap[i] |= j << 8;
496  colmap[i] |= j;
497  }
498  /* Offset from DM window colors */
499  gpr_$acquire_display( status );
500  gpr_$set_color_map( (int) COLMAP_OFFSET, 256 - COLMAP_OFFSET,
501  colmap, status );
502  gpr_$release_display( status );
503  }
504  else
505  {
506  bwdithermap( 2, gam, colmap, divN, modN, dm16);
507  }
508 }
status_ $t status
Definition: getap.c:99
int divN[256]
Definition: getap.c:80
void bwdithermap(int levels, double gamma, int bwmap[], int divN[256], int modN[256], int magic[16][16])
int modN[256]
Definition: getap.c:80
int gray_flag
Definition: getap.c:83
gpr_ $color_vector_t color_map
Definition: getap.c:114
rle_map * cmap
Definition: rle.h:112
short map[3][256]
Definition: getap.c:115
void make_square(double N, int divN[256], int modN[256], int magic[16][16])
short colmap[128][3]
Definition: get4d.c:37
int dm16[16][16]
Definition: getap.c:79
int four_flag
Definition: getap.c:88
float gam
Definition: getap.c:81
rle_hdr hdr
Definition: getap.c:118
int
Definition: getami.c:848
int ncmap
Definition: rle.h:100
int cmaplen
Definition: rle.h:100
int gam_flag
Definition: getap.c:87
int i
Definition: rletorla.c:82
#define COLMAP_OFFSET
Definition: getap.c:72
const char * value
Definition: rleClock.c:574
int bw_flag
Definition: getap.c:89

Here is the call graph for this function:

Variable Documentation

gpr_ $attribute_desc_t attribs

Definition at line 109 of file getap.c.

gpr_ $bitmap_desc_t bitmap

Definition at line 110 of file getap.c.

int borrow_mode = false

Definition at line 84 of file getap.c.

int bw_flag = false

Definition at line 89 of file getap.c.

Referenced by window_color_map().

gpr_ $color_vector_t color_map

Definition at line 114 of file getap.c.

boolean created

Definition at line 112 of file getap.c.

gpr_ $pixel_value_t dest_pixels[1023]

Definition at line 95 of file getap.c.

int divN[256]

Definition at line 80 of file getap.c.

int dm16[16][16]

Definition at line 79 of file getap.c.

gpr_ $bitmap_desc_t dump_bitmap

Definition at line 111 of file getap.c.

gpr_ $offset_t dump_size

Definition at line 107 of file getap.c.

gpr_ $window_t dump_window

Definition at line 108 of file getap.c.

gpr_ $event_t event

Definition at line 105 of file getap.c.

short font_id

Definition at line 97 of file getap.c.

int four_flag = false

Definition at line 88 of file getap.c.

Referenced by window_color_map().

float gam = 2.0

Definition at line 81 of file getap.c.

int gam_flag = true

Definition at line 87 of file getap.c.

Referenced by borrow_color_map(), and window_color_map().

int gray_flag = false

Definition at line 83 of file getap.c.

Referenced by window_color_map().

rle_hdr hdr

Definition at line 118 of file getap.c.

gpr_ $bmf_group_header_array_t header

Definition at line 113 of file getap.c.

int inverse_flag = false

Definition at line 82 of file getap.c.

char key

Definition at line 102 of file getap.c.

gpr_ $keyset_t keyset
Initial value:
= { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }

Definition at line 100 of file getap.c.

int left = 0

Definition at line 93 of file getap.c.

int linear_flag = false

Definition at line 86 of file getap.c.

short map[3][256]

Definition at line 115 of file getap.c.

short middle

Definition at line 98 of file getap.c.

int modN[256]

Definition at line 80 of file getap.c.

int no_border_flag = false

Definition at line 92 of file getap.c.

boolean obs

Definition at line 104 of file getap.c.

gpr_ $position_t position

Definition at line 103 of file getap.c.

rle_pixel** rows

Definition at line 77 of file getap.c.

gpr_ $offset_t size

Definition at line 96 of file getap.c.

status_ $t status

Definition at line 99 of file getap.c.

int top = 0

Definition at line 94 of file getap.c.

gpr_ $version_t version

Definition at line 106 of file getap.c.

int x_flag = false

Definition at line 90 of file getap.c.

int y_flag = false

Definition at line 91 of file getap.c.