tdf#162815 Greyscale images not corrrectly exported to PDF
regression from commit 21734247d5
"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 <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
2af9fcddba
commit
668dbfd99a
@@ -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 " );
|
||||
|
||||
Reference in New Issue
Block a user