You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2013/10/29 18:40:44 UTC

svn commit: r1536830 - in /openoffice/trunk/main: cui/source/tabpages/tpbitmap.cxx drawinglayer/source/processor2d/vclprocessor2d.cxx svx/source/xoutdev/xattrbmp.cxx

Author: alg
Date: Tue Oct 29 17:40:43 2013
New Revision: 1536830

URL: http://svn.apache.org/r1536830
Log:
i123564 corrected some aspects when working whith bitmaps with low color depth or small size

Modified:
    openoffice/trunk/main/cui/source/tabpages/tpbitmap.cxx
    openoffice/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx
    openoffice/trunk/main/svx/source/xoutdev/xattrbmp.cxx

Modified: openoffice/trunk/main/cui/source/tabpages/tpbitmap.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cui/source/tabpages/tpbitmap.cxx?rev=1536830&r1=1536829&r2=1536830&view=diff
==============================================================================
--- openoffice/trunk/main/cui/source/tabpages/tpbitmap.cxx (original)
+++ openoffice/trunk/main/cui/source/tabpages/tpbitmap.cxx Tue Oct 29 17:40:43 2013
@@ -397,30 +397,41 @@ IMPL_LINK( SvxBitmapTabPage, ChangeBitma
 			Color aPixelColor = aFront;
 			Color aBackColor = aBack;
 
-			aBitmapCtl.SetPixelColor( aPixelColor );
-			aBitmapCtl.SetBackgroundColor( aBackColor );
-
-			// Wenn der Eintrag nicht in der Listbox ist, wird die Farbe
-			// temporaer hinzugenommen
-			if( 0 == aLbBitmaps.GetSelectEntryPos() )
-			{
-				aLbColor.SelectEntry( Color( COL_BLACK ) );
-				ChangePixelColorHdl_Impl( this );
-			}
-			else
-				aLbColor.SelectEntry( aPixelColor );
-			if( aLbColor.GetSelectEntryCount() == 0 )
-			{
-				aLbColor.InsertEntry( aPixelColor, String() );
-				aLbColor.SelectEntry( aPixelColor );
-			}
-			aLbBackgroundColor.SelectEntry( aBackColor );
-			if( aLbBackgroundColor.GetSelectEntryCount() == 0 )
-			{
-				aLbBackgroundColor.InsertEntry( aBackColor, String() );
-				aLbBackgroundColor.SelectEntry( aBackColor );
-			}
-		}
+            // #123564# 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 == aLbBitmaps.GetSelectEntryPos() )
+            //{
+            //	aLbColor.SelectEntry( Color( COL_BLACK ) );
+            //	ChangePixelColorHdl_Impl( this );
+            //}
+            //else
+
+            aLbColor.SelectEntry( aPixelColor );
+
+            if( aLbColor.GetSelectEntryCount() == 0 )
+            {
+                aLbColor.InsertEntry( aPixelColor, String() );
+                aLbColor.SelectEntry( aPixelColor );
+            }
+
+            aLbBackgroundColor.SelectEntry( aBackColor );
+
+            if( aLbBackgroundColor.GetSelectEntryCount() == 0 )
+            {
+                aLbBackgroundColor.InsertEntry( aBackColor, String() );
+                aLbBackgroundColor.SelectEntry( aBackColor );
+            }
+
+            // update aBitmapCtl, rXFSet and aCtlPreview
+            aBitmapCtl.SetPixelColor( aPixelColor );
+            aBitmapCtl.SetBackgroundColor( aBackColor );
+            rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
+            aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
+            aCtlPreview.Invalidate();
+        }
         else
 		{
 			aCtlPixel.Reset();

Modified: openoffice/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx?rev=1536830&r1=1536829&r2=1536830&view=diff
==============================================================================
--- openoffice/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx (original)
+++ openoffice/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx Tue Oct 29 17:40:43 2013
@@ -470,8 +470,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)
@@ -483,9 +484,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);
                                 }
 

Modified: openoffice/trunk/main/svx/source/xoutdev/xattrbmp.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/xoutdev/xattrbmp.cxx?rev=1536830&r1=1536829&r2=1536830&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/xoutdev/xattrbmp.cxx (original)
+++ openoffice/trunk/main/svx/source/xoutdev/xattrbmp.cxx Tue Oct 29 17:40:43 2013
@@ -129,10 +129,12 @@ bool SVX_DLLPUBLIC isHistorical8x8(const
                     if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount())
                     {
                         const BitmapPalette& rPalette = pRead->GetPalette();
-                        
-                        o_rBack = rPalette[1];
-                        o_rFront = rPalette[0];
-                       
+
+                        // #123564# bachground and foregrund were exchanged; of course
+                        // rPalette[0] is the background color
+                        o_rFront = rPalette[1];
+                        o_rBack = rPalette[0];
+
                         return true;
                     }
                 }