[Libreoffice-commits] core.git: 2 commits - include/vcl vcl/source
Caolán McNamara
caolanm at redhat.com
Thu Feb 26 06:39:21 PST 2015
include/vcl/dibtools.hxx | 8 +++++++-
vcl/source/filter/wmf/emfwr.cxx | 22 ++++++++++++++++++----
vcl/source/gdi/dibtools.cxx | 9 ---------
3 files changed, 25 insertions(+), 14 deletions(-)
New commits:
commit 08cb6e93cc8120b7b86ada52048e4c243828c2d8
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Feb 26 13:58:33 2015 +0000
expand this 1980's shift-fest, torture-by-ternery and magic '3' into human
Change-Id: Ifb18d5fd0b330dde0edc428621af417ddc836b21
diff --git a/include/vcl/dibtools.hxx b/include/vcl/dibtools.hxx
index a43764f..ddd7c87 100644
--- a/include/vcl/dibtools.hxx
+++ b/include/vcl/dibtools.hxx
@@ -24,14 +24,20 @@
#include <tools/rc.hxx>
#include <vcl/region.hxx>
-
// predefines
class SvStream;
class BitmapEx;
class Bitmap;
+// - Compression defines
+#define COMPRESS_OWN ('S'|('D'<<8UL))
+#define COMPRESS_NONE ( 0UL )
+#define RLE_8 ( 1UL )
+#define RLE_4 ( 2UL )
+#define BITFIELDS ( 3UL )
+#define ZCOMPRESS ( COMPRESS_OWN | 0x01000000UL ) /* == 'SD01' (binary) */
bool VCL_DLLPUBLIC ReadDIB( // ReadDIB(rBitmap, rIStm, true);
Bitmap& rTarget,
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index 3a91bce..6e84f4c 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -856,15 +856,29 @@ void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt,
aMemStm.SeekRel( 8 );
aMemStm.ReadUInt32( nColsUsed );
- nPalCount = ( nBitCount <= 8 ) ? ( nColsUsed ? nColsUsed : ( 1 << (sal_uInt32) nBitCount ) ) :
- ( ( 3 == nCompression ) ? 3 : 0 );
+ if (nBitCount <= 8)
+ {
+ if (nColsUsed)
+ nPalCount = nColsUsed;
+ else
+ nPalCount = 1 << (sal_uInt32)nBitCount;
+ }
+ else
+ {
+ if (nCompression == BITFIELDS)
+ nPalCount = 3;
+ else
+ nPalCount = 0;
+ }
+
+ sal_uInt32 nPalSize = nPalCount * 4;
m_rStm.Write( aMemStm.GetData(), nDIBSize );
const sal_uLong nEndPos = m_rStm.Tell();
m_rStm.Seek( nOffPos );
- m_rStm.WriteUInt32( 80 ).WriteUInt32( nHeaderSize + ( nPalCount << 2 ) );
- m_rStm.WriteUInt32( 80 + ( nHeaderSize + ( nPalCount << 2 ) ) ).WriteUInt32( nImageSize );
+ m_rStm.WriteUInt32( 80 ).WriteUInt32( nHeaderSize + nPalSize );
+ m_rStm.WriteUInt32( 80 + nHeaderSize + nPalSize ).WriteUInt32( nImageSize );
m_rStm.Seek( nEndPos );
ImplEndRecord();
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index 5ee404f..d79622f 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -37,15 +37,6 @@
#define DIBINFOHEADERSIZE ( sizeof(DIBInfoHeader) )
#define DIBV5HEADERSIZE ( sizeof(DIBV5Header) )
-// - Compression defines
-
-#define COMPRESS_OWN ('S'|('D'<<8UL))
-#define COMPRESS_NONE ( 0UL )
-#define RLE_8 ( 1UL )
-#define RLE_4 ( 2UL )
-#define BITFIELDS ( 3UL )
-#define ZCOMPRESS ( COMPRESS_OWN | 0x01000000UL ) /* == 'SD01' (binary) */
-
// - DIBInfoHeader and DIBV5Header
typedef sal_Int32 FXPT2DOT30;
commit 5e5b90c12862b522a4553337fbf6309bb8278b8c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Feb 26 13:47:58 2015 +0000
in BITFIELDS mode (3) there are *3* pal entries not 12
There are 12 *bytes*, which presumably is the thinko there. But this nPalCount
gets multiplied by 4 to convert it to bytes later.
This is the source of the bad mask values found after "Use the cairo-compatible
basebmp surface for headless" etc. Arbitrary values ended up being read as mask
values.
Change-Id: If5d93f74b1c58d3ecdb5186f93cb0215a556586a
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index df94922..3a91bce 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -857,7 +857,7 @@ void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt,
aMemStm.ReadUInt32( nColsUsed );
nPalCount = ( nBitCount <= 8 ) ? ( nColsUsed ? nColsUsed : ( 1 << (sal_uInt32) nBitCount ) ) :
- ( ( 3 == nCompression ) ? 12 : 0 );
+ ( ( 3 == nCompression ) ? 3 : 0 );
m_rStm.Write( aMemStm.GetData(), nDIBSize );
More information about the Libreoffice-commits
mailing list