[Libreoffice-commits] core.git: filter/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Mon Jan 9 21:15:10 UTC 2017


 filter/source/msfilter/msdffimp.cxx |   38 ++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

New commits:
commit 735941713c81ec8ca9ac796b832d776f6ef633ef
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sun Jan 8 23:35:44 2017 +0100

    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 at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 841c546..651e94b 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));


More information about the Libreoffice-commits mailing list