24 #include <cx3d_types.h>
25 #include <cx3d_solid.h>
32 #define DIRECTCOLG( r, g, b, gv ) (DIRECTCOL( gamma( r, gv ),
43 cx_go( pc, DISP_BM1, IMAGE_VIS, NO, NO );
49 static void run ( r, g, b, start, stop, y, magnification, originx, originy,
52 int start, stop, y, magnification, originx, originy;
67 else cx_clr_dc(
DIRECTCOLG( r, g, b, gamma_value ),
68 originx+start, originx+stop,
69 originy+y, originy+y );
72 static void scanline ( scan, y, magnification, originx, originy, gamma_value )
74 int y, magnification, originx, originy;
80 DLMADDR pc = cx_getpc( );
85 register rle_pixel _r = *r, _g = *g, _b = *b;
89 while (*r == _r && *g == _g && *b == _b) {
94 run( _r, _g, _b, start, r - scan[0] - 1, y, magnification,
95 originx, originy, gamma_value );
98 if (runcount++ > 128) {
108 run( *r, *g, *b, start, start, y, magnification, originx, originy,
116 static void background ( magnification, originx, originy, gamma_value )
117 int magnification, originx, originy;
121 DLMADDR pc = cx_getpc( );
130 default: fprintf( stderr,
"getcx3d: internal error 1\n" );
133 cx_clr_dc(
DIRECTCOLG( r, g, b, gamma_value ),
138 else cx_clr_dc(
DIRECTCOLG( r, g, b, gamma_value ),
147 static void colormap ( ) {
149 DLMADDR pc = cx_getpc( );
152 #ifndef CX3D_COLORMAP
153 fprintf( stderr,
"getcx3d: (3) colormap not loaded\n" );
156 for (i = 0 ; i < (1 << hdr.cmaplen) ; i++) {
157 cx_s_disp_clu( DISP_BM1,
158 DIRECTCOL( i, i, i ),
159 (hdr.cmap[i]>>8)/255.0,
160 (hdr.cmap[i+(1<<hdr.cmaplen)]>>8)/255.0,
161 (hdr.cmap[i+(2<<hdr.cmaplen)]>>8)/255.0 );
166 #ifndef CX3D_COLORMAP
167 fprintf( stderr,
"getcx3d: (1) colormap not loaded\n" );
170 for (i = 0 ; i < (1 << hdr.cmaplen) ; i++) {
171 cx_s_disp_clu( DISP_BM1, DIRECTCOL( i, i, i ),
172 (hdr.cmap[i]>>8)/255.0,
173 (hdr.cmap[i]>>8)/255.0,
174 (hdr.cmap[i]>>8)/255.0 );
181 static void clear_scan ( scan )
205 getcx3d ( f, force_background, magnification, originx, originy, gamma_value )
207 int force_background, magnification, originx, originy;
223 "getcx3d: error reading setup information from %s\n",
227 if (force_background != -1)
234 for (i = 0 ; i < 3 ; i++)
238 background( magnification, originx, originy, gamma_value );
249 bcopy( (
char *) scan[0], (
char *) scan[i],
253 scanline( scan, y, magnification,
254 originx, originy, gamma_value );
259 for (i = 0 ; i < 3 ; i++) free( (
char *) scan[i] );
262 static void usage ( ) {
264 "usage: getcx3d [-O] [-B] [-d] [-t] [-p x y] [-l] file ...\n" );
265 fprintf( stderr,
"getcx3d: list as many files as you wish\n" );
266 fprintf( stderr,
"getcx3d: use - for stdin\n" );
267 fprintf( stderr,
"getcx3d: see the man page for details\n" );
282 int force_background = -1;
284 int magnification = 1;
285 int originx = 0, originy = 0;
286 float gamma_value =
GAMMA;
298 if (!cx_open(
"/dev/dr0" )) {
299 fprintf( stderr,
"getcx3d: wait your turn\n" );
303 cx_init_disp( DISP_BM1 );
307 while (*++argv)
if (*argv[0] ==
'-')
switch (argv[0][1]) {
308 case 'O': force_background = 1;
break;
309 case 'B': force_background = 2;
break;
310 case 'd': magnification = 2;
break;
311 case 't': magnification = 3;
break;
312 case 'p': originx = atoi( *++argv ); originy = atoi( *++argv );
break;
313 case 'l': gamma_value = 1.0;
break;
314 case '\0': getcx3d( (
char *) 0, force_background, magnification,
315 originx, originy, gamma_value );
318 force_background = -1;
320 originx = originy = 0;
323 default: usage( );
goto out;
325 getcx3d( argv[0], force_background, magnification,
326 originx, originy, gamma_value );
329 force_background = -1;
331 originx = originy = 0;
335 if (!doneone) getcx3d( (
char *) 0, force_background, magnification,
336 originx, originy, gamma_value );
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
char * cmd_name(char **argv)
#define DIRECTCOLG(r, g, b, gv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
int rle_getrow(rle_hdr *the_hdr, scanline)
FILE * rle_open_f_noexit(char *prog_name, char *file_name, char *mode)
#define RLE_CLR_BIT(glob, bit)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)