mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
fix:mdx dictionary support tiff image
This commit is contained in:
parent
c21d7ffc02
commit
4970958253
32
mdx.cc
32
mdx.cc
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "tiff.hh"
|
||||
#include "utils.hh"
|
||||
|
||||
namespace Mdx
|
||||
|
@ -971,6 +972,37 @@ void MddResourceRequest::run()
|
|||
data.resize( bytes.size() );
|
||||
memcpy( &data.front(), bytes.constData(), bytes.size() );
|
||||
}
|
||||
if( Filetype::isNameOfTiff( u8ResourceName ) )
|
||||
{
|
||||
// Convert it
|
||||
|
||||
dataMutex.lock();
|
||||
|
||||
QImage img = QImage::fromData( (unsigned char *)&data.front(), data.size() );
|
||||
|
||||
#ifdef MAKE_EXTRA_TIFF_HANDLER
|
||||
if( img.isNull() )
|
||||
GdTiff::tiffToQImage( &data.front(), data.size(), img );
|
||||
#endif
|
||||
|
||||
dataMutex.unlock();
|
||||
|
||||
if( !img.isNull() )
|
||||
{
|
||||
// Managed to load -- now store it back as BMP
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer( &ba );
|
||||
buffer.open( QIODevice::WriteOnly );
|
||||
img.save( &buffer, "png" );
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
|
||||
data.resize( buffer.size() );
|
||||
|
||||
memcpy( &data.front(), buffer.data(), data.size() );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue