summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/inc/graphic/GraphicFormatDetector.hxx2
-rw-r--r--vcl/source/filter/GraphicFormatDetector.cxx11
-rw-r--r--vcl/source/filter/graphicfilter2.cxx39
3 files changed, 15 insertions, 37 deletions
diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx b/vcl/inc/graphic/GraphicFormatDetector.hxx
index bb5ffa37361a..5d5ff7f9ece3 100644
--- a/vcl/inc/graphic/GraphicFormatDetector.hxx
+++ b/vcl/inc/graphic/GraphicFormatDetector.hxx
@@ -192,7 +192,7 @@ private:
*/
sal_uInt8* checkAndUncompressBuffer(sal_uInt8* aUncompressedBuffer, sal_uInt32 nSize,
sal_uInt64& nDecompressedSize);
- // bool mbExtendedInfo;
+ bool mbExtendedInfo;
GraphicMetadata maMetadata;
bool mbWasCompressed;
};
diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx
index 4c3b6663d3b1..4cf30e6e8571 100644
--- a/vcl/source/filter/GraphicFormatDetector.cxx
+++ b/vcl/source/filter/GraphicFormatDetector.cxx
@@ -339,14 +339,14 @@ bool isPCT(SvStream& rStream, sal_uLong nStreamPos, sal_uLong nStreamLen)
} // end anonymous namespace
GraphicFormatDetector::GraphicFormatDetector(SvStream& rStream, OUString aFormatExtension,
- bool /* bExtendedInfo */)
+ bool bExtendedInfo)
: mrStream(rStream)
, maExtension(std::move(aFormatExtension))
, mnFirstLong(0)
, mnSecondLong(0)
, mnStreamPosition(0)
, mnStreamLength(0)
- // , mbExtendedInfo(bExtendedInfo)
+ , mbExtendedInfo(bExtendedInfo)
, maMetadata()
{
}
@@ -516,6 +516,13 @@ bool GraphicFormatDetector::checkGIF()
&& maFirstBytes[5] == 0x61)
{
maMetadata.mnFormat = GraphicFileFormat::GIF;
+ if (mbExtendedInfo)
+ {
+ sal_uInt16 nWidth = maFirstBytes[6] | (maFirstBytes[7] << 8);
+ sal_uInt16 nHeight = maFirstBytes[8] | (maFirstBytes[9] << 8);
+ maMetadata.maPixSize = Size(nWidth, nHeight);
+ maMetadata.mnBitsPerPixel = ((maFirstBytes[10] & 112) >> 4) + 1;
+ }
return true;
}
return false;
diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx
index f59beaeb93a2..0a58f03a98ea 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -217,41 +217,12 @@ bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, bool bExtendedInfo )
bool GraphicDescriptor::ImpDetectGIF( SvStream& rStm, bool bExtendedInfo )
{
- sal_uInt32 n32 = 0;
- bool bRet = false;
-
sal_Int32 nStmPos = rStm.Tell();
- rStm.SetEndian( SvStreamEndian::LITTLE );
- rStm.ReadUInt32( n32 );
-
- if ( n32 == 0x38464947 )
- {
- sal_uInt16 n16 = 0;
- rStm.ReadUInt16( n16 );
- if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) )
- {
- aMetadata.mnFormat = GraphicFileFormat::GIF;
- bRet = true;
-
- if ( bExtendedInfo )
- {
- sal_uInt16 nTemp16 = 0;
- sal_uInt8 cByte = 0;
-
- // Pixel width
- rStm.ReadUInt16( nTemp16 );
- aMetadata.maPixSize.setWidth( nTemp16 );
-
- // Pixel height
- rStm.ReadUInt16( nTemp16 );
- aMetadata.maPixSize.setHeight( nTemp16 );
-
- // Bits/Pixel
- rStm.ReadUChar( cByte );
- aMetadata.mnBitsPerPixel = ( ( cByte & 112 ) >> 4 ) + 1;
- }
- }
- }
+ vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo );
+ bool bRet = aDetector.detect();
+ bRet &= aDetector.checkGIF();
+ if ( bRet )
+ aMetadata = aDetector.getMetadata();
rStm.Seek( nStmPos );
return bRet;
}