32 #if BITS_IN_JSAMPLE != 8 33 Sorry,
this code only copes with 8-bit JSAMPLEs.
51 #define CMAPLENGTH (1<<(CMAPBITS)) 62 typedef rle_dest_struct * rle_dest_ptr;
79 rle_dest_ptr dest = (rle_dest_ptr) dinfo;
82 #ifdef PROGRESS_REPORT 99 if (cinfo->output_width > 32767 || cinfo->output_height > 32767)
100 ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width,
101 cinfo->output_height);
104 cinfo->out_color_space !=
JCS_RGB)
105 ERREXIT(cinfo, JERR_RLE_COLORSPACE);
107 if (cinfo->output_components != 1 && cinfo->output_components != 3)
108 ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components);
112 dest->colormap = NULL;
114 if (cinfo->quantize_colors) {
116 cmapsize = cinfo->out_color_components * CMAPLENGTH *
SIZEOF(rle_map);
117 dest->colormap = (rle_map *) (*cinfo->mem->alloc_small)
119 MEMZERO(dest->colormap, cmapsize);
123 for (ci = 0; ci < cinfo->out_color_components; ci++) {
124 for (i = 0; i < cinfo->actual_number_of_colors; i++) {
125 dest->colormap[ci * CMAPLENGTH +
i] =
132 dest->pub.buffer = (*cinfo->mem->access_virt_sarray)
134 dest->pub.buffer_height = 1;
136 dest->pub.put_pixel_rows = rle_put_pixel_rows;
138 #ifdef PROGRESS_REPORT 139 if (progress != NULL) {
156 rle_dest_ptr dest = (rle_dest_ptr) dinfo;
158 if (cinfo->output_scanline < cinfo->output_height) {
159 dest->pub.buffer = (*cinfo->mem->access_virt_sarray)
161 cinfo->output_scanline, (
JDIMENSION) 1, TRUE);
174 rle_dest_ptr dest = (rle_dest_ptr) dinfo;
176 rle_pixel **rle_row, *
red, *
green, *blue;
178 char cmapcomment[80];
181 #ifdef PROGRESS_REPORT 186 header = *rle_hdr_init(NULL);
187 header.rle_file = dest->
pub.output_file;
189 header.xmax = cinfo->output_width - 1;
191 header.ymax = cinfo->output_height - 1;
193 header.ncolors = cinfo->output_components;
194 for (ci = 0; ci < cinfo->output_components; ci++) {
195 RLE_SET_BIT(header, ci);
197 if (cinfo->quantize_colors) {
198 header.ncmap = cinfo->out_color_components;
199 header.cmaplen = CMAPBITS;
200 header.cmap = dest->colormap;
202 sprintf(cmapcomment,
"color_map_length=%d", cinfo->actual_number_of_colors);
203 rle_putcom(cmapcomment, &header);
207 rle_put_setup(&header);
214 #ifdef PROGRESS_REPORT 215 if (progress != NULL) {
222 if (cinfo->output_components == 1) {
223 for (row = cinfo->output_height-1; row >= 0; row--) {
224 rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray)
227 rle_putrow(rle_row, (
int) cinfo->output_width, &header);
228 #ifdef PROGRESS_REPORT 229 if (progress != NULL) {
236 for (row = cinfo->output_height-1; row >= 0; row--) {
237 rle_row = (rle_pixel **) dest->rle_row;
238 output_row = * (*cinfo->mem->access_virt_sarray)
244 for (col = cinfo->output_width; col > 0; col--) {
249 rle_putrow(rle_row, (
int) cinfo->output_width, &header);
250 #ifdef PROGRESS_REPORT 251 if (progress != NULL) {
259 #ifdef PROGRESS_REPORT 260 if (progress != NULL)
266 fflush(dest->pub.output_file);
267 if (ferror(dest->pub.output_file))
268 ERREXIT(cinfo, JERR_FILE_WRITE);
282 dest = (rle_dest_ptr)
285 dest->pub.start_output = start_output_rle;
286 dest->pub.finish_output = finish_output_rle;
292 dest->rle_row = (*cinfo->mem->alloc_sarray)
294 cinfo->output_width, (
JDIMENSION) cinfo->output_components);
297 dest->image = (*cinfo->mem->request_virt_sarray)
299 (
JDIMENSION) (cinfo->output_width * cinfo->output_components),
struct jpeg_common_struct * j_common_ptr
#define GETJSAMPLE(value)
#define ERREXIT(cinfo, code)
jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
struct jpeg_progress_mgr pub
#define ERREXIT1(cinfo, code, p1)
std::string sprintf(char const *__restrict fmt,...)
int completed_extra_passes
struct cdjpeg_progress_mgr * cd_progress_ptr
#define ERREXIT2(cinfo, code, p1, p2)
#define MEMZERO(target, size)