Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341702 - [JFace] CompositeImageDescriptor mixes images with alpha channel wrong
Summary: [JFace] CompositeImageDescriptor mixes images with alpha channel wrong
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Oleg Besedin CLA
QA Contact: Susan McCourt CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-02 14:26 EDT by Stephan Wahlbrink CLA
Modified: 2011-04-26 13:45 EDT (History)
3 users (show)

See Also:


Attachments
Example for icon which is not painted correctly (2.76 KB, image/png)
2011-04-02 14:28 EDT, Stephan Wahlbrink CLA
no flags Details
Screenshot of the painted DemoIcon (3.67 KB, image/png)
2011-04-02 14:29 EDT, Stephan Wahlbrink CLA
no flags Details
Patch proposal (1.59 KB, patch)
2011-04-02 14:33 EDT, Stephan Wahlbrink CLA
ob1.eclipse: iplog+
Details | Diff
Updated patch (2.70 KB, patch)
2011-04-06 15:24 EDT, Oleg Besedin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Wahlbrink CLA 2011-04-02 14:26:52 EDT
Build Identifier: 3.7.0 I20110329-0800

The method used to mixes images with alpha channel in JFace's CompositeImageDescriptor seems to be wrong for some cases.

Reproducible: Always
Comment 1 Stephan Wahlbrink CLA 2011-04-02 14:28:56 EDT
Created attachment 192415 [details]
Example for icon which is not painted correctly
Comment 2 Stephan Wahlbrink CLA 2011-04-02 14:29:53 EDT
Created attachment 192416 [details]
Screenshot of the painted DemoIcon
Comment 3 Stephan Wahlbrink CLA 2011-04-02 14:33:47 EDT
Created attachment 192417 [details]
Patch proposal
Comment 4 Oleg Besedin CLA 2011-04-04 13:10:36 EDT
That code was originally added in bug 147072. 

Silenio, do you remember if that was a copy from SWT-something?
Comment 5 Silenio Quarti CLA 2011-04-04 14:16:02 EDT
I believe it came from org.eclipse.swt.graphics.GC line#1367.
Comment 6 Oleg Besedin CLA 2011-04-06 15:24:09 EDT
Created attachment 192665 [details]
Updated patch

Nice find and a very good fix! 

The current code is only correct if dstAlpha is 1.0. Which it is in many / most cases, but obviously not always. Even then the calculation of dstAlpha we have is wrong as for a semi-transparent overlay of opaque image it will produce result which will be partially transparent.

I'd like to make a few updates to the patch:

- Keep current formulas for when dstAlpha == 1.0, expect calculation of the result alpha channel which is alway going to be 1.0 in this case. This is both for performance and to minimize effect of the change.

- Add a check for re-calculated dstAlpha being 0 (it could happen if both original image and overlay are transparent at some point).

- Updated copyright
Comment 7 Oleg Besedin CLA 2011-04-06 15:52:51 EDT
Updated patch applied to CVS Head. Thank you Stephan, excellent job!
Comment 8 Stephan Wahlbrink CLA 2011-04-06 16:03:42 EDT
Thanks.

(In reply to comment #6)
> - Add a check for re-calculated dstAlpha being 0 (it could happen if both
> original image and overlay are transparent at some point).

I think it will not happen because sourceAlpha == 0 is already checked some lines above. Of course, the check is no problem.

Ciao,
Stephan
Comment 9 Oleg Besedin CLA 2011-04-26 13:45:09 EDT
Verified in I20110425-1800.