BitmapEx->Bitmap in forms
since Bitmap can handle transparency now. Drop some code - we no longer have images with palettes and transparency Change-Id: I480765e0e402e67485a53c660e1179a9d7c5b153 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190282 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -222,7 +222,7 @@ void ImageProducer::ImplInitConsumer( const Graphic& rGraphic )
|
||||
sal_uInt32 nHeight = 0;
|
||||
sal_uInt8 nBitCount = 0;
|
||||
css::uno::Sequence< sal_Int32 > aRGBPal;
|
||||
rGraphic.GetBitmapEx().GetColorModel(aRGBPal, nRMask, nGMask, nBMask, nAMask, mnTransIndex, nWidth, nHeight, nBitCount);
|
||||
rGraphic.GetBitmap().GetColorModel(aRGBPal, nRMask, nGMask, nBMask, nAMask, mnTransIndex, nWidth, nHeight, nBitCount);
|
||||
|
||||
// create temporary list to hold interfaces
|
||||
ConsumerList_t aTmp = maConsList;
|
||||
@@ -240,17 +240,11 @@ void ImageProducer::ImplInitConsumer( const Graphic& rGraphic )
|
||||
|
||||
void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
|
||||
{
|
||||
BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
|
||||
const Bitmap& aBmp( aBmpEx.GetBitmap() );
|
||||
Bitmap aBmp( rGraphic.GetBitmap() );
|
||||
BitmapScopedReadAccess pBmpAcc(aBmp);
|
||||
|
||||
if( !pBmpAcc )
|
||||
return;
|
||||
|
||||
AlphaMask aMask( aBmpEx.GetAlphaMask() );
|
||||
BitmapScopedReadAccess pMskAcc;
|
||||
if (!aMask.IsEmpty())
|
||||
pMskAcc = aMask;
|
||||
const tools::Long nWidth = pBmpAcc->Width();
|
||||
const tools::Long nHeight = pBmpAcc->Height();
|
||||
const tools::Long nStartX = 0;
|
||||
@@ -260,20 +254,11 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
|
||||
const tools::Long nPartWidth = nEndX - nStartX + 1;
|
||||
const tools::Long nPartHeight = nEndY - nStartY + 1;
|
||||
|
||||
if( !pMskAcc )
|
||||
{
|
||||
aMask = AlphaMask(aBmp.GetSizePixel());
|
||||
aMask.Erase( 0 );
|
||||
pMskAcc = aMask;
|
||||
}
|
||||
|
||||
// create temporary list to hold interfaces
|
||||
ConsumerList_t aTmp = maConsList;
|
||||
|
||||
if( pBmpAcc->HasPalette() )
|
||||
{
|
||||
const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_ALPHA_TRANSPARENT ) );
|
||||
|
||||
if( mnTransIndex < 256 )
|
||||
{
|
||||
css::uno::Sequence<sal_Int8> aData( nPartWidth * nPartHeight );
|
||||
@@ -281,16 +266,9 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
|
||||
|
||||
for( tools::Long nY = nStartY; nY <= nEndY; nY++ )
|
||||
{
|
||||
Scanline pScanlineMask = pMskAcc->GetScanline( nY );
|
||||
Scanline pScanline = pBmpAcc->GetScanline( nY );
|
||||
for( tools::Long nX = nStartX; nX <= nEndX; nX++ )
|
||||
{
|
||||
if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == aWhite )
|
||||
*pTmp++ = sal::static_int_cast< sal_Int8 >(
|
||||
mnTransIndex );
|
||||
else
|
||||
*pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex();
|
||||
}
|
||||
*pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex();
|
||||
}
|
||||
|
||||
// iterate through interfaces
|
||||
@@ -304,15 +282,9 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
|
||||
|
||||
for( tools::Long nY = nStartY; nY <= nEndY; nY++ )
|
||||
{
|
||||
Scanline pScanlineMask = pMskAcc->GetScanline( nY );
|
||||
Scanline pScanline = pBmpAcc->GetScanline( nY );
|
||||
for( tools::Long nX = nStartX; nX <= nEndX; nX++ )
|
||||
{
|
||||
if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == aWhite )
|
||||
*pTmp++ = mnTransIndex;
|
||||
else
|
||||
*pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex();
|
||||
}
|
||||
*pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex();
|
||||
}
|
||||
|
||||
// iterate through interfaces
|
||||
@@ -323,12 +295,10 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
|
||||
else
|
||||
{
|
||||
css::uno::Sequence<sal_Int32> aData( nPartWidth * nPartHeight );
|
||||
const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_WHITE ) );
|
||||
sal_Int32* pTmp = aData.getArray();
|
||||
|
||||
for( tools::Long nY = nStartY; nY <= nEndY; nY++ )
|
||||
{
|
||||
Scanline pScanlineMask = pMskAcc->GetScanline( nY );
|
||||
Scanline pScanline = pBmpAcc->GetScanline( nY );
|
||||
for( tools::Long nX = nStartX; nX <= nEndX; nX++, pTmp++ )
|
||||
{
|
||||
@@ -338,7 +308,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
|
||||
*pTmp |= static_cast<sal_Int32>(aCol.GetGreen()) << 16;
|
||||
*pTmp |= static_cast<sal_Int32>(aCol.GetBlue()) << 8;
|
||||
|
||||
if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) != aWhite )
|
||||
if( aCol.GetAlpha() != 0 )
|
||||
*pTmp |= 0x000000ffUL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <vcl/bitmap/BitmapTypes.hxx>
|
||||
|
||||
#include <o3tl/typed_flags_set.hxx>
|
||||
#include <com/sun/star/uno/Sequence.hxx>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
@@ -598,6 +599,13 @@ public:
|
||||
|
||||
void CombineMaskOr(Color maskColor, sal_uInt8 nTol);
|
||||
|
||||
/**
|
||||
* Retrieves the color model data we need for the XImageConsumer stuff.
|
||||
*/
|
||||
void GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
|
||||
sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex,
|
||||
sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount);
|
||||
|
||||
/** Remove existing blending against COL_WHITE based on given AlphaMask
|
||||
|
||||
Inside convertToBitmapEx the content gets rendered to RGB target (no 'A'),
|
||||
|
||||
@@ -2397,4 +2397,51 @@ void Bitmap::CombineMaskOr(Color rTransColor, sal_uInt8 nTol)
|
||||
maPrefSize = aSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the color model data we need for the XImageConsumer stuff.
|
||||
*/
|
||||
void Bitmap::GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
|
||||
sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex,
|
||||
sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount)
|
||||
{
|
||||
BitmapScopedReadAccess pReadAccess( *this );
|
||||
assert( pReadAccess );
|
||||
|
||||
if( pReadAccess->HasPalette() )
|
||||
{
|
||||
sal_uInt16 nPalCount = pReadAccess->GetPaletteEntryCount();
|
||||
|
||||
if( nPalCount )
|
||||
{
|
||||
rRGBPalette = css::uno::Sequence< sal_Int32 >( nPalCount + 1 );
|
||||
|
||||
sal_Int32* pTmp = rRGBPalette.getArray();
|
||||
|
||||
for( sal_uInt32 i = 0; i < nPalCount; i++, pTmp++ )
|
||||
{
|
||||
const BitmapColor& rCol = pReadAccess->GetPaletteColor( static_cast<sal_uInt16>(i) );
|
||||
|
||||
*pTmp = static_cast<sal_Int32>(rCol.GetRed()) << sal_Int32(24);
|
||||
*pTmp |= static_cast<sal_Int32>(rCol.GetGreen()) << sal_Int32(16);
|
||||
*pTmp |= static_cast<sal_Int32>(rCol.GetBlue()) << sal_Int32(8);
|
||||
*pTmp |= sal_Int32(0x000000ffL);
|
||||
}
|
||||
|
||||
rnTransparencyIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rnRedMask = 0xff000000UL;
|
||||
rnGreenMask = 0x00ff0000UL;
|
||||
rnBlueMask = 0x0000ff00UL;
|
||||
rnAlphaMask = 0x000000ffUL;
|
||||
rnTransparencyIndex = 0;
|
||||
}
|
||||
|
||||
rnWidth = pReadAccess->Width();
|
||||
rnHeight = pReadAccess->Height();
|
||||
rnBitCount = pReadAccess->GetBitCount();
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user