mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
cd40bfa7d3
* Qt already have built-in support for them * remove qmake option no_extra_tiff_handler
32 lines
848 B
C++
32 lines
848 B
C++
/* This file is (c) 2014 Abs62
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
#include "tiff.hh"
|
|
#include <QBuffer>
|
|
#include <QApplication>
|
|
#include <QScreen>
|
|
|
|
namespace GdTiff {
|
|
|
|
void tiff2img( std::vector< char > & data, const char * format )
|
|
{
|
|
QImage img = QImage::fromData( (unsigned char *)&data.front(), data.size() );
|
|
|
|
if ( !img.isNull() ) {
|
|
QByteArray ba;
|
|
QBuffer buffer( &ba );
|
|
buffer.open( QIODevice::WriteOnly );
|
|
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() );
|
|
buffer.close();
|
|
}
|
|
}
|
|
|
|
} // namespace GdTiff
|