35 #if BITS_IN_JSAMPLE != 8
36 Sorry,
this code only copes with 8-bit JSAMPLEs.
52 { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind;
62 typedef struct _rle_source_struct * rle_source_ptr;
64 typedef struct _rle_source_struct {
83 rle_source_ptr source = (rle_source_ptr) sinfo;
85 #ifdef PROGRESS_REPORT
90 source->header = *rle_hdr_init(NULL);
91 source->header.rle_file = source->pub.input_file;
92 switch (rle_get_setup(&(source->header))) {
103 ERREXIT(cinfo, JERR_RLE_EMPTY);
109 ERREXIT(cinfo, JERR_RLE_BADERROR);
115 width = source->header.xmax - source->header.xmin + 1;
116 height = source->header.ymax - source->header.ymin + 1;
117 source->header.xmin = 0;
118 source->header.xmax =
width-1;
124 if (source->header.ncolors == 1 && source->header.ncmap == 0) {
125 source->visual = GRAYSCALE;
127 }
else if (source->header.ncolors == 1 && source->header.ncmap == 1) {
128 source->visual = MAPPEDGRAY;
130 1 << source->header.cmaplen);
131 }
else if (source->header.ncolors == 1 && source->header.ncmap == 3) {
132 source->visual = PSEUDOCOLOR;
134 1 << source->header.cmaplen);
135 }
else if (source->header.ncolors == 3 && source->header.ncmap == 3) {
136 source->visual = TRUECOLOR;
138 1 << source->header.cmaplen);
139 }
else if (source->header.ncolors == 3 && source->header.ncmap == 0) {
140 source->visual = DIRECTCOLOR;
143 ERREXIT(cinfo, JERR_RLE_UNSUPPORTED);
145 if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) {
157 if (source->visual != GRAYSCALE) {
158 source->rle_row = (rle_pixel**) (*cinfo->mem->alloc_sarray)
164 source->image = (*cinfo->mem->request_virt_sarray)
169 #ifdef PROGRESS_REPORT
176 source->pub.buffer_height = 1;
189 rle_source_ptr source = (rle_source_ptr) sinfo;
192 source->pub.buffer = (*cinfo->mem->access_virt_sarray)
207 rle_source_ptr source = (rle_source_ptr) sinfo;
213 colormap = source->header.cmap;
216 src_row = * (*cinfo->mem->access_virt_sarray)
243 rle_source_ptr source = (rle_source_ptr) sinfo;
245 JSAMPROW scanline, red_ptr, green_ptr, blue_ptr;
249 #ifdef PROGRESS_REPORT
253 colormap = source->header.cmap;
254 rle_row = source->rle_row;
260 RLE_CLR_BIT(source->header, RLE_ALPHA);
262 #ifdef PROGRESS_REPORT
270 switch (source->visual) {
275 rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray)
277 rle_getrow(&source->header, rle_row);
278 #ifdef PROGRESS_REPORT
290 scanline = * (*cinfo->mem->access_virt_sarray)
292 rle_row = source->rle_row;
293 rle_getrow(&source->header, rle_row);
296 for (channel = 0; channel < source->header.ncolors; channel++) {
298 (colormap[
GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8);
302 #ifdef PROGRESS_REPORT
313 scanline = * (*cinfo->mem->access_virt_sarray)
315 rle_getrow(&source->header, rle_row);
317 red_ptr = rle_row[0];
318 green_ptr = rle_row[1];
319 blue_ptr = rle_row[2];
322 *scanline++ = *red_ptr++;
323 *scanline++ = *green_ptr++;
324 *scanline++ = *blue_ptr++;
327 #ifdef PROGRESS_REPORT
336 #ifdef PROGRESS_REPORT
342 if (source->visual == PSEUDOCOLOR) {
343 source->pub.buffer = source->rle_row;
344 source->pub.get_pixel_rows = get_pseudocolor_row;
346 source->pub.get_pixel_rows = get_rle_row;
351 return (*source->pub.get_pixel_rows) (cinfo, sinfo);
373 rle_source_ptr source;
376 source = (rle_source_ptr)
378 SIZEOF(rle_source_struct));
380 source->pub.start_input = start_input_rle;
381 source->pub.finish_input = finish_input_rle;
382 source->pub.get_pixel_rows = load_image;