summaryrefslogtreecommitdiff
path: root/vcl/workben
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-11-17 06:37:06 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-11-17 06:40:56 +0000
commit18c50cefd761efe71a5e6957422ed6f153e6ba34 (patch)
treea25fdf0e95f695b14694b64b04b57942afc47bcb /vcl/workben
parent691402155ef119fa89d1e09d3bde1f7d063a9941 (diff)
vcldemo: improve my rather trivial inferred alpha maths.
Change-Id: I420628cea2272d6f5af0b13b9c32902627dcf86f
Diffstat (limited to 'vcl/workben')
-rw-r--r--vcl/workben/vcldemo.cxx21
1 files changed, 15 insertions, 6 deletions
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 7ccde7cab3b9..94d549247410 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -798,16 +798,25 @@ public:
// we get the most precision from the largest delta
long nInverseAlpha = std::max(nAR, std::max(nAG, nAB)); // (1-a)
nInverseAlpha = CLAMP(nInverseAlpha, 0, 255);
+ long nAlpha = 255 - nInverseAlpha;
pMaskAcc->SetPixel(y,x,BitmapColor((sal_Int8)CLAMP(nInverseAlpha,0,255)));
// now recover the pixels
- long n2R = aColW.GetRed() + aColB.GetRed();
- long n2G = aColW.GetGreen() + aColB.GetGreen();
- long n2B = aColW.GetBlue() + aColB.GetBlue();
+ long nR = (aColW.GetRed() + aColB.GetRed() - nInverseAlpha) * 128;
+ long nG = (aColW.GetGreen() + aColB.GetGreen() - nInverseAlpha) * 128;
+ long nB = (aColW.GetBlue() + aColB.GetBlue() - nInverseAlpha) * 128;
+ if (nAlpha == 0)
+ { // doesn't matter what's behind transparency
+ nR = nG = nB = 0;
+ }
+ else
+ {
+ nR /= nAlpha; nG /= nAlpha; nB /= nAlpha;
+ }
pRecAcc->SetPixel(y,x,BitmapColor(
- (sal_uInt8)CLAMP((n2R+1)/2-nInverseAlpha,0,255),
- (sal_uInt8)CLAMP((n2G+1)/2-nInverseAlpha,0,255),
- (sal_uInt8)CLAMP((n2B+1)/2-nInverseAlpha,0,255)));
+ (sal_uInt8)CLAMP(nR,0,255),
+ (sal_uInt8)CLAMP(nG,0,255),
+ (sal_uInt8)CLAMP(nB,0,255)));
#undef CLAMP
}
}