[Libreoffice-commits] core.git: include/vcl vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 9 16:25:53 UTC 2021


 include/vcl/RawBitmap.hxx       |    6 ++++++
 vcl/source/filter/ipsd/ipsd.cxx |    9 +++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 520bb32555985c12642b40fad3b7dcac7a940585
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jun 9 15:24:19 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jun 9 18:25:10 2021 +0200

    tdf#142629 import psd image with transparent background
    
    regression from
        commit 2168d709805a847ac012ff87b06e081ca139d064
        Date:   Mon Feb 12 15:29:10 2018 +0200
        use RawBitmap in PSDReader
    
    Change-Id: I8d547d3cca7fb8fc90a8d9382e054b4d4b2f3519
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116916
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/RawBitmap.hxx b/include/vcl/RawBitmap.hxx
index 26e08dbdedac..b26d532a4032 100644
--- a/include/vcl/RawBitmap.hxx
+++ b/include/vcl/RawBitmap.hxx
@@ -49,6 +49,12 @@ public:
         if (mnBitCount == 32)
             mpData[p] = nColor.GetAlpha();
     }
+    void SetAlpha(tools::Long nY, tools::Long nX, sal_uInt8 nAlpha)
+    {
+        assert(mnBitCount == 32);
+        tools::Long p = (nY * maSize.getWidth() + nX) * (mnBitCount / 8) + 3;
+        mpData[p] = nAlpha;
+    }
     Color GetPixel(tools::Long nY, tools::Long nX) const
     {
         tools::Long p = (nY * maSize.getWidth() + nX) * mnBitCount / 8;
diff --git a/vcl/source/filter/ipsd/ipsd.cxx b/vcl/source/filter/ipsd/ipsd.cxx
index 6b96d742dae2..08e520884754 100644
--- a/vcl/source/filter/ipsd/ipsd.cxx
+++ b/vcl/source/filter/ipsd/ipsd.cxx
@@ -121,7 +121,7 @@ bool PSDReader::ReadPSD(Graphic & rGraphic )
     }
 
     Size aBitmapSize( mpFileHeader->nColumns, mpFileHeader->nRows );
-    mpBitmap.reset( new vcl::bitmap::RawBitmap( aBitmapSize, 24 ) );
+    mpBitmap.reset( new vcl::bitmap::RawBitmap( aBitmapSize, mbTransparent ? 32 : 24 ) );
     if ( mpPalette && mbStatus )
     {
         mvPalette.resize( 256 );
@@ -131,8 +131,9 @@ bool PSDReader::ReadPSD(Graphic & rGraphic )
         }
     }
 
-    if ((mnDestBitDepth == 1 || mnDestBitDepth == 8 || mbTransparent) && mvPalette.empty())
+    if ((mnDestBitDepth == 1 || mnDestBitDepth == 8) && mvPalette.empty())
     {
+        SAL_WARN("vcl", "no palette, but bit depth is " << mnDestBitDepth);
         mbStatus = false;
         return mbStatus;
     }
@@ -723,7 +724,7 @@ bool PSDReader::ImplReadBody()
                     m_rPSD.ReadUChar( nDummy );
                 for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ )
                 {
-                    mpBitmap->SetPixel(nY, nX, SanitizePaletteIndex(mvPalette, nDat));
+                    mpBitmap->SetAlpha(nY, nX, nDat ? 0 : 255);
                     if ( ++nX == mpFileHeader->nColumns )
                     {
                         nX = 0;
@@ -744,7 +745,7 @@ bool PSDReader::ImplReadBody()
                         nDat = 1;
                     if ( mpFileHeader->nDepth == 16 )   // 16 bit depth is to be skipped
                         m_rPSD.ReadUChar( nDummy );
-                    mpBitmap->SetPixel(nY, nX, SanitizePaletteIndex(mvPalette, nDat));
+                    mpBitmap->SetAlpha(nY, nX, nDat ? 0 : 255);
                     if ( ++nX == mpFileHeader->nColumns )
                     {
                         nX = 0;


More information about the Libreoffice-commits mailing list