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

Caolán McNamara caolanm at redhat.com
Tue Feb 14 10:30:12 UTC 2017


 filter/source/graphicfilter/iras/iras.cxx |   29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

New commits:
commit d06646ca28851e5d289d43b4a1e04b1350747695
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 14 10:28:19 2017 +0000

    move allocation of bmp to after reading palette
    
    Change-Id: Ib54e0b3f3fae2c2e76cf49e03dceab2259b26b92

diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index 0836ac5..21e554f 100644
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ b/filter/source/graphicfilter/iras/iras.cxx
@@ -96,15 +96,11 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
     if ( !mbStatus )
         return false;
 
-    Bitmap aBmp(Size(mnWidth, mnHeight), mnDstBitsPerPix);
-    Bitmap::ScopedWriteAccess pAcc(aBmp);
-    if ( pAcc == nullptr )
-        return false;
+    bool bPalette(false);
+    BitmapPalette aPalette;
 
     if ( mnDstBitsPerPix <= 8 )     // paletten bildchen
     {
-        bool bPalette(false);
-
         if ( mnColorMapType == RAS_COLOR_RAW_MAP )      // RAW Colormap wird geskipped
         {
             sal_uLong nCurPos = m_rRAS.Tell();
@@ -119,7 +115,7 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
 
             if ( ( mnDstColors >= 2 ) && ( ( mnColorMapSize % 3 ) == 0 ) )
             {
-                pAcc->SetPaletteEntryCount( mnDstColors );
+                aPalette.SetEntryCount(mnDstColors);
                 sal_uInt16  i;
                 sal_uInt8   nRed[256], nGreen[256], nBlue[256];
                 for ( i = 0; i < mnDstColors; i++ ) m_rRAS.ReadUChar( nRed[ i ] );
@@ -127,7 +123,7 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
                 for ( i = 0; i < mnDstColors; i++ ) m_rRAS.ReadUChar( nBlue[ i ] );
                 for ( i = 0; i < mnDstColors; i++ )
                 {
-                    pAcc->SetPaletteColor( i, BitmapColor( nRed[ i ], nGreen[ i ], nBlue[ i ] ) );
+                    aPalette[i] = BitmapColor(nRed[ i ], nGreen[ i ], nBlue[ i ]);
                 }
                 bPalette = true;
             }
@@ -138,15 +134,16 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
         else if ( mnColorMapType != RAS_COLOR_NO_MAP )  // alles andere ist kein standard
             return false;
 
-        if ( !bPalette )
+        if (!bPalette)
         {
             mnDstColors = 1 << mnDstBitsPerPix;
-            pAcc->SetPaletteEntryCount( mnDstColors );
+            aPalette.SetEntryCount(mnDstColors);
             for ( sal_uInt16 i = 0; i < mnDstColors; i++ )
             {
                 sal_uLong nCount = 255 - ( 255 * i / ( mnDstColors - 1 ) );
-                pAcc->SetPaletteColor( i, BitmapColor( (sal_uInt8)nCount, (sal_uInt8)nCount, (sal_uInt8)nCount ) );
+                aPalette[i] = BitmapColor((sal_uInt8)nCount, (sal_uInt8)nCount, (sal_uInt8)nCount);
             }
+            bPalette = true;
         }
     }
     else
@@ -158,6 +155,16 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
         }
     }
 
+    Bitmap aBmp(Size(mnWidth, mnHeight), mnDstBitsPerPix);
+    Bitmap::ScopedWriteAccess pAcc(aBmp);
+    if (pAcc == nullptr)
+        return false;
+
+    if (bPalette)
+    {
+        pAcc->SetPalette(aPalette);
+    }
+
     // Bitmap-Daten einlesen
     mbStatus = ImplReadBody(pAcc.get());
 


More information about the Libreoffice-commits mailing list