diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-01-04 21:21:52 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-01-04 21:21:52 +0200 |
commit | 3c2ad3eed6fc522ad809797747c8028b3dd4778a (patch) | |
tree | c64f652f34da2e39db11b6fca22ad5322c75554d /src/plugins/imageformats/tiff/qtiffhandler.cpp | |
parent | 1019058c497e33edef80d5cb120aa7d6a418a7c6 (diff) | |
parent | 1eaa734e4de3589c3c90e4676959a82299a6eb56 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.13' into tqtc/lts-5.15-opensourcev5.15.13-lts-lgpl
Change-Id: I61d561ccb0fe4d1f669a97acb27e76f646b76731
Diffstat (limited to 'src/plugins/imageformats/tiff/qtiffhandler.cpp')
-rw-r--r-- | src/plugins/imageformats/tiff/qtiffhandler.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index ac8956c..f0dfe7f 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -43,6 +43,9 @@ #include <qdebug.h> #include <qimage.h> #include <qglobal.h> +#include <qbuffer.h> +#include <qfiledevice.h> + extern "C" { #include "tiffio.h" } @@ -90,13 +93,33 @@ toff_t qtiffSizeProc(thandle_t fd) return static_cast<QIODevice *>(fd)->size(); } -int qtiffMapProc(thandle_t /*fd*/, tdata_t* /*pbase*/, toff_t* /*psize*/) +int qtiffMapProc(thandle_t fd, void **base, toff_t *size) { + QIODevice *device = static_cast<QIODevice *>(fd); + + QFileDevice *file = qobject_cast<QFileDevice *>(device); + if (file) { + *base = file->map(0, file->size()); + if (*base != nullptr) { + *size = file->size(); + return 1; + } + } else { + QBuffer *buf = qobject_cast<QBuffer *>(device); + if (buf) { + *base = const_cast<char *>(buf->data().constData()); + *size = buf->size(); + return 1; + } + } return 0; } -void qtiffUnmapProc(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/) +void qtiffUnmapProc(thandle_t fd, void *base, toff_t /*size*/) { + QFileDevice *file = qobject_cast<QFileDevice *>(static_cast<QIODevice *>(fd)); + if (file && base) + file->unmap(static_cast<uchar *>(base)); } |