From b34fceb3caea3de53abfc1fc2cb4a5a15af5fd6f Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 4 Oct 2023 14:51:37 +0300 Subject: [PATCH] Add BitmapReadAccess::GetColorFromData Change-Id: Ie7eb0770dc6c5feaa7b4835bdaebfe688a3a381f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157580 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- include/vcl/BitmapReadAccess.hxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/include/vcl/BitmapReadAccess.hxx b/include/vcl/BitmapReadAccess.hxx index c2d4c8f43c42..0d12bcae9dd6 100644 --- a/include/vcl/BitmapReadAccess.hxx +++ b/include/vcl/BitmapReadAccess.hxx @@ -79,22 +79,25 @@ public: { assert(mpBuffer && "Access is not valid!"); assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!"); - assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!"); - return mFncGetPixel(GetScanline(nY), nX, maColorMask); + return GetPixelFromData(GetScanline(nY), nX); } BitmapColor GetPixel(const Point& point) const { return GetPixel(point.Y(), point.X()); } - BitmapColor GetColor(tools::Long nY, tools::Long nX) const + BitmapColor GetColorFromData(sal_uInt8* pData, tools::Long nX) const { if (HasPalette()) - { - const BitmapBuffer* pBuffer = mpBuffer; - return pBuffer->maPalette[GetPixelIndex(nY, nX)]; - } + return GetPaletteColor(GetIndexFromData(pData, nX)); else - return GetPixel(nY, nX); + return GetPixelFromData(pData, nX); + } + + BitmapColor GetColor(tools::Long nY, tools::Long nX) const + { + assert(mpBuffer && "Access is not valid!"); + assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!"); + return GetColorFromData(GetScanline(nY), nX); } BitmapColor GetColor(const Point& point) const { return GetColor(point.Y(), point.X()); }