diff --git a/cui/source/dialogs/tipofthedaydlg.cxx b/cui/source/dialogs/tipofthedaydlg.cxx index 86b84c688e8b..8424b58f55dc 100644 --- a/cui/source/dialogs/tipofthedaydlg.cxx +++ b/cui/source/dialogs/tipofthedaydlg.cxx @@ -233,10 +233,10 @@ void TipOfTheDayDialog::UpdateTip() RID_SVXBMP_TOTD_IMPRESS, RID_SVXBMP_TOTD_SOFFICE }; const OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); - BitmapEx aBmpEx; - ImageTree::get().loadImage(sModuleImage[nType], aIconTheme, aBmpEx, true, + Bitmap aBmp; + ImageTree::get().loadImage(sModuleImage[nType], aIconTheme, aBmp, true, ImageLoadFlags::IgnoreDarkTheme); - aGraphic = aBmpEx; + aGraphic = aBmp; } if (!aGraphic.IsAnimated()) diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index 27eeb24364f2..0587f53196a0 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -38,7 +38,7 @@ VCL_DLLPUBLIC lookup_table const & get_unpremultiply_table(); VCL_DLLPUBLIC sal_uInt8 unpremultiply(sal_uInt8 c, sal_uInt8 a); VCL_DLLPUBLIC sal_uInt8 premultiply(sal_uInt8 c, sal_uInt8 a); -BitmapEx VCL_DLLPUBLIC loadFromName(const OUString& rFileName, const ImageLoadFlags eFlags = ImageLoadFlags::NONE); +Bitmap VCL_DLLPUBLIC loadFromName(const OUString& rFileName, const ImageLoadFlags eFlags = ImageLoadFlags::NONE); void loadFromSvg(SvStream& rStream, const OUString& sPath, Bitmap& rBitmap, double fScaleFactor); diff --git a/include/vcl/ImageTree.hxx b/include/vcl/ImageTree.hxx index 4de20d74e935..e183f1090b94 100644 --- a/include/vcl/ImageTree.hxx +++ b/include/vcl/ImageTree.hxx @@ -48,7 +48,7 @@ namespace com::sun::star::io { } class ImplImageTree; -class BitmapEx; +class Bitmap; class SvMemoryStream; class ImageTree @@ -72,12 +72,12 @@ public: VCL_DLLPUBLIC bool loadImage( OUString const & name, OUString const & style, - BitmapEx & bitmap, bool localized, + Bitmap & bitmap, bool localized, const ImageLoadFlags eFlags = ImageLoadFlags::NONE); VCL_DLLPUBLIC bool loadImage( OUString const & name, OUString const & style, - BitmapEx & bitmap, bool localized, + Bitmap & bitmap, bool localized, sal_Int32 nScalePercentage, const ImageLoadFlags eFlags = ImageLoadFlags::NONE); diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index a92a437f7312..32d529d393fb 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -110,6 +110,7 @@ class SAL_WARN_UNUSED VCL_DLLPUBLIC Bitmap final public: Bitmap(); + Bitmap( const OUString& rIconName ); Bitmap( const Bitmap& rBitmap ); explicit Bitmap( const BitmapEx& rBitmapEx ); Bitmap( const Size& rSizePixel, vcl::PixelFormat ePixelFormat, const BitmapPalette* pPal = nullptr ); @@ -616,6 +617,7 @@ public: private: SAL_DLLPRIVATE bool ImplConvertUp(vcl::PixelFormat ePixelFormat, Color const* pExtColor = nullptr); SAL_DLLPRIVATE bool ImplConvertDown8BPP(Color const* pExtColor = nullptr); + SAL_DLLPRIVATE void loadFromIconTheme( const OUString& rIconName ); private: std::shared_ptr mxSalBmp; diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index feee3c29ab85..dc6d637eeb6b 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -468,8 +468,6 @@ private: const int nHeight, const int nStride); - SAL_DLLPRIVATE void loadFromIconTheme( const OUString& rIconName ); - Bitmap maBitmap; AlphaMask maAlphaMask; Size maBitmapSize; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index bc03847d97d9..a4a12a35878a 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6371,8 +6371,8 @@ static void lcl_paintBitmapExToRect(vcl::RenderContext *pOut, const Point& aPoin SwTaggedPDFHelper aTaggedPDFHelper( nullptr, nullptr, nullptr, *_pViewShell->GetOut() ); static tools::DeleteOnDeinit shadowMaskObj( - vcl::bitmap::loadFromName(BMP_PAGE_SHADOW_MASK, - ImageLoadFlags::IgnoreDarkTheme | ImageLoadFlags::IgnoreScalingFactor)); + BitmapEx(vcl::bitmap::loadFromName(BMP_PAGE_SHADOW_MASK, + ImageLoadFlags::IgnoreDarkTheme | ImageLoadFlags::IgnoreScalingFactor))); drawinglayer::primitive2d::DiscreteShadow& shadowMask = *shadowMaskObj.get(); static tools::DeleteOnDeinit< BitmapEx > aPageTopRightShadowObj {}; diff --git a/vcl/inc/imagerepository.hxx b/vcl/inc/imagerepository.hxx index 5e903a7378e2..5d82ee499497 100644 --- a/vcl/inc/imagerepository.hxx +++ b/vcl/inc/imagerepository.hxx @@ -21,7 +21,7 @@ #include -class BitmapEx; +class Bitmap; namespace vcl @@ -44,7 +44,7 @@ namespace vcl */ static bool loadImage( const OUString& _rName, - BitmapEx& _out_rImage + Bitmap& _out_rImage ); }; diff --git a/vcl/inc/implimagetree.hxx b/vcl/inc/implimagetree.hxx index 9ca076d44376..2f8b2a31cbc0 100644 --- a/vcl/inc/implimagetree.hxx +++ b/vcl/inc/implimagetree.hxx @@ -44,13 +44,13 @@ struct ImageRequestParameters { OUString msName; OUString msStyle; - BitmapEx& mrBitmap; + Bitmap& mrBitmap; bool mbLocalized; ImageLoadFlags meFlags; bool mbWriteImageToCache; sal_Int32 mnScalePercentage; - ImageRequestParameters(OUString aName, OUString aStyle, BitmapEx& rBitmap, bool bLocalized, + ImageRequestParameters(OUString aName, OUString aStyle, Bitmap& rBitmap, bool bLocalized, ImageLoadFlags eFlags, sal_Int32 nScalePercentage) : msName(std::move(aName)) , msStyle(std::move(aStyle)) @@ -82,7 +82,7 @@ public: bool loadImage( OUString const & name, OUString const & style, - BitmapEx & bitmap, bool localized, + Bitmap & bitmap, bool localized, const ImageLoadFlags eFlags, sal_Int32 nScalePercentage = -1); @@ -97,7 +97,7 @@ private: ImplImageTree(const ImplImageTree&) = delete; ImplImageTree& operator=(const ImplImageTree&) = delete; - typedef std::unordered_map> IconCache; + typedef std::unordered_map> IconCache; typedef std::unordered_map ScaledIconCache; typedef std::unordered_map IconLinkHash; diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx index 7723a05b703c..9c523eeceda7 100644 --- a/vcl/source/bitmap/BitmapEx.cxx +++ b/vcl/source/bitmap/BitmapEx.cxx @@ -82,25 +82,7 @@ BitmapEx::BitmapEx(Size aSize, vcl::PixelFormat ePixelFormat) BitmapEx::BitmapEx( const OUString& rIconName ) { - loadFromIconTheme( rIconName ); -} - -void BitmapEx::loadFromIconTheme( const OUString& rIconName ) -{ - bool bSuccess; - OUString aIconTheme; - - try - { - aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); - bSuccess = ImageTree::get().loadImage(rIconName, aIconTheme, *this, true); - } - catch (...) - { - bSuccess = false; - } - - SAL_WARN_IF( !bSuccess, "vcl", "BitmapEx::BitmapEx(): could not load image " << rIconName << " via icon theme " << aIconTheme); + operator=(Bitmap(rIconName)); } BitmapEx::BitmapEx( const Bitmap& rBmp ) : diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 5b36f9140893..24cda45d4bc0 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -49,15 +49,15 @@ using drawinglayer::primitive2d::Primitive2DReference; namespace vcl::bitmap { -BitmapEx loadFromName(const OUString& rFileName, const ImageLoadFlags eFlags) +Bitmap loadFromName(const OUString& rFileName, const ImageLoadFlags eFlags) { bool bSuccess = true; OUString aIconTheme; - BitmapEx aBitmapEx; + Bitmap aBitmap; try { aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); - ImageTree::get().loadImage(rFileName, aIconTheme, aBitmapEx, true, eFlags); + ImageTree::get().loadImage(rFileName, aIconTheme, aBitmap, true, eFlags); } catch (...) { @@ -66,7 +66,7 @@ BitmapEx loadFromName(const OUString& rFileName, const ImageLoadFlags eFlags) SAL_WARN_IF(!bSuccess, "vcl", "vcl::bitmap::loadFromName : could not load image " << rFileName << " via icon theme " << aIconTheme); - return aBitmapEx; + return aBitmap; } void loadFromSvg(SvStream& rStream, const OUString& sPath, Bitmap& rBitmap, double fScalingFactor) diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx index e8262657873e..7471778967f7 100644 --- a/vcl/source/bitmap/bitmap.cxx +++ b/vcl/source/bitmap/bitmap.cxx @@ -35,6 +35,7 @@ #include #endif #include +#include #include #include @@ -148,6 +149,29 @@ Bitmap::Bitmap(const BitmapEx& rBitmapEx) } } +Bitmap::Bitmap( const OUString& rIconName ) +{ + loadFromIconTheme( rIconName ); +} + +void Bitmap::loadFromIconTheme( const OUString& rIconName ) +{ + bool bSuccess; + OUString aIconTheme; + + try + { + aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); + bSuccess = ImageTree::get().loadImage(rIconName, aIconTheme, *this, true); + } + catch (...) + { + bSuccess = false; + } + + SAL_WARN_IF( !bSuccess, "vcl", "BitmapEx::BitmapEx(): could not load image " << rIconName << " via icon theme " << aIconTheme); +} + #ifdef DBG_UTIL namespace diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index 08873c8a40dd..daf4da518193 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -200,7 +200,7 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadRepositoryImage( std::u16string_view sPathName; if( o3tl::starts_with(rResourceURL, u"private:graphicrepository/", &sPathName) ) { - BitmapEx aBitmap; + Bitmap aBitmap; if ( vcl::ImageRepository::loadImage( OUString(sPathName), aBitmap ) ) { Graphic aGraphic(aBitmap); diff --git a/vcl/source/image/ImageRepository.cxx b/vcl/source/image/ImageRepository.cxx index 6bf57e699419..e30a3a24d7bc 100644 --- a/vcl/source/image/ImageRepository.cxx +++ b/vcl/source/image/ImageRepository.cxx @@ -25,7 +25,7 @@ namespace vcl { - bool ImageRepository::loadImage( const OUString& _rName, BitmapEx& _out_rImage ) + bool ImageRepository::loadImage( const OUString& _rName, Bitmap& _out_rImage ) { OUString sIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); diff --git a/vcl/source/image/ImageTree.cxx b/vcl/source/image/ImageTree.cxx index fdc47cbfe700..4d471151f44a 100644 --- a/vcl/source/image/ImageTree.cxx +++ b/vcl/source/image/ImageTree.cxx @@ -40,7 +40,7 @@ css::uno::Reference ImageTree::getImageXInputStream(OUStr } bool ImageTree::loadImage(OUString const & rName, OUString const & rStyle, - BitmapEx & rBitmap, bool bLocalized, + Bitmap & rBitmap, bool bLocalized, sal_Int32 nScalePercentage, const ImageLoadFlags eFlags) { @@ -48,7 +48,7 @@ bool ImageTree::loadImage(OUString const & rName, OUString const & rStyle, } bool ImageTree::loadImage(OUString const & rName, OUString const & rStyle, - BitmapEx & rBitmap, bool bLocalized, + Bitmap & rBitmap, bool bLocalized, const ImageLoadFlags eFlags) { return loadImage(rName, rStyle, rBitmap, bLocalized, -1, eFlags); diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx index 8cc049c13004..c47d04bad907 100644 --- a/vcl/source/image/ImplImage.cxx +++ b/vcl/source/image/ImplImage.cxx @@ -57,7 +57,7 @@ ImplImage::ImplImage(const GDIMetaFile& rMetaFile) bool ImplImage::loadStockAtScale(SalGraphics* pGraphics, Bitmap &rBitmap) { - BitmapEx aBitmapEx; + Bitmap aBitmap; ImageLoadFlags eScalingFlags = ImageLoadFlags::NONE; sal_Int32 nScalePercentage = -1; @@ -77,7 +77,7 @@ bool ImplImage::loadStockAtScale(SalGraphics* pGraphics, Bitmap &rBitmap) } #endif - if (!ImageTree::get().loadImage(maStockName, aIconTheme, aBitmapEx, true, + if (!ImageTree::get().loadImage(maStockName, aIconTheme, aBitmap, true, nScalePercentage, eScalingFlags)) { /* If the uno command has parameters, passed in from a toolbar, @@ -89,7 +89,7 @@ bool ImplImage::loadStockAtScale(SalGraphics* pGraphics, Bitmap &rBitmap) sal_Int32 nEnd = maStockName.lastIndexOf("."); OUString aFileName = maStockName.replaceAt(nStart, nEnd - nStart, u""); - if (!ImageTree::get().loadImage(aFileName, aIconTheme, aBitmapEx, true, + if (!ImageTree::get().loadImage(aFileName, aIconTheme, aBitmap, true, nScalePercentage, eScalingFlags)) { SAL_WARN_IF(!bOptional, "vcl", @@ -105,7 +105,7 @@ bool ImplImage::loadStockAtScale(SalGraphics* pGraphics, Bitmap &rBitmap) return false; } } - rBitmap = Bitmap(aBitmapEx); + rBitmap = aBitmap; return true; } diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx index 1232734f4e72..29587c07ba44 100644 --- a/vcl/source/image/ImplImageTree.cxx +++ b/vcl/source/image/ImplImageTree.cxx @@ -352,7 +352,7 @@ OUString ImplImageTree::fallbackStyle(std::u16string_view rsStyle) return sResult; } -bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, BitmapEx & rBitmap, bool localized, +bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, Bitmap & rBitmap, bool localized, const ImageLoadFlags eFlags, sal_Int32 nScalePercentage) { OUString aCurrentStyle(rStyle); diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 97f7f7208e51..74f1e034dfdb 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -263,23 +263,18 @@ static void CreateNetWmAppIcon( sal_uInt16 nIcon, NetWmIconData& netwm_icon ) else sIcon = SV_ICON_SIZE16[nIcon]; - BitmapEx aIcon = vcl::bitmap::loadFromName(sIcon, ImageLoadFlags::IgnoreScalingFactor); + Bitmap aIcon = vcl::bitmap::loadFromName(sIcon, ImageLoadFlags::IgnoreScalingFactor); if( aIcon.IsEmpty()) continue; - vcl::bitmap::convertBitmap32To24Plus8(aIcon, aIcon); - Bitmap icon = aIcon.GetBitmap(); - AlphaMask mask = aIcon.GetAlphaMask(); - BitmapScopedReadAccess iconData(icon); - BitmapScopedReadAccess maskData(mask); + BitmapScopedReadAccess iconData(aIcon); netwm_icon[ pos++ ] = size; // width netwm_icon[ pos++ ] = size; // height for( int y = 0; y < size; ++y ) for( int x = 0; x < size; ++x ) { BitmapColor col = iconData->GetColor( y, x ); - BitmapColor alpha = maskData->GetColor( y, x ); - netwm_icon[ pos++ ] = (((( 255 - alpha.GetBlue()) * 256U ) + col.GetRed()) * 256 + col.GetGreen()) * 256 + col.GetBlue(); + netwm_icon[ pos++ ] = (((( 255 - col.GetAlpha()) * 256U ) + col.GetRed()) * 256 + col.GetGreen()) * 256 + col.GetBlue(); } } netwm_icon.resize( pos );