summaryrefslogtreecommitdiff
path: root/vcl/source/image
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-12 11:11:13 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-04-12 13:56:53 +0200
commit812f0a83d223cddf00b121db40ca7ff91c22ccfa (patch)
tree8137fdfbac1f3c50bcd5b55ef66cd036aef0e455 /vcl/source/image
parented437865a0db175e45ff421d50f429dff421d0cf (diff)
internally resize image instead of scaling bitmaps outside
When we want a different size Image, we can now set that as a parameter at construction of the Image. Previously we needed to create an Image, forcefully take the bitmap out, resize the bitmap and create a new Image out of that. Doing it internally gives us the benefit to have a more control over the scaling process, especially when dealing with HiDPI images. Change-Id: I104118f4d863d519cc7aad1a17ca0289c01ed9ff Reviewed-on: https://gerrit.libreoffice.org/70617 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source/image')
-rw-r--r--vcl/source/image/Image.cxx6
-rw-r--r--vcl/source/image/ImplImage.cxx13
2 files changed, 13 insertions, 6 deletions
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index e52583b99bd9..4316f9145a16 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -60,7 +60,7 @@ Image::Image(const OUString & rFileUrl)
OUString sImageName;
if (rFileUrl.startsWith("private:graphicrepository/", &sImageName))
{
- mpImplData = std::make_shared<ImplImage>(sImageName);
+ mpImplData = std::make_shared<ImplImage>(sImageName, Size());
}
else
{
@@ -72,8 +72,8 @@ Image::Image(const OUString & rFileUrl)
}
}
-Image::Image(StockImage, const OUString & rFileUrl)
- : mpImplData(std::make_shared<ImplImage>(rFileUrl))
+Image::Image(StockImage, const OUString & rFileUrl, Size aSpecificSize)
+ : mpImplData(std::make_shared<ImplImage>(rFileUrl, aSpecificSize))
{
}
diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx
index 95d605e47173..7605f88d9767 100644
--- a/vcl/source/image/ImplImage.cxx
+++ b/vcl/source/image/ImplImage.cxx
@@ -39,14 +39,16 @@
ImplImage::ImplImage(const BitmapEx &rBitmapEx)
: maBitmapChecksum(0)
, maSizePixel(rBitmapEx.GetSizePixel())
+ , maPreferedSizePixel()
, maBitmapEx(rBitmapEx)
{
}
-ImplImage::ImplImage(const OUString &aStockName)
+ImplImage::ImplImage(const OUString &aStockName, Size const & rPreferedSize)
: maBitmapChecksum(0)
- , maSizePixel(0,0) // defer size lookup
- , maStockName( aStockName )
+ , maSizePixel() // defer size lookup
+ , maPreferedSizePixel(rPreferedSize)
+ , maStockName(aStockName)
{
}
@@ -61,6 +63,11 @@ bool ImplImage::loadStockAtScale(double fScale, BitmapEx &rBitmapEx)
SAL_WARN("vcl", "Failed to load scaled image from " << maStockName << " at " << fScale);
return false;
}
+ if (maPreferedSizePixel != Size())
+ {
+ Size aScaleSize(maPreferedSizePixel.Width() * fScale, maPreferedSizePixel.Height() * fScale);
+ aBitmapEx.Scale(aScaleSize);
+ }
rBitmapEx = aBitmapEx;
return true;
}