Kaydet (Commit) 1c4cd77b authored tarafından Noel Grandin's avatar Noel Grandin

forms - move the Bitmap accessing code inside BitmapEx

Change-Id: I58d5200332c133146adb6bb99b4b88697f03990a
Reviewed-on: https://gerrit.libreoffice.org/55313Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7b5f5d77
...@@ -329,71 +329,27 @@ void ImageProducer::ImplUpdateData( const Graphic& rGraphic ) ...@@ -329,71 +329,27 @@ void ImageProducer::ImplUpdateData( const Graphic& rGraphic )
void ImageProducer::ImplInitConsumer( const Graphic& rGraphic ) void ImageProducer::ImplInitConsumer( const Graphic& rGraphic )
{ {
Bitmap aBmp( rGraphic.GetBitmapEx().GetBitmap() ); sal_uInt32 nRMask = 0;
BitmapReadAccess* pBmpAcc = aBmp.AcquireReadAccess(); sal_uInt32 nGMask = 0;
sal_uInt32 nBMask = 0;
if( pBmpAcc ) sal_uInt32 nAMask = 0;
sal_uInt32 nWidth = 0;
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);
// create temporary list to hold interfaces
ConsumerList_t aTmp = maConsList;
// iterate through interfaces
for (auto const& elem : aTmp)
{ {
sal_uInt16 nPalCount = 0; elem->init( nWidth, nHeight );
sal_uInt32 nRMask = 0; elem->setColorModel( nBitCount,aRGBPal, nRMask, nGMask, nBMask, nAMask );
sal_uInt32 nGMask = 0;
sal_uInt32 nBMask = 0;
sal_uInt32 nAMask = 0;
css::uno::Sequence< sal_Int32 > aRGBPal;
if( pBmpAcc->HasPalette() )
{
nPalCount = pBmpAcc->GetPaletteEntryCount();
if( nPalCount )
{
aRGBPal = css::uno::Sequence< sal_Int32 >( nPalCount + 1 );
sal_Int32* pTmp = aRGBPal.getArray();
for( sal_uInt32 i = 0; i < nPalCount; i++, pTmp++ )
{
const BitmapColor& rCol = pBmpAcc->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);
}
if( rGraphic.IsTransparent() )
{
// append transparent entry
*pTmp = sal_Int32(0xffffff00L);
mnTransIndex = nPalCount;
nPalCount++;
}
else
mnTransIndex = 0;
}
}
else
{
nRMask = 0xff000000UL;
nGMask = 0x00ff0000UL;
nBMask = 0x0000ff00UL;
nAMask = 0x000000ffUL;
}
// create temporary list to hold interfaces
ConsumerList_t aTmp = maConsList;
// iterate through interfaces
for (auto const& elem : aTmp)
{
elem->init( pBmpAcc->Width(), pBmpAcc->Height() );
elem->setColorModel( pBmpAcc->GetBitCount(),aRGBPal, nRMask, nGMask, nBMask, nAMask );
}
Bitmap::ReleaseAccess( pBmpAcc );
mbConsInit = true;
} }
mbConsInit = true;
} }
......
...@@ -431,6 +431,13 @@ public: ...@@ -431,6 +431,13 @@ public:
void AdjustTransparency( sal_uInt8 cTrans ); void AdjustTransparency( sal_uInt8 cTrans );
void CombineMaskOr(Color maskColor, sal_uInt8 nTol); 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);
public: public:
SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetBitmapSalBitmap() const { return maBitmap.ImplGetSalBitmap(); } SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetBitmapSalBitmap() const { return maBitmap.ImplGetSalBitmap(); }
......
...@@ -1444,4 +1444,59 @@ void BitmapEx::CombineMaskOr(Color maskColor, sal_uInt8 nTol) ...@@ -1444,4 +1444,59 @@ void BitmapEx::CombineMaskOr(Color maskColor, sal_uInt8 nTol)
meTransparent = TransparentType::Bitmap; meTransparent = TransparentType::Bitmap;
} }
/**
* Retrieves the color model data we need for the XImageConsumer stuff.
*/
void BitmapEx::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)
{
Bitmap::ScopedReadAccess pReadAccess( maBitmap );
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);
}
if( IsTransparent() )
{
// append transparent entry
*pTmp = sal_Int32(0xffffff00L);
rnTransparencyIndex = nPalCount;
nPalCount++;
}
else
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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment