Changeset 13771

Show
Ignore:
Timestamp:
02/13/08 01:23:44 (3 months ago)
Author:
warmerdam
Message:

migrated JPEGCOLORMODE_RGB setting into SetDirectory? (#2189)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/gtiff/geotiff.cpp

    r13743 r13771  
    27422742        return TRUE; 
    27432743 
     2744    CPLDebug( "GTiff", "SetDirectory(%15.0f)",(double) nNewOffset ); 
     2745 
    27442746    if( GetAccess() == GA_Update ) 
    27452747        TIFFFlush( hTIFF ); 
    27462748     
    2747     return TIFFSetSubDirectory( hTIFF, nNewOffset ); 
     2749    int nSetDirResult = TIFFSetSubDirectory( hTIFF, nNewOffset ); 
     2750 
     2751/* -------------------------------------------------------------------- */ 
     2752/*      YCbCr JPEG compressed images should be translated on the fly    */ 
     2753/*      to RGB by libtiff/libjpeg unless specifically requested         */ 
     2754/*      otherwise.                                                      */ 
     2755/* -------------------------------------------------------------------- */ 
     2756    if( !TIFFGetField( hTIFF, TIFFTAG_COMPRESSION, &(nCompression) ) ) 
     2757        nCompression = COMPRESSION_NONE; 
     2758 
     2759    if( !TIFFGetField( hTIFF, TIFFTAG_PHOTOMETRIC, &(nPhotometric) ) ) 
     2760        nPhotometric = PHOTOMETRIC_MINISBLACK; 
     2761     
     2762    if( nCompression == COMPRESSION_JPEG  
     2763        && nPhotometric == PHOTOMETRIC_YCBCR  
     2764        && CSLTestBoolean( CPLGetConfigOption("CONVERT_YCBCR_TO_RGB", 
     2765                                              "YES") ) ) 
     2766    { 
     2767        int nColorMode; 
     2768 
     2769        TIFFGetField( hTIFF, TIFFTAG_JPEGCOLORMODE, &nColorMode ); 
     2770        if( nColorMode != JPEGCOLORMODE_RGB ) 
     2771            TIFFSetField(hTIFF, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); 
     2772    } 
     2773 
     2774    return nSetDirResult; 
    27482775} 
    27492776 
     
    31043131    } 
    31053132         
    3106 /* -------------------------------------------------------------------- */ 
    3107 /*      YCbCr JPEG compressed images should be translated on the fly    */ 
    3108 /*      to RGB by libtiff/libjpeg unless specifically requested         */ 
    3109 /*      otherwise.                                                      */ 
    3110 /* -------------------------------------------------------------------- */ 
    3111     if( nCompression == COMPRESSION_JPEG  
    3112         && nPhotometric == PHOTOMETRIC_YCBCR  
    3113         && CSLTestBoolean( CPLGetConfigOption("CONVERT_YCBCR_TO_RGB", 
    3114                                               "YES") ) ) 
    3115     { 
    3116         TIFFSetField(hTIFF, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); 
    3117     } 
    3118  
    31193133/* -------------------------------------------------------------------- */ 
    31203134/*      Should we treat this via the odd bits interface?                */