AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
March 2006

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2006.03.29 22:22 "TIFF_UPSAMPLED", by Frank Warmerdam
2006.03.30 18:44 "Re: TIFF_UPSAMPLED", by Antonio Scuri

2006.03.30 18:44 "Re: TIFF_UPSAMPLED", by Antonio Scuri

Hi,

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