16 #include <graphics/grafix.h>
17 #include <graphics/window.h>
18 #include <graphics/control.h>
19 #include <graphics/events.h>
20 #include <sys/ioctl.h>
21 #include <machine/graphics.h>
24 #define RASTERSIZE_LIM 1280
25 #define MONOCHROME_MODE 1
26 #define EIGHT_BIT_COLOUR_MODE 2
27 #define MONOCHROME_ENTRIES 128
120 char *infname = NULL, *window_name;
124 hdr = *rle_hdr_init( (rle_hdr *)NULL );
127 if (scanargs(argc, argv, "getOrion D%- w%- f%- g%-gamma!f l%- r%- infile
129 &debug_flag, &bw_flag, &all_colours_flag,
130 &gamma_flag, &gam, &linear_flag, &reverse_flag, &infname) == 0)
140 fprintf(stderr,
"getOrion: error reading setup information from %s\n",
141 infname ? infname :
"stdin");
142 fprintf(stderr,
"with return code %d\n", temp);
160 for (i = 0; i < 3; i++)
175 init_monochrome_colour_map();
179 init_24_bit_colour_map();
180 onec_threem_mode = TRUE;
184 init_8_bit_colour_map();
190 SetRect (&r, 50, 50, window_size_x, window_size_y);
192 window_name =
"piped";
194 window_name = infname;
196 rle_window = NewWindow(NIL, r, window_name, VISIBLE, noGrowDocProc, FRONT,
199 UpdateWindow(rle_window, TRUE);
203 scanbitmap = NewRBitMap(window_size_x, 1, 8);
232 for (i = 0; i < 256; i++) {
233 gammamap[i] = (
int) (0.5 + 255 * pow(i / 255.0, 1.0/
gam));
244 init_8_bit_colour_map()
264 init_monochrome_colour_map()
289 init_24_bit_colour_map()
291 int i, g_offset, b_offset;
297 b_offset = 2 * g_offset;
310 #define DMAP(v, x, y) (errN[v]>dm16[x][y] ? divN[v]+1
: divN[v])
321 unsigned char *r, *g, *b;
322 int i, dither_col, dither_row;
324 int g_offset, b_offset;
325 unsigned char *dest_pixel_ptr;
330 write_scanline(yscan);
334 dither_row = yscan % 16;
346 b_offset = 2 * g_offset;
348 for (i = 0; i <= xmax; i++, r++, g++, b++,
349 dither_col = ((dither_col + 1) & 15),
360 for (i = 0; i <= xmax; i++, r++, g++, b++,
361 dither_col = ((dither_col + 1) & 15),
364 DMAP(*r, dither_col, dither_row) +
365 DMAP(*g, dither_col, dither_row) * 6 +
366 DMAP(*b, dither_col, dither_row) * 36;
370 write_scanline(yscan);
383 unsigned char *r, *g, *b;
384 int i, dither_col, dither_row;
385 unsigned char *dest_pixel_ptr;
388 int g_offset, b_offset;
390 dither_row = yscan % 16;
403 b_offset = 2 * g_offset;
405 for (i = 0; i <= xmax; i++, r++, g++, b++,
406 dither_col = ((dither_col + 1) & 15),
411 10 *
hdr.cmap[*b + b_offset]) / 100;
412 *dest_pixel_ptr =
DMAP(bw_val, dither_col, dither_row);
418 for (i = 0; i <= xmax; i++, r++, g++, b++,
419 dither_col = ((dither_col + 1) & 15),
422 (35*(*r) + 55*(*g) + 10*(*b)) / 100;
424 DMAP(bw_val, dither_col, dither_row);
428 write_scanline(yscan);
433 #define WriteCLT(cltp) (ioctl (_gdev, GTIOCSCLT, &(cltp)))
434 #define ReadCLT(cltp) (ioctl (_gdev, GTIOCGCLT, &(cltp)))
459 for (i = 0; i < terminate; i++)
475 write_scanline(yscan)
487 SetRect(&trandr, 0, yscan, window_size_x, 1);
491 translate_bits(&((*rle_window).port.portBits), trandr);
494 AddUpdate(rle_window, trandr, 255);
495 UpdateWindow(rle_window, TRUE);
511 translate_bits(db, dr)
515 Ptr sa = scanbitmap.baseAddr;
516 unsigned sw = scanbitmap.rowBits;
517 Ptr da = db->baseAddr;
519 unsigned dw = db->rowBits;
520 unsigned dh = db->colBits;
521 unsigned dps = db->planeSize;
522 int cw = width (db->bounds);
523 int ch = height (db->bounds);
524 unsigned w = window_size_x;
526 unsigned char *srcad;
528 int bitpos, bytes_in_source;
532 scanad = scanbitmap.baseAddr;
535 bytes_in_source = window_size_x;
537 while(bytes_in_source){
539 dest = dest | (((*srcad++ >> plane) & 0x01) << bitpos);
540 if (bitpos++ == 31) {
549 rasterop(sa, sw, 1, 0, 0,
550 da, dw, dh, 1, 23, cw, ch,
551 0, dy, w, 1, srcCopy);
570 GetNextEvent (everyEvent, &myEvent);
571 switch (myEvent.what)
574 whichWindow = (WindowPtr) myEvent.refCon;
575 switch (FindWindow (myEvent.where, whichWindow))
578 if (TrackGoAway (whichWindow, myEvent.where))
585 DragWindow (whichWindow, myEvent.where, stdBoundsRect);
589 if (whichWindow != FrontWindow ())
591 BringToFront (whichWindow);
595 myPt = myEvent.where;
596 GlobalToLocal (&myPt);
622 theWindow = (WindowPtr) myEvent.message;
623 theState = (myEvent.modifiers & activateFlag) != 0;
628 HiliteWindow (theWindow, TRUE);
635 HiliteWindow (theWindow, FALSE);
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
#define EIGHT_BIT_COLOUR_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)
starbase_color_index_type dest_pixels[1023]
int rle_getrow(rle_hdr *the_hdr, scanline)
void dithermap(int levels, double gamma, rgbmap, divN, modN, magic)
unsigned char scanline[4][1023]
#define RLE_CLR_BIT(glob, bit)
#define MONOCHROME_ENTRIES
void bwdithermap(int levels, double gamma, bwmap, divN, modN, magic)