From a4c1e2793a9600a7c2a4e021a91f1091ba1e5f1d Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sun, 17 Apr 2022 18:28:01 +0800 Subject: [PATCH] feature:webp auto scale to reduce the size --- tiff.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tiff.cc b/tiff.cc index 6b8f3f6a1..c40d5f140 100644 --- a/tiff.cc +++ b/tiff.cc @@ -14,6 +14,8 @@ #endif #include +#include +#include namespace GdTiff { @@ -153,7 +155,11 @@ void tiff2img( vector< char > & data, const char * format ) QByteArray ba; QBuffer buffer( &ba ); buffer.open( QIODevice::WriteOnly ); - img.save( &buffer, format ); + QSize screenSize = QApplication::primaryScreen()->availableSize(); + QSize imgSize = img.size(); + int scaleSize = qMin( imgSize.width(), screenSize.width() ); + + img.scaledToWidth( scaleSize ).save( &buffer, format ); data.resize( buffer.size() ); memcpy( &data.front(), buffer.data(), data.size() );