Bug 558295 - Color: provide API to calculate resulting color for simple 'over' painting of semi-transparent color
Summary: Color: provide API to calculate resulting color for simple 'over' painting of...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.14   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-12-13 05:22 EST by Thomas Singer CLA
Modified: 2019-12-13 10:38 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Singer CLA 2019-12-13 05:22:59 EST
A semi-transparent color (0 < alpha < 255) is drawn 'over' a fully opaque colored area. What is the resulting color?

Please provide Color or RGB API to calculate the resulting (opaque) color from an initial opaque and an 'over' drawn, possibly semi transparent color.

Background: macOS reports some system colors like SWT.COLOR_SELECTION with an alpha channel < 255. I need to know what color to draw to achieve the desired effect.
Comment 1 Eric Williams CLA 2019-12-13 09:52:53 EST
Wouldn't this depend on what the color "underneath" is? I don't think this is something Color can provide us independently.
Comment 2 Thomas Singer CLA 2019-12-13 10:38:00 EST
Of course, this depends on the already existing color. Something like

 RGB calculateOverOperation(RGB baseColor, RGB drawingColorWithAlpha);

See also https://en.wikipedia.org/wiki/Alpha_compositing. In AWT it's about drawing with AlphaComposite.SRC_OVER. The code already should exist somewhere in SWT, if I remember correctly, because of GTK or macOS returning alpha-blended colors.