| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2006.03.30 18:44 "Re: TIFF_UPSAMPLED", by Antonio ScuriHi,
I solved my problem when saving/loading YCbCr color mode JPEG
compressed TIFF in a different way.
When encoding I do not want to provide a downsampled output so I changed:
function JPEGPreEncode, at line 1298 in tif_jpeg.c from CVS
FROM
if (sp->photometric == PHOTOMETRIC_YCBCR) {
if (sp->jpegcolormode == JPEGCOLORMODE_RGB) {
sp->cinfo.c.in_color_space = JCS_RGB;
} else {
sp->cinfo.c.in_color_space = JCS_YCbCr;
if (sp->h_sampling != 1 ||
sp->v_sampling != 1)
downsampled_input = TRUE;
TO
if (sp->photometric == PHOTOMETRIC_YCBCR) {
if (sp->jpegcolormode == JPEGCOLORMODE_RGB) {
sp->cinfo.c.in_color_space = JCS_RGB;
} else {
sp->cinfo.c.in_color_space = JCS_YCbCr;
tif->tif_flags |= TIFF_UPSAMPLED; /*
Changed for IM
if (sp->h_sampling != 1 ||
sp->v_sampling != 1)
downsampled_input = TRUE; */
And
Also when decoding I do not want to get a downsampled output so I changed:
function JPEGPreDecode, at line 801 in tif_jpeg.c from CVS
FROM
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
sp->photometric == PHOTOMETRIC_YCBCR &&
sp->jpegcolormode == JPEGCOLORMODE_RGB) {
/* Convert YCbCr to RGB */
sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
sp->cinfo.d.out_color_space = JCS_RGB;
} else {
/* Suppress colorspace handling */
sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
sp->cinfo.d.out_color_space = JCS_UNKNOWN;
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
(sp->h_sampling != 1 || sp->v_sampling != 1))
downsampled_output = TRUE;
/* XXX what about up-sampling? */
TO
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
sp->photometric == PHOTOMETRIC_YCBCR &&
sp->jpegcolormode == JPEGCOLORMODE_RGB) {
/* Convert YCbCr to RGB */
sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
sp->cinfo.d.out_color_space = JCS_RGB;
} else {
/* Suppress colorspace handling */
sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
sp->cinfo.d.out_color_space = JCS_UNKNOWN;
tif->tif_flags |= TIFF_UPSAMPLED; /* Changed for IM
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
(sp->h_sampling != 1 || sp->v_sampling != 1))
downsampled_output = TRUE; */
/* XXX what about up-sampling? */
}
Hope this helps too.
Best,
scuri
|
|||||||