代码拉取完成,页面将自动刷新
同步操作将从 OpenCloudOS Stream/qt5-qtimageformats 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From a733ebf966d4fad62ba05d90d29e36668eb5ce68 Mon Sep 17 00:00:00 2001
From: Eirik Aavitsland <[email protected]>
Date: Wed, 4 Jan 2023 18:06:57 +0100
Subject: [PATCH 03/10] Implement support for file memory mapping for tiff
reading
libtiff will by default attempt to establish a memory map for reading
a tiff file. Implement the callbacks to establish this in Qt's tiff
handler, since this will save data copying, particularly in the case
where the input file is already in memory as a resource or QBuffer.
Also, this makes sure that QTiffHandler utilizes libtiff's default,
and hence best tested, code path for tiff decoding. Specifically, it
avoids a hitting a bug that breaks reading of certain tiffs in the
newly released libtiff version 4.5.0.
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Id6a746546e069da9910cacd4a4996c669c72cbab
Reviewed-by: Dmitry Shachnev <[email protected]>
Reviewed-by: Allan Sandfeld Jensen <[email protected]>
(cherry picked from commit cd92d76e9dcd98f4fc974c796453459779393bdc)
---
.../imageformats/tiff/qtiffhandler.cpp | 26 +++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp
index b385273..79be154 100644
--- a/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -44,6 +44,8 @@
#include <qglobal.h>
#include <qvariant.h>
#include <qvarlengtharray.h>
+#include <qbuffer.h>
+#include <qfiledevice.h>
extern "C" {
#include "tiffio.h"
@@ -92,13 +94,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));
}
--
2.43.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。