BitmapEx->Bitmap in ThumbnailView

Now that Bitmap can handle transparency

Change-Id: I32ecfd63489afad3d0fcf39471c3d6f14a35afb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188792
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2025-08-02 13:33:03 +02:00
parent 5a130d91b2
commit 07fd24a4bd
6 changed files with 17 additions and 19 deletions
+2 -2
View File
@@ -150,11 +150,11 @@ public:
bool IsBuiltInRegion(const OUString& rRegionName);
static BitmapEx scaleImg (const BitmapEx &rImg, tools::Long width, tools::Long height);
static Bitmap scaleImg (const Bitmap &rImg, tools::Long width, tools::Long height);
static BitmapEx getDefaultThumbnail( std::u16string_view rPath );
static BitmapEx fetchThumbnail (const OUString &msURL, tools::Long width, tools::Long height);
static Bitmap fetchThumbnail (const OUString &msURL, tools::Long width, tools::Long height);
static bool IsDefaultTemplate(const OUString& rPath);
+2 -2
View File
@@ -18,7 +18,7 @@
#include <vcl/customweld.hxx>
class BitmapEx;
class Bitmap;
class ThumbnailViewItem;
typedef ::std::vector< ThumbnailViewItem* > ThumbnailValueItemList;
class ThumbnailViewAcc;
@@ -232,7 +232,7 @@ public:
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
static BitmapEx readThumbnail(const OUString &msURL);
static Bitmap readThumbnail(const OUString &msURL);
protected:
+3 -4
View File
@@ -242,10 +242,9 @@ public:
nothing had to be done, e.g. because one of the rectangles are
empty.
*/
SAL_DLLPRIVATE bool CopyPixel(
const tools::Rectangle& rRectDst,
const tools::Rectangle& rRectSrc,
const Bitmap& rBmpSrc );
bool CopyPixel( const tools::Rectangle& rRectDst,
const tools::Rectangle& rRectSrc,
const Bitmap& rBmpSrc );
/** Copy a rectangular area inside this bitmap.
+5 -6
View File
@@ -147,7 +147,7 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUStri
if (aTitle.isEmpty())
aTitle = aURLObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset);
BitmapEx aThumbnail;
Bitmap aThumbnail;
//fdo#74834: only load thumbnail if the corresponding option is not disabled in the configuration
if (officecfg::Office::Common::History::RecentDocsThumbnail::get())
@@ -159,20 +159,20 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUStri
SvMemoryStream aStream(aDecoded.getArray(), aDecoded.getLength(), StreamMode::READ);
vcl::PngImageReader aReader(aStream);
aThumbnail = aReader.read();
aThumbnail = Bitmap(aReader.read());
}
else if (sfx2::RecentDocsView::typeMatchesExtension(sfx2::ApplicationType::TYPE_DATABASE,
aURLObj.getExtension()))
{
aThumbnail
= BitmapEx(nThumbnailSize > 192 ? SFX_THUMBNAIL_BASE_256 : SFX_THUMBNAIL_BASE_192);
= Bitmap(BitmapEx(nThumbnailSize > 192 ? SFX_THUMBNAIL_BASE_256 : SFX_THUMBNAIL_BASE_192));
}
}
if (aThumbnail.IsEmpty())
{
// 1. Thumbnail absent: get the default thumbnail, checking for encryption.
BitmapEx aExt(getDefaultThumbnail(rURL));
Bitmap aExt(getDefaultThumbnail(rURL));
Size aExtSize(aExt.GetSizePixel());
// attempt to make it appear as if it is on a piece of paper
@@ -202,8 +202,7 @@ RecentDocsViewItem::RecentDocsViewItem(sfx2::RecentDocsView &rView, const OUStri
}
// create empty, and copy the default thumbnail in
sal_uInt8 nAlpha = 255;
aThumbnail = BitmapEx(Bitmap(aThumbnailSize, vcl::PixelFormat::N24_BPP), AlphaMask(aThumbnailSize, &nAlpha));
aThumbnail = Bitmap(aThumbnailSize, vcl::PixelFormat::N32_BPP);
aThumbnail.CopyPixel(
::tools::Rectangle(Point((aThumbnailSize.Width() - aExtSize.Width()) / 2, (aThumbnailSize.Height() - aExtSize.Height()) / 2), aExtSize),
+3 -3
View File
@@ -819,9 +819,9 @@ void TemplateLocalView::setExportTemplateHdl(const Link<void*,void> &rLink)
maExportTemplateHdl = rLink;
}
BitmapEx TemplateLocalView::scaleImg (const BitmapEx &rImg, tools::Long width, tools::Long height)
Bitmap TemplateLocalView::scaleImg (const Bitmap &rImg, tools::Long width, tools::Long height)
{
BitmapEx aImg = rImg;
Bitmap aImg = rImg;
if (!rImg.IsEmpty())
{
@@ -883,7 +883,7 @@ BitmapEx TemplateLocalView::getDefaultThumbnail( std::u16string_view rPath )
return aImg;
}
BitmapEx TemplateLocalView::fetchThumbnail (const OUString &msURL, tools::Long width, tools::Long height)
Bitmap TemplateLocalView::fetchThumbnail (const OUString &msURL, tools::Long width, tools::Long height)
{
return TemplateLocalView::scaleImg(ThumbnailView::readThumbnail(msURL), width, height);
}
+2 -2
View File
@@ -132,7 +132,7 @@ getFirstStreamByRelType(const OUString& URL, std::initializer_list<OUString> typ
return {};
}
BitmapEx ThumbnailView::readThumbnail(const OUString &msURL)
Bitmap ThumbnailView::readThumbnail(const OUString &msURL)
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -185,7 +185,7 @@ BitmapEx ThumbnailView::readThumbnail(const OUString &msURL)
// Note that the preview is returned without scaling it to the desired
// width. This gives the caller the chance to take advantage of a
// possibly larger resolution then was asked for.
return aThumbnail;
return Bitmap(aThumbnail);
}
ThumbnailView::ThumbnailView(std::unique_ptr<weld::ScrolledWindow> xWindow, std::unique_ptr<weld::Menu> xMenu)