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;
126 TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height);
127 }
else if (source->header.ncolors == 1 && source->header.ncmap == 1) {
128 source->visual = MAPPEDGRAY;
129 TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height,
130 1 << source->header.cmaplen);
131 }
else if (source->header.ncolors == 1 && source->header.ncmap == 3) {
132 source->visual = PSEUDOCOLOR;
133 TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height,
134 1 << source->header.cmaplen);
135 }
else if (source->header.ncolors == 3 && source->header.ncmap == 3) {
136 source->visual = TRUECOLOR;
137 TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height,
138 1 << source->header.cmaplen);
139 }
else if (source->header.ncolors == 3 && source->header.ncmap == 0) {
140 source->visual = DIRECTCOLOR;
141 TRACEMS2(cinfo, 1, JTRC_RLE, width, height);
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)
166 (
JDIMENSION) (width * source->header.ncolors),
169 #ifdef PROGRESS_REPORT 170 if (progress !=
NULL) {
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;
214 dest_row = source->pub.buffer[0];
216 src_row = * (*cinfo->mem->access_virt_sarray)
221 *dest_row++ = (
JSAMPLE) (colormap[val ] >> 8);
222 *dest_row++ = (
JSAMPLE) (colormap[val + 256] >> 8);
223 *dest_row++ = (
JSAMPLE) (colormap[val + 512] >> 8);
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 263 if (progress !=
NULL) {
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 279 if (progress !=
NULL) {
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 303 if (progress !=
NULL) {
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 328 if (progress !=
NULL) {
336 #ifdef PROGRESS_REPORT 337 if (progress !=
NULL)
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);
376 source = (rle_source_ptr)
377 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
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;
GLint GLint GLsizei GLsizei height
struct jpeg_common_struct * j_common_ptr
GLenum GLsizei GLenum GLenum const GLvoid * image
GLsizei GLsizei GLchar * source
#define GETJSAMPLE(value)
GLint GLint GLsizei width
#define ERREXIT(cinfo, code)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
J_COLOR_SPACE in_color_space
GLenum GLenum GLvoid * row
int JSAMPARRAY int dest_row
struct jpeg_progress_mgr pub
int completed_extra_passes
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3)
struct cdjpeg_progress_mgr * cd_progress_ptr
struct jvirt_sarray_control * jvirt_sarray_ptr