Skip to content

Commit

Permalink
feature:webp auto scale to reduce the size
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Apr 17, 2022
1 parent 8bbcb72 commit a4c1e27
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tiff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#endif

#include <QBuffer>
#include <QApplication>
#include <QScreen>

namespace GdTiff
{
Expand Down Expand Up @@ -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() );
Expand Down

0 comments on commit a4c1e27

Please sign in to comment.