diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-05 12:05:18 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-07-14 05:53:48 +0000 |
commit | 7682542b4b487003e43c4081be01c06655db3c7e (patch) | |
tree | d2a2a7900c9bd361dd23a345a16122262d4aa6a2 /src/plugins | |
parent | 4cb3c3e15aba83a32f5b4ddcf4561bc231aa4dc2 (diff) |
Factor out qt_getImageText() and qt_getImageTextFromDescription()
... and re-use them in QImageReader, QJpegHandler, QPngHandler.
Change-Id: Iec89e47205f3c420e1e7eb4a2d3c1fbfe887fd8c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/imageformats/jpeg/jpeg.pro | 2 | ||||
-rw-r--r-- | src/plugins/imageformats/jpeg/qjpeghandler.cpp | 25 |
2 files changed, 4 insertions, 23 deletions
diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index 9181abb465..8954cc6402 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -1,6 +1,6 @@ TARGET = qjpeg -QT += core-private +QT += core-private gui-private SOURCES += main.cpp qjpeghandler.cpp HEADERS += main.h qjpeghandler_p.h diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 52e8b39f11..d89b8d398b 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -45,6 +45,7 @@ #include <qbuffer.h> #include <qmath.h> #include <private/qsimd_p.h> +#include <private/qimage_p.h> // for qt_getImageText #include <stdio.h> // jpeglib needs this to be pre-included #include <setjmp.h> @@ -491,30 +492,10 @@ inline my_jpeg_destination_mgr::my_jpeg_destination_mgr(QIODevice *device) free_in_buffer = max_buf; } - static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QString &description) { - QMap<QString, QString> text; - foreach (const QString &key, image.textKeys()) { - if (!key.isEmpty()) - text.insert(key, image.text(key)); - } - foreach (const QString &pair, description.split(QLatin1String("\n\n"))) { - int index = pair.indexOf(QLatin1Char(':')); - if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) { - QString s = pair.simplified(); - if (!s.isEmpty()) - text.insert(QLatin1String("Description"), s); - } else { - QString key = pair.left(index); - if (!key.simplified().isEmpty()) - text.insert(key, pair.mid(index + 2).simplified()); - } - } - if (text.isEmpty()) - return; - - for (QMap<QString, QString>::ConstIterator it = text.constBegin(); it != text.constEnd(); ++it) { + const QMap<QString, QString> text = qt_getImageText(image, description); + for (auto it = text.begin(), end = text.end(); it != end; ++it) { QByteArray comment = it.key().toLatin1(); if (!comment.isEmpty()) comment += ": "; |