diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-05 10:04:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-05 14:44:28 +0200 |
commit | 1c4cd77beeec3b40fb73afa8b77dbf897451a2aa (patch) | |
tree | c35cb2bf06a74581609d5f7a590735e260616748 | |
parent | 7b5f5d77d56ee494647d9e7868546b3f2140896e (diff) |
forms - move the Bitmap accessing code inside BitmapEx
Change-Id: I58d5200332c133146adb6bb99b4b88697f03990a
Reviewed-on: https://gerrit.libreoffice.org/55313
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | forms/source/component/imgprod.cxx | 82 | ||||
-rw-r--r-- | include/vcl/bitmapex.hxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 55 |
3 files changed, 81 insertions, 63 deletions
diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index 3b161e3d6d2c..0b55ecd942f1 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -329,71 +329,27 @@ void ImageProducer::ImplUpdateData( const Graphic& rGraphic ) void ImageProducer::ImplInitConsumer( const Graphic& rGraphic ) { - Bitmap aBmp( rGraphic.GetBitmapEx().GetBitmap() ); - BitmapReadAccess* pBmpAcc = aBmp.AcquireReadAccess(); - - if( pBmpAcc ) + sal_uInt32 nRMask = 0; + sal_uInt32 nGMask = 0; + sal_uInt32 nBMask = 0; + 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; - sal_uInt32 nRMask = 0; - 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; + elem->init( nWidth, nHeight ); + elem->setColorModel( nBitCount,aRGBPal, nRMask, nGMask, nBMask, nAMask ); } + + mbConsInit = true; } diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index b62c3cb5a2fa..e5656be11591 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -431,6 +431,13 @@ public: void AdjustTransparency( sal_uInt8 cTrans ); 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: SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetBitmapSalBitmap() const { return maBitmap.ImplGetSalBitmap(); } diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 3fb232e3c1c1..a369efe1ebf7 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -1444,4 +1444,59 @@ void BitmapEx::CombineMaskOr(Color maskColor, sal_uInt8 nTol) 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: */ |