src/plugins/imageformats/tiff/qtiffhandler.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the plugins of the Qt Toolkit.
     7 ** This file is part of the plugins of the Qt Toolkit.
     8 **
     8 **
   190         || !TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric)) {
   190         || !TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric)) {
   191         TIFFClose(tiff);
   191         TIFFClose(tiff);
   192         return false;
   192         return false;
   193     }
   193     }
   194 
   194 
       
   195     // BitsPerSample defaults to 1 according to the TIFF spec.
   195     uint16 bitPerSample;
   196     uint16 bitPerSample;
   196     if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitPerSample)) {
   197     if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitPerSample))
   197         TIFFClose(tiff);
   198         bitPerSample = 1;
   198         return false;
       
   199     }
       
   200 
   199 
   201     bool grayscale = photometric == PHOTOMETRIC_MINISBLACK || photometric == PHOTOMETRIC_MINISWHITE;
   200     bool grayscale = photometric == PHOTOMETRIC_MINISBLACK || photometric == PHOTOMETRIC_MINISWHITE;
   202     if (grayscale && bitPerSample == 1) {
   201     if (grayscale && bitPerSample == 1) {
   203         if (image->size() != QSize(width, height) || image->format() != QImage::Format_Mono)
   202         if (image->size() != QSize(width, height) || image->format() != QImage::Format_Mono)
   204             *image = QImage(width, height, QImage::Format_Mono);
   203             *image = QImage(width, height, QImage::Format_Mono);