summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-13 15:29:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-02-14 07:29:19 +0100
commite7ed95234244b9f3a2c5c3810984627f05e73384 (patch)
tree408b7d5d9b733361dc02181b0b3814f9d8d6a3a9 /svx
parent6b4d3815a612b688cc5714f8b828a9cc9b109429 (diff)
use VirtualDevice/BitmapEx in CreateColorDropper
part of making Bitmap an internal detail of vcl Change-Id: Ieec5df8976ee0e117a2388dda8ef86b018274915 Reviewed-on: https://gerrit.libreoffice.org/49666 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdhdl.cxx81
1 files changed, 38 insertions, 43 deletions
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index f7fe5b520e7d..293674a88314 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -1114,12 +1114,12 @@ void SdrHdlColor::CreateB2dIAObject()
rtl::Reference< sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
if (xManager.is())
{
- Bitmap aBmpCol(CreateColorDropper(aMarkerColor));
+ BitmapEx aBmpCol(CreateColorDropper(aMarkerColor));
basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
sdr::overlay::OverlayObject* pNewOverlayObject = new
sdr::overlay::OverlayBitmapEx(
aPosition,
- BitmapEx(aBmpCol),
+ aBmpCol,
static_cast<sal_uInt16>(aBmpCol.GetSizePixel().Width() - 1) >> 1,
static_cast<sal_uInt16>(aBmpCol.GetSizePixel().Height() - 1) >> 1
);
@@ -1135,49 +1135,44 @@ void SdrHdlColor::CreateB2dIAObject()
}
}
-Bitmap SdrHdlColor::CreateColorDropper(Color aCol)
+BitmapEx SdrHdlColor::CreateColorDropper(Color aCol)
{
// get the Bitmap
- Bitmap aRetval(aMarkerSize, 24);
- aRetval.Erase(aCol);
-
- // get write access
- std::unique_ptr<BitmapWriteAccess> pWrite(aRetval.AcquireWriteAccess());
- DBG_ASSERT(pWrite, "Got NO write access to a new Bitmap!");
-
- if(pWrite)
- {
- // draw outer border
- sal_Int32 nWidth = aMarkerSize.Width();
- sal_Int32 nHeight = aMarkerSize.Height();
-
- pWrite->SetLineColor(Color(COL_LIGHTGRAY));
- pWrite->DrawLine(Point(0, 0), Point(0, nHeight - 1));
- pWrite->DrawLine(Point(1, 0), Point(nWidth - 1, 0));
- pWrite->SetLineColor(Color(COL_GRAY));
- pWrite->DrawLine(Point(1, nHeight - 1), Point(nWidth - 1, nHeight - 1));
- pWrite->DrawLine(Point(nWidth - 1, 1), Point(nWidth - 1, nHeight - 2));
-
- // draw lighter UpperLeft
- const Color aLightColor(
- static_cast<sal_uInt8>(::std::min(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetRed()) + sal_Int16(0x0040)), sal_Int16(0x00ff))),
- static_cast<sal_uInt8>(::std::min(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetGreen()) + sal_Int16(0x0040)), sal_Int16(0x00ff))),
- static_cast<sal_uInt8>(::std::min(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetBlue()) + sal_Int16(0x0040)), sal_Int16(0x00ff))));
- pWrite->SetLineColor(aLightColor);
- pWrite->DrawLine(Point(1, 1), Point(1, nHeight - 2));
- pWrite->DrawLine(Point(2, 1), Point(nWidth - 2, 1));
-
- // draw darker LowerRight
- const Color aDarkColor(
- static_cast<sal_uInt8>(::std::max(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetRed()) - sal_Int16(0x0040)), sal_Int16(0x0000))),
- static_cast<sal_uInt8>(::std::max(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetGreen()) - sal_Int16(0x0040)), sal_Int16(0x0000))),
- static_cast<sal_uInt8>(::std::max(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetBlue()) - sal_Int16(0x0040)), sal_Int16(0x0000))));
- pWrite->SetLineColor(aDarkColor);
- pWrite->DrawLine(Point(2, nHeight - 2), Point(nWidth - 2, nHeight - 2));
- pWrite->DrawLine(Point(nWidth - 2, 2), Point(nWidth - 2, nHeight - 3));
- }
-
- return aRetval;
+ VclPtr<VirtualDevice> pWrite(VclPtr<VirtualDevice>::Create());
+ pWrite->SetOutputSizePixel(aMarkerSize);
+ pWrite->SetBackground(aCol);
+ pWrite->Erase();
+
+ // draw outer border
+ sal_Int32 nWidth = aMarkerSize.Width();
+ sal_Int32 nHeight = aMarkerSize.Height();
+
+ pWrite->SetLineColor(Color(COL_LIGHTGRAY));
+ pWrite->DrawLine(Point(0, 0), Point(0, nHeight - 1));
+ pWrite->DrawLine(Point(1, 0), Point(nWidth - 1, 0));
+ pWrite->SetLineColor(Color(COL_GRAY));
+ pWrite->DrawLine(Point(1, nHeight - 1), Point(nWidth - 1, nHeight - 1));
+ pWrite->DrawLine(Point(nWidth - 1, 1), Point(nWidth - 1, nHeight - 2));
+
+ // draw lighter UpperLeft
+ const Color aLightColor(
+ static_cast<sal_uInt8>(::std::min(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetRed()) + sal_Int16(0x0040)), sal_Int16(0x00ff))),
+ static_cast<sal_uInt8>(::std::min(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetGreen()) + sal_Int16(0x0040)), sal_Int16(0x00ff))),
+ static_cast<sal_uInt8>(::std::min(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetBlue()) + sal_Int16(0x0040)), sal_Int16(0x00ff))));
+ pWrite->SetLineColor(aLightColor);
+ pWrite->DrawLine(Point(1, 1), Point(1, nHeight - 2));
+ pWrite->DrawLine(Point(2, 1), Point(nWidth - 2, 1));
+
+ // draw darker LowerRight
+ const Color aDarkColor(
+ static_cast<sal_uInt8>(::std::max(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetRed()) - sal_Int16(0x0040)), sal_Int16(0x0000))),
+ static_cast<sal_uInt8>(::std::max(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetGreen()) - sal_Int16(0x0040)), sal_Int16(0x0000))),
+ static_cast<sal_uInt8>(::std::max(static_cast<sal_Int16>(static_cast<sal_Int16>(aCol.GetBlue()) - sal_Int16(0x0040)), sal_Int16(0x0000))));
+ pWrite->SetLineColor(aDarkColor);
+ pWrite->DrawLine(Point(2, nHeight - 2), Point(nWidth - 2, nHeight - 2));
+ pWrite->DrawLine(Point(nWidth - 2, 2), Point(nWidth - 2, nHeight - 3));
+
+ return pWrite->GetBitmapEx(Point(0,0), aMarkerSize);
}
Color SdrHdlColor::GetLuminance(const Color& rCol)