split/Tioga/pdfimage.c in tioga-1.8 vs split/Tioga/pdfimage.c in tioga-1.9

- old
+ new

@@ -155,24 +155,28 @@ "\t/Filter /DCTDecode\n\t/ColorSpace " "/DeviceRGB\n\t/BitsPerComponent 8\n", xo->mask_obj_num, ierr); } - +extern void +str_hls_to_rgb_bang(unsigned char* str, long len); + void Write_Sampled(Sampled_Info *xo, int *ierr) { fprintf(OF, "\n\t/Subtype /Image\n"); fprintf(OF, "\t/Filter /FlateDecode\n\t/Interpolate %s\n", (xo->interpolate)? "true":"false"); fprintf(OF, "\t/Height %i\n", xo->height); fprintf(OF, "\t/Width %i\n", xo->width); int i, len; unsigned long new_len; + unsigned char *image_data; unsigned char *buffer; switch (xo->image_type) { case RGB_IMAGE: + case HLS_IMAGE: fprintf(OF, "\t/ColorSpace /DeviceRGB\n"); fprintf(OF, "\t/BitsPerComponent 8\n"); break; case CMYK_IMAGE: fprintf(OF, "\t/ColorSpace /DeviceCMYK\n"); @@ -212,13 +216,22 @@ } if (xo->value_mask_min >= 0 && xo->value_mask_max >= 0 && xo->value_mask_min <= 255 && xo->value_mask_max <= 255 && xo->value_mask_min <= xo->value_mask_max) fprintf(OF, "\t/Mask [%i %i]\n", xo->value_mask_min, xo->value_mask_max); + + if (xo->image_type == HLS_IMAGE) { + image_data = ALLOC_N_unsigned_char(xo->length); + memcpy(image_data, xo->image_data, xo->length); + str_hls_to_rgb_bang(image_data, xo->length); + } else { + image_data = xo->image_data; + } + new_len = (xo->length * 11)/10 + 100; buffer = ALLOC_N_unsigned_char(new_len); - if (do_flate_compress(buffer, &new_len, xo->image_data, xo->length) + if (do_flate_compress(buffer, &new_len, image_data, xo->length) != FLATE_OK) { free(buffer); RAISE_ERROR("Error compressing image data", ierr); return; } @@ -227,9 +240,10 @@ if (fwrite(buffer, 1, new_len, OF) < new_len) { RAISE_ERROR("Error writing image data", ierr); return; } free(buffer); + if (xo->image_type == HLS_IMAGE) free(image_data); fprintf(OF, "\nendstream\nendobj\n"); } // transform maps (0,0), (1,0), and (0,1) to the given points