summaryrefslogtreecommitdiff
path: root/vcl/source/image/Image.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/image/Image.cxx')
-rw-r--r--vcl/source/image/Image.cxx106
1 files changed, 38 insertions, 68 deletions
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index 049e3bef5d0d..8bce4839a1ea 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -58,17 +58,11 @@ Image::Image(const OUString & rFileUrl)
sal_Int32 nIndex = 0;
if (rFileUrl.getToken( 0, '/', nIndex ) == "private:graphicrepository")
{
- OUString sPathName(rFileUrl.copy(nIndex));
- BitmapEx aBitmapEx;
- if (vcl::ImageRepository::loadImage(sPathName, aBitmapEx))
- {
- ImplInit(aBitmapEx);
- }
+ mpImplData.reset(new ImplImage(rFileUrl.copy(nIndex)));
}
else
{
Graphic aGraphic;
-
if (ERRCODE_NONE == GraphicFilter::LoadGraphic(rFileUrl, IMP_PNG, aGraphic))
{
ImplInit(aGraphic.GetBitmapEx());
@@ -79,33 +73,23 @@ Image::Image(const OUString & rFileUrl)
void Image::ImplInit(const BitmapEx& rBitmapEx)
{
if (!rBitmapEx.IsEmpty())
- {
mpImplData.reset(new ImplImage(rBitmapEx));
- }
}
Size Image::GetSizePixel() const
{
- Size aRet;
-
if (mpImplData)
- {
- aRet = mpImplData->maBitmapEx.GetSizePixel();
- }
-
- return aRet;
+ return mpImplData->getSizePixel();
+ else
+ return Size();
}
BitmapEx Image::GetBitmapEx() const
{
- BitmapEx aRet;
-
if (mpImplData)
- {
- aRet = mpImplData->maBitmapEx;
- }
-
- return aRet;
+ return mpImplData->getBitmapEx();
+ else
+ return BitmapEx();
}
bool Image::operator==(const Image& rImage) const
@@ -117,7 +101,7 @@ bool Image::operator==(const Image& rImage) const
else if (!rImage.mpImplData || !mpImplData)
bRet = false;
else
- bRet = rImage.mpImplData->maBitmapEx == mpImplData->maBitmapEx;
+ bRet = rImage.mpImplData->isEqual(*mpImplData);
return bRet;
}
@@ -128,63 +112,49 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
return;
const Point aSrcPos(0, 0);
- Size aBitmapSizePixel = mpImplData->maBitmapEx.GetSizePixel();
+ Size aBitmapSizePixel = mpImplData->getSizePixel();
Size aOutSize = pSize ? *pSize : pOutDev->PixelToLogic(aBitmapSizePixel);
- if (nStyle & DrawImageFlags::Disable)
- {
- BitmapChecksum aChecksum = mpImplData->maBitmapEx.GetChecksum();
- if (mpImplData->maBitmapChecksum != aChecksum)
- {
- BitmapEx aDisabledBmpEx(mpImplData->maBitmapEx);
- BitmapFilter::Filter(aDisabledBmpEx, BitmapDisabledImageFilter());
+ // FIXME: do the HiDPI scaling fun here [!] =)
+ BitmapEx aRenderBmp = mpImplData->getBitmapEx(!!(nStyle & DrawImageFlags::Disable));
- mpImplData->maBitmapChecksum = aChecksum;
- mpImplData->maDisabledBitmapEx = aDisabledBmpEx;
- }
- pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aBitmapSizePixel, mpImplData->maDisabledBitmapEx);
- }
- else
+ if (!(nStyle & DrawImageFlags::Disable) &&
+ (nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight |
+ DrawImageFlags::Deactive | DrawImageFlags::SemiTransparent)))
{
- if (nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight |
- DrawImageFlags::Deactive | DrawImageFlags::SemiTransparent))
+ BitmapEx aTempBitmapEx(aRenderBmp);
+
+ if (nStyle & (DrawImageFlags::Highlight | DrawImageFlags::Deactive))
{
- BitmapEx aTempBitmapEx(mpImplData->maBitmapEx);
+ const StyleSettings& rSettings = pOutDev->GetSettings().GetStyleSettings();
+ Color aColor;
+ if (nStyle & DrawImageFlags::Highlight)
+ aColor = rSettings.GetHighlightColor();
+ else
+ aColor = rSettings.GetDeactiveColor();
+
+ BitmapFilter::Filter(aTempBitmapEx, BitmapColorizeFilter(aColor));
+ }
- if (nStyle & (DrawImageFlags::Highlight | DrawImageFlags::Deactive))
+ if (nStyle & DrawImageFlags::SemiTransparent)
+ {
+ if (aTempBitmapEx.IsTransparent())
{
- const StyleSettings& rSettings = pOutDev->GetSettings().GetStyleSettings();
- Color aColor;
- if (nStyle & DrawImageFlags::Highlight)
- aColor = rSettings.GetHighlightColor();
- else
- aColor = rSettings.GetDeactiveColor();
-
- BitmapFilter::Filter(aTempBitmapEx, BitmapColorizeFilter(aColor));
+ Bitmap aAlphaBmp(aTempBitmapEx.GetAlpha().GetBitmap());
+ aAlphaBmp.Adjust(50);
+ aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aAlphaBmp));
}
-
- if (nStyle & DrawImageFlags::SemiTransparent)
+ else
{
- if (aTempBitmapEx.IsTransparent())
- {
- Bitmap aAlphaBmp(aTempBitmapEx.GetAlpha().GetBitmap());
- aAlphaBmp.Adjust(50);
- aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aAlphaBmp));
- }
- else
- {
- sal_uInt8 cErase = 128;
- aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aTempBitmapEx.GetSizePixel(), &cErase));
- }
+ sal_uInt8 cErase = 128;
+ aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aTempBitmapEx.GetSizePixel(), &cErase));
}
- pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aTempBitmapEx.GetSizePixel(), aTempBitmapEx);
- }
- else
- {
- pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, mpImplData->maBitmapEx.GetSizePixel(), mpImplData->maBitmapEx);
}
+ aRenderBmp = aTempBitmapEx;
}
+
+ pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aBitmapSizePixel, aRenderBmp);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */