30 #if BITS_IN_JSAMPLE != 8 31 Sorry,
this code only copes with 8-bit JSAMPLEs.
62 int map_colors,
int map_entry_size));
82 image_ptr = (*cinfo->mem->access_virt_sarray)
91 outptr = image_ptr[0];
92 for (col = cinfo->output_width; col > 0; col--) {
117 image_ptr = (*cinfo->mem->access_virt_sarray)
124 outptr = image_ptr[0];
125 for (col = cinfo->output_width; col > 0; col--) {
126 *outptr++ = *inptr++;
160 char bmpfileheader[14];
161 char bmpinfoheader[40];
162 #define PUT_2B(array,offset,value) \ 163 (array[offset] = (char) ((value) & 0xFF), \ 164 array[offset+1] = (char) (((value) >> 8) & 0xFF)) 165 #define PUT_4B(array,offset,value) \ 166 (array[offset] = (char) ((value) & 0xFF), \ 167 array[offset+1] = (char) (((value) >> 8) & 0xFF), \ 168 array[offset+2] = (char) (((value) >> 16) & 0xFF), \ 169 array[offset+3] = (char) (((value) >> 24) & 0xFF)) 170 INT32 headersize, bfSize;
171 int bits_per_pixel, cmap_entries;
174 if (cinfo->out_color_space ==
JCS_RGB) {
175 if (cinfo->quantize_colors) {
190 headersize = 14 + 40 + cmap_entries * 4;
198 bmpfileheader[0] = 0x42;
199 bmpfileheader[1] = 0x4D;
200 PUT_4B(bmpfileheader, 2, bfSize);
202 PUT_4B(bmpfileheader, 10, headersize);
205 PUT_2B(bmpinfoheader, 0, 40);
206 PUT_4B(bmpinfoheader, 4, cinfo->output_width);
207 PUT_4B(bmpinfoheader, 8, cinfo->output_height);
208 PUT_2B(bmpinfoheader, 12, 1);
209 PUT_2B(bmpinfoheader, 14, bits_per_pixel);
212 if (cinfo->density_unit == 2) {
213 PUT_4B(bmpinfoheader, 24, (
INT32) (cinfo->X_density*100));
214 PUT_4B(bmpinfoheader, 28, (
INT32) (cinfo->Y_density*100));
216 PUT_2B(bmpinfoheader, 32, cmap_entries);
220 ERREXIT(cinfo, JERR_FILE_WRITE);
222 ERREXIT(cinfo, JERR_FILE_WRITE);
224 if (cmap_entries > 0)
233 char bmpfileheader[14];
234 char bmpcoreheader[12];
235 INT32 headersize, bfSize;
236 int bits_per_pixel, cmap_entries;
239 if (cinfo->out_color_space ==
JCS_RGB) {
240 if (cinfo->quantize_colors) {
255 headersize = 14 + 12 + cmap_entries * 3;
263 bmpfileheader[0] = 0x42;
264 bmpfileheader[1] = 0x4D;
265 PUT_4B(bmpfileheader, 2, bfSize);
267 PUT_4B(bmpfileheader, 10, headersize);
270 PUT_2B(bmpcoreheader, 0, 12);
271 PUT_2B(bmpcoreheader, 4, cinfo->output_width);
272 PUT_2B(bmpcoreheader, 6, cinfo->output_height);
273 PUT_2B(bmpcoreheader, 8, 1);
274 PUT_2B(bmpcoreheader, 10, bits_per_pixel);
277 ERREXIT(cinfo, JERR_FILE_WRITE);
279 ERREXIT(cinfo, JERR_FILE_WRITE);
281 if (cmap_entries > 0)
293 int map_colors,
int map_entry_size)
296 int num_colors = cinfo->actual_number_of_colors;
300 if (colormap != NULL) {
301 if (cinfo->out_color_components == 3) {
303 for (
i = 0;
i < num_colors;
i++) {
307 if (map_entry_size == 4)
312 for (
i = 0;
i < num_colors;
i++) {
316 if (map_entry_size == 4)
322 for (
i = 0;
i < 256;
i++) {
326 if (map_entry_size == 4)
332 ERREXIT1(cinfo, JERR_TOO_MANY_COLORS,
i);
333 for (;
i < map_colors;
i++) {
337 if (map_entry_size == 4)
361 for (
row = cinfo->output_height;
row > 0;
row--) {
362 if (progress != NULL) {
367 image_ptr = (*cinfo->mem->access_virt_sarray)
369 data_ptr = image_ptr[0];
370 for (col = dest->
row_width; col > 0; col--) {
375 if (progress != NULL)
381 ERREXIT(cinfo, JERR_FILE_WRITE);
405 }
else if (cinfo->out_color_space ==
JCS_RGB) {
406 if (cinfo->quantize_colors)
411 ERREXIT(cinfo, JERR_BMP_COLORSPACE);
418 row_width = cinfo->output_width * cinfo->output_components;
420 while ((row_width & 3) != 0) row_width++;
425 dest->
whole_image = (*cinfo->mem->request_virt_sarray)
427 row_width, cinfo->output_height, (
JDIMENSION) 1);
429 if (cinfo->progress != NULL) {
435 dest->
pub.
buffer = (*cinfo->mem->alloc_sarray)
start_output_bmp(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
#define PUT_4B(array, offset, value)
struct jpeg_common_struct * j_common_ptr
#define GETJSAMPLE(value)
#define ERREXIT(cinfo, code)
JDIMENSION cur_output_row
#define JFWRITE(file, buf, sizeofbuf)
jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
bmp_dest_struct * bmp_dest_ptr
jvirt_sarray_ptr whole_image
write_bmp_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
write_colormap(j_decompress_ptr cinfo, bmp_dest_ptr dest, int map_colors, int map_entry_size)
struct jpeg_progress_mgr pub
#define ERREXIT1(cinfo, code, p1)
finish_output_bmp(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
int completed_extra_passes
write_os2_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
#define PUT_2B(array, offset, value)
jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2)
put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied)
struct cdjpeg_progress_mgr * cd_progress_ptr
struct djpeg_dest_struct pub
put_gray_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied)
#define MEMZERO(target, size)