vcl/source/filter/png/PngImageWriter.cxx |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 219a6b035572374ab9ef1def52883f856c5ad049
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Sep 3 08:35:46 2025 +0200
Commit:     Noel Grandin <noelgran...@gmail.com>
CommitDate: Wed Sep 3 11:32:56 2025 +0200

    more asserts in pngWrite
    
    just to catch anything I might have missed
    
    Change-Id: I53aa4a6b6bb70d1f7443673ed5cdc477549da329
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190549
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/vcl/source/filter/png/PngImageWriter.cxx 
b/vcl/source/filter/png/PngImageWriter.cxx
index 455c1c1710f9..be7023804e92 100644
--- a/vcl/source/filter/png/PngImageWriter.cxx
+++ b/vcl/source/filter/png/PngImageWriter.cxx
@@ -20,11 +20,8 @@ namespace
 {
 void combineScanlineChannels(BitmapScopedReadAccess& pAccess, Scanline 
pScanline,
                              std::vector<std::remove_pointer_t<Scanline>>& 
pResult,
-                             sal_uInt32 nBitmapWidth, int colorType)
+                             sal_uInt32 nBitmapWidth)
 {
-    assert(colorType != PNG_COLOR_TYPE_GRAY_ALPHA);
-    (void)colorType;
-
     for (sal_uInt32 i = 0; i < nBitmapWidth; ++i)
     {
         BitmapColor aCol = pAccess->GetPixelFromData(pScanline, i);
@@ -182,6 +179,7 @@ static bool pngWrite(SvStream& rStream, const Graphic& 
rGraphic, int nCompressio
             case ScanlineFormat::N1BitMsbPal:
             {
                 assert(!aBitmap.HasAlpha());
+                assert(pAccess->HasPalette());
                 colorType = PNG_COLOR_TYPE_PALETTE;
                 bitDepth = 1;
                 break;
@@ -189,10 +187,11 @@ static bool pngWrite(SvStream& rStream, const Graphic& 
rGraphic, int nCompressio
             case ScanlineFormat::N8BitPal:
             {
                 assert(!aBitmap.HasAlpha());
+                assert(pAccess->HasPalette());
                 // Calling aBitmap.HasGreyPalette8Bit() hits an assert when
                 // using Skia in a debug build so query the palette through
                 // the bitmap read access object.
-                if (!pAccess->HasPalette() || 
!pAccess->GetPalette().IsGreyPalette8Bit())
+                if (!pAccess->GetPalette().IsGreyPalette8Bit())
                     colorType = PNG_COLOR_TYPE_PALETTE;
                 else
                     colorType = PNG_COLOR_TYPE_GRAY;
@@ -247,6 +246,7 @@ static bool pngWrite(SvStream& rStream, const Graphic& 
rGraphic, int nCompressio
             }
             default:
             {
+                assert(false);
                 return false;
             }
         }
@@ -347,7 +347,7 @@ static bool pngWrite(SvStream& rStream, const Graphic& 
rGraphic, int nCompressio
                     aCombinedChannels.resize(nBitmapWidth * 
png_get_channels(pPng, pInfo));
                     // Combine color and alpha channels
                     combineScanlineChannels(pAccess, pSourcePointer, 
aCombinedChannels,
-                                            nBitmapWidth, colorType);
+                                            nBitmapWidth);
                     pFinalPointer = aCombinedChannels.data();
                 }
                 png_write_row(pPng, pFinalPointer);

Reply via email to