diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2018-02-24 18:00:29 +1100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-26 07:15:38 +0100 |
commit | fa2dd2ba03f8be1f148dca8f6164daaf7bbf7d96 (patch) | |
tree | babe6650aab4c03fe913852a171004abd715a0c1 /vcl | |
parent | ea05b6595b2d0c8106249b08f3529b4574bdfdf5 (diff) |
vcl: consolidate ColorOf() and GrayOf() functions
Change-Id: Ic80dda409ceaff89be5f249cf906abbb40679f3c
Reviewed-on: https://gerrit.libreoffice.org/50272
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/generic/print/genpspgraphics.cxx | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index 3f9b12257fee..e0556e2d8fd2 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -69,18 +69,15 @@ private: Scanline mpScanAccess; sal_PtrDiff mnScanOffset; - sal_uInt32 ColorOf (BitmapColor const & rColor) const; - sal_uInt8 GrayOf (BitmapColor const & rColor) const; - - public: - - explicit SalPrinterBmp (BitmapBuffer* pBitmap); - virtual sal_uInt32 GetPaletteColor (sal_uInt32 nIdx) const override; - virtual sal_uInt32 GetPaletteEntryCount () const override; - virtual sal_uInt32 GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const override; - virtual sal_uInt8 GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const override; - virtual sal_uInt8 GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const override; - virtual sal_uInt32 GetDepth () const override; +public: + explicit SalPrinterBmp (BitmapBuffer* pBitmap); + + virtual sal_uInt32 GetPaletteColor (sal_uInt32 nIdx) const override; + virtual sal_uInt32 GetPaletteEntryCount () const override; + virtual sal_uInt32 GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const override; + virtual sal_uInt8 GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const override; + virtual sal_uInt8 GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const override; + virtual sal_uInt32 GetDepth () const override; }; SalPrinterBmp::SalPrinterBmp (BitmapBuffer* pBuffer) @@ -174,37 +171,19 @@ SalPrinterBmp::GetDepth () const } sal_uInt32 -SalPrinterBmp::ColorOf (BitmapColor const & rColor) const -{ - if (rColor.IsIndex()) - return ColorOf (mpBmpBuffer->maPalette[rColor.GetIndex()]); - else - return ((rColor.GetBlue()) & 0x000000ff) - | ((rColor.GetGreen() << 8) & 0x0000ff00) - | ((rColor.GetRed() << 16) & 0x00ff0000); -} - -sal_uInt8 -SalPrinterBmp::GrayOf (BitmapColor const & rColor) const -{ - if (rColor.IsIndex()) - return GrayOf (mpBmpBuffer->maPalette[rColor.GetIndex()]); - else - return ( rColor.GetBlue() * 28UL - + rColor.GetGreen() * 151UL - + rColor.GetRed() * 77UL ) >> 8; -} - -sal_uInt32 SalPrinterBmp::GetPaletteEntryCount () const { return mpBmpBuffer->maPalette.GetEntryCount (); } sal_uInt32 -SalPrinterBmp::GetPaletteColor (sal_uInt32 nIdx) const +SalPrinterBmp::GetPaletteColor(sal_uInt32 nIdx) const { - return ColorOf (mpBmpBuffer->maPalette[nIdx]); + BitmapColor aColor(mpBmpBuffer->maPalette[nIdx]); + + return ((aColor.GetBlue()) & 0x000000ff) + | ((aColor.GetGreen() << 8) & 0x0000ff00) + | ((aColor.GetRed() << 16) & 0x00ff0000); } sal_uInt32 @@ -213,7 +192,12 @@ SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const Scanline pScan = mpScanAccess + nRow * mnScanOffset; BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); - return ColorOf (aColor); + if (aColor.IsIndex()) + GetPaletteColor(aColor.GetIndex()); + + return ((aColor.GetBlue()) & 0x000000ff) + | ((aColor.GetGreen() << 8) & 0x0000ff00) + | ((aColor.GetRed() << 16) & 0x00ff0000); } sal_uInt8 @@ -222,7 +206,13 @@ SalPrinterBmp::GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const Scanline pScan = mpScanAccess + nRow * mnScanOffset; BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); - return GrayOf (aColor); + if (aColor.IsIndex()) + aColor = mpBmpBuffer->maPalette[aColor.GetIndex()]; + + return ( aColor.GetBlue() * 28UL + + aColor.GetGreen() * 151UL + + aColor.GetRed() * 77UL ) >> 8; + } sal_uInt8 |