summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpnghandler.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-03-22 10:18:16 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-03-22 10:18:16 (GMT)
commit88ebb57019913958771416261206d9daa77fc4aa (patch)
tree44950a191d27dd51881088737cf19154a774f8bb /src/gui/image/qpnghandler.cpp
parent84a342eea111f0a1da8fd0c417362aae2b851e56 (diff)
parent9e85af3454bd0a2d962523d52e688f9bc7259528 (diff)
downloadQt-88ebb57019913958771416261206d9daa77fc4aa.zip
Qt-88ebb57019913958771416261206d9daa77fc4aa.tar.gz
Qt-88ebb57019913958771416261206d9daa77fc4aa.tar.bz2
Merge remote-tracking branch 'mainline/master'
Conflicts: src/gui/image/qpnghandler.cpp
Diffstat (limited to 'src/gui/image/qpnghandler.cpp')
-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 7e0355a..d88c437 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,13 +503,15 @@ 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);
+
#ifndef QT_NO_IMAGE_TEXT
+ readPngTexts(end_info);
for (int i = 0; i < readTexts.size()-1; i+=2)
outImage->setText(readTexts.at(i), readTexts.at(i+1));
#endif
- 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;