31 static char rcs_ident[] =
"$Id: rle_getraw.c,v 3.0.1.1 1992/01/28 18:20:36 spencer Exp spencer $";
39 #define VAXSHORT( var, fp )
40 { var = fgetc(fp)&0xFF
; var |= (fgetc(fp)) << 8
; }
44 #define OPCODE(inst) (inst[0
] & ~LONG)
45 #define LONGP(inst) (inst[0
] & LONG)
46 #define DATUM(inst) (inst[1
] & 0xff
)
84 register rle_op * rawp = NULL;
87 int scan_x = the_hdr
->xmin;
88 register int was_data;
89 short word, long_data, nc, been_some = 0;
92 if ( the_hdr->priv.get.vert_skip > 0 )
93 the_hdr->priv.get.scan_y += the_hdr->priv.get.vert_skip;
96 for ( channel = (the_hdr
->alpha ? -1 : 0);
99 if (
RLE_BIT( *the_hdr, channel ) )
103 if ( the_hdr->priv.get.is_eof )
111 inst[0] = getc( infile );
112 inst[1] = getc( infile );
115 the_hdr->priv.get.is_eof = 1;
125 VAXSHORT( the_hdr->priv.get.vert_skip, infile );
128 the_hdr->priv.get.vert_skip =
DATUM(inst);
133 channel =
DATUM(inst);
134 if ( channel == 255 )
137 if (
RLE_BIT( *the_hdr, channel ) )
138 rawp = scanraw[channel];
152 scan_x +=
DATUM(inst);
170 rawp->u.pixels = (
rle_pixel *)malloc( (
unsigned)nc );
171 fread( (
char *)rawp->u.pixels, 1, nc, infile );
173 (
void)getc( infile );
178 if ( the_hdr->priv.get.is_seek )
179 fseek( infile, ((nc + 1) / 2) * 2, 1 );
183 for ( ii = ((nc + 1) / 2) * 2; ii > 0; ii-- )
184 (
void) getc( infile );
207 rawp->u.run_val = word;
216 the_hdr->priv.get.is_eof = 1;
221 "%s: rle_getraw: Unrecognized opcode: %d, reading %s\n",
233 the_hdr->priv.get.scan_y +=
234 the_hdr->priv.get.vert_skip;
239 if ( the_hdr->priv.get.scan_y >= the_hdr
->ymax )
241 int y = the_hdr->priv.get.scan_y;
248 return (was_data == 0) ? 32768 : the_hdr->priv.get.scan_y;
274 register rle_op * raw_p;
278 for ( i = nraw[c], raw_p = scanraw[c]; i > 0; i--, raw_p++ )
281 if ( raw_p->u.pixels )
282 free( raw_p->u.pixels );
285 "%s(%s): rle_freeraw given NULL pixel pointer, %d[%d].\n",
288 raw_p->u.pixels = NULL;
void rle_freeraw(rle_hdr *the_hdr, scanraw, nraw)
unsigned int rle_getskip(rle_hdr *the_hdr)
#define VAXSHORT(var, fp)
unsigned int rle_getraw(rle_hdr *the_hdr, scanraw, nraw)
#define RLE_BIT(glob, bit)