fix:mdx dictionary support tiff image

This commit is contained in:
xiaoyifang 2022-04-04 23:50:33 +08:00
parent c21d7ffc02
commit 4970958253

32
mdx.cc
View file

@ -40,6 +40,7 @@
#include <QRegularExpression> #include <QRegularExpression>
#include "tiff.hh"
#include "utils.hh" #include "utils.hh"
namespace Mdx namespace Mdx
@ -971,6 +972,37 @@ void MddResourceRequest::run()
data.resize( bytes.size() ); data.resize( bytes.size() );
memcpy( &data.front(), bytes.constData(), 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; break;
} }