summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-01-08 23:35:44 +0100
committerAndras Timar <andras.timar@collabora.com>2017-02-17 23:48:19 +0100
commitfbc5694cc0cf10f432e15da09da5497a90e2cbf2 (patch)
tree433568a2515e1d469378899dcc1a93838659411b /filter
parent2b3c44144ebcce424f8e5ad23e10bc2a0733b0f9 (diff)
Fix import of patterns for MS binary formats
Don't use XOBitmap, which in some cases doesn't import the pattern correctly (on Linux and with a different issue on Windows too) - it doesn't seem to be necessary to use it, just convert the pattern bitmap to a bitmap that has the expected colors applied. Change-Id: Ide7d5ce0115b63e882b3544b10fd00d5582cf7d3 Reviewed-on: https://gerrit.libreoffice.org/32855 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 735941713c81ec8ca9ac796b832d776f6ef633ef)
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/msdffimp.cxx38
1 files changed, 22 insertions, 16 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 8c017ec260df..1ac086b988db 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -1369,24 +1369,30 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
if ( IsProperty( DFF_Prop_fillBackColor ) )
aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor, 0 ), DFF_Prop_fillBackColor );
- XOBitmap aXOBitmap( aBmp );
- aXOBitmap.Bitmap2Array();
- aXOBitmap.SetBitmapType( XBitmapType::N8x8 );
- aXOBitmap.SetPixelSize( aBmp.GetSizePixel() );
-
- if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
+ // Create a bitmap for the pattern with expected colors
+ Bitmap aResult(Size(8, 8), 24);
{
- aXOBitmap.SetPixelColor( aCol1 );
- aXOBitmap.SetBackgroundColor( aCol2 );
- }
- else
- {
- aXOBitmap.SetPixelColor( aCol2 );
- aXOBitmap.SetBackgroundColor( aCol1 );
- }
+ Bitmap::ScopedReadAccess pRead(aBmp);
+ Bitmap::ScopedWriteAccess pWrite(aResult);
- aXOBitmap.Array2Bitmap();
- aGraf = Graphic( aXOBitmap.GetBitmap() );
+ for (long y = 0; y < pWrite->Height(); ++y)
+ {
+ for (long x = 0; x < pWrite->Width(); ++x)
+ {
+ Color aReadColor;
+ if (pRead->HasPalette())
+ aReadColor = pRead->GetPaletteColor(pRead->GetPixelIndex(y, x));
+ else
+ aReadColor = pRead->GetPixel(y, x);
+
+ if (aReadColor.GetColor() == 0)
+ pWrite->SetPixel(y, x, aCol2);
+ else
+ pWrite->SetPixel(y, x, aCol1);
+ }
+ }
+ }
+ aGraf = Graphic(aResult);
}
rSet.Put(XFillBitmapItem(OUString(), aGraf));