summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2011-03-17 10:16:16 (GMT)
committeraavit <qt-info@nokia.com>2011-03-17 11:26:46 (GMT)
commitb9b1d0c5ae9ff9a8799616acd7165565afbd2337 (patch)
tree097bcef2f1eb2663fad49a3e6de3dab0cd87f9b5 /src/gui/image
parent6d4ef0ff8fd30e5f50f6f770d651a51584e5cfdc (diff)
downloadQt-b9b1d0c5ae9ff9a8799616acd7165565afbd2337.zip
Qt-b9b1d0c5ae9ff9a8799616acd7165565afbd2337.tar.gz
Qt-b9b1d0c5ae9ff9a8799616acd7165565afbd2337.tar.bz2
Fixes: some text fields in PNG image files were not read
Text chunks placed after the real image data (IDAT chunks) were ignored. Reviewed-by: Kim
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpnghandler.cpp65
1 files changed, 39 insertions, 26 deletions
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index a9aad51..450e8c6 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -109,6 +109,7 @@ public:
bool readPngHeader();
bool readPngImage(QImage *image);
+ void readPngTexts(png_info *info);
QImage::Format readImageFormat();
@@ -359,6 +360,39 @@ static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const
}
#endif
+
+/*!
+ \internal
+*/
+void Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngTexts(png_info *info)
+{
+#ifndef QT_NO_IMAGE_TEXT
+ png_textp text_ptr;
+ int num_text=0;
+ png_get_text(png_ptr, info, &text_ptr, &num_text);
+
+ while (num_text--) {
+ QString key, value;
+ key = QString::fromLatin1(text_ptr->key);
+#if defined(PNG_iTXt_SUPPORTED)
+ if (text_ptr->itxt_length) {
+ value = QString::fromUtf8(text_ptr->text, int(text_ptr->itxt_length));
+ } else
+#endif
+ {
+ value = QString::fromLatin1(text_ptr->text, int(text_ptr->text_length));
+ }
+ if (!description.isEmpty())
+ description += QLatin1String("\n\n");
+ description += key + QLatin1String(": ") + value.simplified();
+ readTexts.append(key);
+ readTexts.append(value);
+ text_ptr++;
+ }
+#endif
+}
+
+
/*!
\internal
*/
@@ -394,30 +428,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader()
png_set_read_fn(png_ptr, this, iod_read_fn);
png_read_info(png_ptr, info_ptr);
-#ifndef QT_NO_IMAGE_TEXT
- png_textp text_ptr;
- int num_text=0;
- png_get_text(png_ptr,info_ptr,&text_ptr,&num_text);
-
- while (num_text--) {
- QString key, value;
- key = QString::fromLatin1(text_ptr->key);
-#if defined(PNG_iTXt_SUPPORTED)
- if (text_ptr->itxt_length) {
- value = QString::fromUtf8(text_ptr->text, int(text_ptr->itxt_length));
- } else
-#endif
- {
- value = QString::fromLatin1(QByteArray(text_ptr->text, int(text_ptr->text_length)));
- }
- if (!description.isEmpty())
- description += QLatin1String("\n\n");
- description += key + QLatin1String(": ") + value.simplified();
- readTexts.append(key);
- readTexts.append(value);
- text_ptr++;
- }
-#endif
+ readPngTexts(info_ptr);
state = ReadHeader;
return true;
@@ -492,11 +503,13 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
outImage->setDotsPerMeterX(png_get_x_pixels_per_meter(png_ptr,info_ptr));
outImage->setDotsPerMeterY(png_get_y_pixels_per_meter(png_ptr,info_ptr));
+ state = ReadingEnd;
+ png_read_end(png_ptr, end_info);
+
+ readPngTexts(end_info);
for (int i = 0; i < readTexts.size()-1; i+=2)
outImage->setText(readTexts.at(i), readTexts.at(i+1));
- state = ReadingEnd;
- png_read_end(png_ptr, end_info);
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
delete [] row_pointers;
png_ptr = 0;