[Libreoffice-commits] core.git: cui/source drawinglayer/source svx/source

Armin Le Grand alg at apache.org
Tue Nov 5 13:37:37 CET 2013


 cui/source/tabpages/tpbitmap.cxx                   |   33 ++++++++++++++-------
 drawinglayer/source/processor2d/vclprocessor2d.cxx |   15 +++++++--
 svx/source/xoutdev/xattrbmp.cxx                    |    6 ++-
 3 files changed, 38 insertions(+), 16 deletions(-)

New commits:
commit 36f21914b31a28f75ec2195c266424a18408f747
Author: Armin Le Grand <alg at apache.org>
Date:   Tue Oct 29 17:40:43 2013 +0000

    Resolves: i123564 corrected some aspects when working with bitmaps...
    
    with low color depth or small size
    
    (cherry picked from commit ba54ce4fc788605fc96235f432b455311faee406)
    
    Conflicts:
    	cui/source/tabpages/tpbitmap.cxx
    
    Change-Id: I10677414ab7d1904dbb29cd395a0c0334e0faa03

diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 17e89cb..89a51a8 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -354,29 +354,40 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl)
             Color aPixelColor = aFront;
             Color aBackColor = aBack;
 
-            m_pBitmapCtl->SetPixelColor( aPixelColor );
-            m_pBitmapCtl->SetBackgroundColor( aBackColor );
+            // #i123564# This causes the wrong color to be selected
+            // as foreground color when the 1st bitmap in the bitmap
+            // list is selected. I see no reason why this is done,
+            // thus I will take it out
+            //
+            //if( 0 == m_pLbBitmaps->GetSelectEntryPos() )
+            //{
+            //  m_pLbColor->SelectEntry( Color( COL_BLACK ) );
+            //  ChangePixelColorHdl_Impl( this );
+            //}
+            //else
+
+            m_pLbColor->SelectEntry( aPixelColor );
 
-            // if the entry is not in the listbox,
-            // the color is added temporarily
-            if( 0 == m_pLbBitmaps->GetSelectEntryPos() )
-            {
-                m_pLbColor->SelectEntry( Color( COL_BLACK ) );
-                ChangePixelColorHdl_Impl( this );
-            }
-            else
-                m_pLbColor->SelectEntry( aPixelColor );
             if( m_pLbColor->GetSelectEntryCount() == 0 )
             {
                 m_pLbColor->InsertEntry( aPixelColor, OUString() );
                 m_pLbColor->SelectEntry( aPixelColor );
             }
+
             m_pLbBackgroundColor->SelectEntry( aBackColor );
+
             if( m_pLbBackgroundColor->GetSelectEntryCount() == 0 )
             {
                 m_pLbBackgroundColor->InsertEntry( aBackColor, OUString() );
                 m_pLbBackgroundColor->SelectEntry( aBackColor );
             }
+
+            // update m_pBitmapCtl, rXFSet and m_pCtlPreview
+            m_pBitmapCtl->SetPixelColor( aPixelColor );
+            m_pBitmapCtl->SetBackgroundColor( aBackColor );
+            rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx())));
+            m_pCtlPreview->SetAttributes( aXFillAttr.GetItemSet() );
+            m_pCtlPreview->Invalidate();
         }
         else
         {
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index cf5289a..1cd768e 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -484,8 +484,9 @@ namespace drawinglayer
                             aGraphicRange.transform(mpOutputDevice->GetViewTransformation() * aLocalTransform);
 
                             // extract discrete size of graphic
-                            const sal_Int32 nBWidth(basegfx::fround(aGraphicRange.getWidth()));
-                            const sal_Int32 nBHeight(basegfx::fround(aGraphicRange.getHeight()));
+                            // caution: when getting to zero, nothing would be painted; thus, do not allow this
+                            const sal_Int32 nBWidth(std::max(sal_Int32(1), basegfx::fround(aGraphicRange.getWidth())));
+                            const sal_Int32 nBHeight(std::max(sal_Int32(1), basegfx::fround(aGraphicRange.getHeight())));
 
                             // only do something when bitmap fill has a size in discrete units
                             if(nBWidth > 0 && nBHeight > 0)
@@ -497,9 +498,17 @@ namespace drawinglayer
                                 static bool bEnablePreScaling(true);
                                 const bool bPreScaled(bEnablePreScaling && nBWidth * nBHeight < (250 * 250));
 
+                                // ... but only up to a maximum size, else it gets too expensive
                                 if(bPreScaled)
                                 {
-                                    // ... but only up to a maximum size, else it gets too expensive
+                                    // if color depth is below 24bit, expand before scaling for better quality.
+                                    // This is even needed for low colors, else the scale will produce
+                                    // a bitmap in gray or Black/White (!)
+                                    if(aBitmapEx.GetBitCount() < 24)
+                                    {
+                                        aBitmapEx.Convert(BMP_CONVERSION_24BIT);
+                                    }
+
                                     aBitmapEx.Scale(aNeededBitmapSizePixel, BMP_SCALE_INTERPOLATE);
                                 }
 
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 89d2261..e98c4d5 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -264,8 +264,10 @@ bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBa
                     {
                         const BitmapPalette& rPalette = pRead->GetPalette();
 
-                        o_rBack = rPalette[1];
-                        o_rFront = rPalette[0];
+                        // #i123564# bachground and foregrund were exchanged; of course
+                        // rPalette[0] is the background color
+                        o_rFront = rPalette[1];
+                        o_rBack = rPalette[0];
 
                         return true;
                     }


More information about the Libreoffice-commits mailing list