From 668dbfd99ada1888d5919cffedcfd7486c101717 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 26 Nov 2024 14:18:59 +0200 Subject: tdf#162815 Greyscale images not corrrectly exported to PDF regression from commit 21734247d58a6e915b058d8fa55ece949d049613 "drop internal support for 1-bit images" This only works on Linux because the HasGreyPaletteAny() check is returning false on Linux, because on linux the swap in/out is more aggressive, and after it is has gone through the swap in/out process, the image palette is no longer one that matches anything that HasGreyPaletteAny() checks for (it contains 256 entries, but only 2 of them are used) I'm not exactly sure why the greyscale bitmap generation code is generating bad PDF data, but the RGB code works great, so lets just use that rather. Change-Id: Ibb9e837540d5ed567c706e21e7ff93fe92118580 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177329 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/source/gdi/pdfwriter_impl.cxx | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'vcl') diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 71c097d6b36e..3665709fd42b 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -9738,37 +9738,6 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject, bool bMask ) aLine.append( "/ColorSpace" ); if( bTrueColor ) aLine.append( "/DeviceRGB\n" ); - else if( aBitmap.HasGreyPaletteAny() ) - { - aLine.append( "/DeviceGray\n" ); - if (aBitmap.getPixelFormat() == vcl::PixelFormat::N8_BPP) - { - // #i47395# 1 bit bitmaps occasionally have an inverted grey palette - sal_uInt16 nBlackIndex = pAccess->GetBestPaletteIndex( BitmapColor( COL_BLACK ) ); - assert( nBlackIndex == 0 || nBlackIndex == 1); - sal_uInt16 nWhiteIndex = pAccess->GetBestPaletteIndex( BitmapColor( COL_WHITE ) ); - if( pAccess->GetPalette()[nBlackIndex] == BitmapColor( COL_BLACK ) && - pAccess->GetPalette()[nWhiteIndex] == BitmapColor( COL_WHITE ) ) - { - // It is black and white - if( nBlackIndex == 1 ) - aLine.append( "/Decode[1 0]\n" ); - } - else - { - // It is two levels of grey - aLine.append( "/Decode[" ); - assert( pAccess->GetPalette()[0].GetRed() == pAccess->GetPalette()[0].GetGreen() && - pAccess->GetPalette()[0].GetRed() == pAccess->GetPalette()[0].GetBlue() && - pAccess->GetPalette()[1].GetRed() == pAccess->GetPalette()[1].GetGreen() && - pAccess->GetPalette()[1].GetRed() == pAccess->GetPalette()[1].GetBlue() ); - aLine.append( pAccess->GetPalette()[0].GetRed() / 255.0 ); - aLine.append( " " ); - aLine.append( pAccess->GetPalette()[1].GetRed() / 255.0 ); - aLine.append( "]\n" ); - } - } - } else { aLine.append( "[ /Indexed/DeviceRGB " ); -- cgit