Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 99253

Summary: [Graphics] Alpha information lost from .ico files
Product: [Eclipse Project] Platform Reporter: Billy Biggs <billy.biggs>
Component: SWTAssignee: Praveen <pinnamur>
Status: CLOSED DUPLICATE QA Contact: Felipe Heidrich <eclipse.felipe>
Severity: normal    
Priority: P3 CC: benjamin_pasero, bpasero, eclipse.felipe, ericwill, lindawat, lshanmug, michaelvanmeekeren, Silenio_Quarti, snorthov, xixiyan
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
Patch v01
none
Testcase none

Description Billy Biggs CLA 2005-06-09 16:02:39 EDT
When loading a .ico file with alpha information, the alphadata is not correctly
used.  This results in an image with a mask but no alpha channel.  See bug 98894
for what happened when this was used in Eclipse for Shell.setImages().
Comment 1 Felipe Heidrich CLA 2005-06-10 11:37:47 EDT
This problem should first be solved in Image#init(Device, ImageData).
When the ImageData is loaded from a PNG file it has 24bit of color information 
(image.data) and the alpha channel is stored in the image.alphaData array.
When it is loaded from a ICO file the color and alpha information is store in 
32bit in the image.data array.
The init blits the 32bit byte array to a 24bit byte array throwing away the 
alpha.
Comment 2 Steve Northover CLA 2005-06-10 17:06:22 EDT
Not for 3.1?
Comment 3 Felipe Heidrich CLA 2005-06-10 17:31:41 EDT
I got some code working but far from ideal. Unfortunately I don't think we have 
the time to write the code, test all the cases (different versions of GTK and 
all that) and still fix the bugs.
Comment 4 Steve Northover CLA 2005-06-10 18:26:22 EDT
Not for 3.1.
Comment 5 Felipe Heidrich CLA 2009-08-19 12:22:18 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 6 Benjamin Pasero CLA 2010-03-01 19:42:02 EST
Any workaround?
Comment 7 Felipe Heidrich CLA 2010-03-02 08:40:39 EST
Praveen, can you take at look at this problem ?
Comment 8 Benjamin Pasero CLA 2010-03-02 08:58:40 EST
As I am stuck with 3.5.2, a workaround that I could use would be great too.
Comment 9 Felipe Heidrich CLA 2010-03-02 09:12:47 EST
(In reply to comment #8)
> As I am stuck with 3.5.2, a workaround that I could use would be great too.

the only workaround I can think of is changing the images, maybe converting the .ico (that show the problem) to .png (or some other format that works better with alpha).
Comment 10 Praveen CLA 2010-03-02 10:24:11 EST
Sure Felipe, I will try to work on this.
Comment 11 Benjamin Pasero CLA 2010-03-27 08:36:19 EDT
Actually I have found out that loading the ICO file with the Image() constructor instead of ImageLoader, the transparency is better. See also bug 256969. In fact, on Windows, using Image() results in missing transparency whereas the ImageLoader is working. Weird.
Comment 12 Praveen CLA 2010-04-16 09:33:55 EDT
Created attachment 165094 [details]
Patch v01

Felipe, I have added code changes for handling alpha data of Icon files. I have tested it using different images/icons and they appear good at the moment. Please review the patch and post your comments. Thanks.
Comment 13 Praveen CLA 2010-04-16 09:37:50 EDT
Created attachment 165095 [details]
Testcase

I have added a few alpha icons (multiple icons in a single image) in the attachment along with the snippet that helps in displaying the icon on the shell. Also, ImageAnalyzer example can be used for loading/opening the icon and analyzing it.
Comment 14 Praveen CLA 2010-05-05 06:50:54 EDT
Is this candidate for 3.6RC1 ?
Comment 15 Felipe Heidrich CLA 2010-05-05 10:08:12 EDT
The patch affects all platforms but only GTK has been fixed and tested to handle ico with alphaData. Not critical for 3.6.
Comment 16 Praveen CLA 2010-05-06 08:51:50 EDT
(In reply to comment #15)
> The patch affects all platforms but only GTK has been fixed and tested to
> handle ico with alphaData.
Since the reported problem appears on all the platforms, the code changes are independent of the platform. If you are happy with the taken approach in the patch, I would go ahead testing/addressing various scenarios on all platforms.
Comment 17 Felipe Heidrich CLA 2010-05-06 11:32:49 EDT
I'll be happy with the code after I know it works everywhere ;-)

Yes, the approach seems correct.
Comment 18 Xi Yan CLA 2019-03-08 16:12:47 EST
This can be fixed with the native implementation of ImageLoader. See https://git.eclipse.org/r/#/c/138185/
Comment 19 Xi Yan CLA 2019-03-08 16:13:10 EST

*** This bug has been marked as a duplicate of bug 545032 ***