summaryrefslogtreecommitdiff
path: root/include/basegfx
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-01-08 12:57:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-01-08 17:20:23 +0100
commit9cc41b9ad52e3da734ce72223946bd00bfc92d14 (patch)
treeafb7874bb7be5bbb22dfd0f637fe1a362e9c0430 /include/basegfx
parente12e4dc835fcdd42b0966fd9dd02921654492ad8 (diff)
opacity->alpha in BPixel
They are basically the same thing, but alpha is the preferred term these days. Also improve the mixing algorithm, 1 - opacity is 255 - opacity not 256 - opacity since the range of sal_uInt8 is 0..255 Change-Id: I8788ac79285ab25c8d322b05817dffd3745fd699 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108963 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/basegfx')
-rw-r--r--include/basegfx/pixel/bpixel.hxx48
1 files changed, 24 insertions, 24 deletions
diff --git a/include/basegfx/pixel/bpixel.hxx b/include/basegfx/pixel/bpixel.hxx
index ee42f29c6318..50209ec2ce47 100644
--- a/include/basegfx/pixel/bpixel.hxx
+++ b/include/basegfx/pixel/bpixel.hxx
@@ -33,62 +33,62 @@ namespace basegfx
unsigned mnR : 8; // red intensity
unsigned mnG : 8; // green intensity
unsigned mnB : 8; // blue intensity
- unsigned mnO : 8; // opacity, 0 == full transparence
- } maRGBO;
+ unsigned mnA : 8; // opacity, 0 == full transparence
+ } maRGBA;
struct
{
unsigned mnValue : 32; // all values
- } maCombinedRGBO;
+ } maCombinedRGBA;
} maPixelUnion;
public:
BPixel()
{
- maPixelUnion.maCombinedRGBO.mnValue = 0;
+ maPixelUnion.maCombinedRGBA.mnValue = 0;
}
// use explicit here to make sure everyone knows what he is doing. Values range from
// 0..255 integer here.
- explicit BPixel(sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue, sal_uInt8 nOpacity)
+ explicit BPixel(sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue, sal_uInt8 nAlpha)
{
- maPixelUnion.maRGBO.mnR = nRed;
- maPixelUnion.maRGBO.mnG = nGreen;
- maPixelUnion.maRGBO.mnB = nBlue;
- maPixelUnion.maRGBO.mnO = nOpacity;
+ maPixelUnion.maRGBA.mnR = nRed;
+ maPixelUnion.maRGBA.mnG = nGreen;
+ maPixelUnion.maRGBA.mnB = nBlue;
+ maPixelUnion.maRGBA.mnA = nAlpha;
}
// constructor from BColor which uses double precision color, so change it
// to local integer format. It will also be clamped here.
- BPixel(const BColor& rColor, sal_uInt8 nOpacity)
+ BPixel(const BColor& rColor, sal_uInt8 nAlpha)
{
- maPixelUnion.maRGBO.mnR = sal_uInt8((rColor.getRed() * 255.0) + 0.5);
- maPixelUnion.maRGBO.mnG = sal_uInt8((rColor.getGreen() * 255.0) + 0.5);
- maPixelUnion.maRGBO.mnB = sal_uInt8((rColor.getBlue() * 255.0) + 0.5);
- maPixelUnion.maRGBO.mnO = nOpacity;
+ maPixelUnion.maRGBA.mnR = sal_uInt8((rColor.getRed() * 255.0) + 0.5);
+ maPixelUnion.maRGBA.mnG = sal_uInt8((rColor.getGreen() * 255.0) + 0.5);
+ maPixelUnion.maRGBA.mnB = sal_uInt8((rColor.getBlue() * 255.0) + 0.5);
+ maPixelUnion.maRGBA.mnA = nAlpha;
}
// data access read
- sal_uInt8 getRed() const { return maPixelUnion.maRGBO.mnR; }
- sal_uInt8 getGreen() const { return maPixelUnion.maRGBO.mnG; }
- sal_uInt8 getBlue() const { return maPixelUnion.maRGBO.mnB; }
- sal_uInt8 getOpacity() const { return maPixelUnion.maRGBO.mnO; }
+ sal_uInt8 getRed() const { return maPixelUnion.maRGBA.mnR; }
+ sal_uInt8 getGreen() const { return maPixelUnion.maRGBA.mnG; }
+ sal_uInt8 getBlue() const { return maPixelUnion.maRGBA.mnB; }
+ sal_uInt8 getAlpha() const { return maPixelUnion.maRGBA.mnA; }
// data access write
- void setRed(sal_uInt8 nNew) { maPixelUnion.maRGBO.mnR = nNew; }
- void setGreen(sal_uInt8 nNew) { maPixelUnion.maRGBO.mnG = nNew; }
- void setBlue(sal_uInt8 nNew) { maPixelUnion.maRGBO.mnB = nNew; }
- void setOpacity(sal_uInt8 nNew) { maPixelUnion.maRGBO.mnO = nNew; }
+ void setRed(sal_uInt8 nNew) { maPixelUnion.maRGBA.mnR = nNew; }
+ void setGreen(sal_uInt8 nNew) { maPixelUnion.maRGBA.mnG = nNew; }
+ void setBlue(sal_uInt8 nNew) { maPixelUnion.maRGBA.mnB = nNew; }
+ void setAlpha(sal_uInt8 nNew) { maPixelUnion.maRGBA.mnA = nNew; }
// comparators
bool operator==( const BPixel& rPixel ) const
{
- return (rPixel.maPixelUnion.maCombinedRGBO.mnValue == maPixelUnion.maCombinedRGBO.mnValue);
+ return (rPixel.maPixelUnion.maCombinedRGBA.mnValue == maPixelUnion.maCombinedRGBA.mnValue);
}
bool operator!=( const BPixel& rPixel ) const
{
- return (rPixel.maPixelUnion.maCombinedRGBO.mnValue != maPixelUnion.maCombinedRGBO.mnValue);
+ return (rPixel.maPixelUnion.maCombinedRGBA.mnValue != maPixelUnion.maCombinedRGBA.mnValue);
}
};