Bug 99295 - Problems selecting 16x16 image from the WIndows *.ico
Summary: Problems selecting 16x16 image from the WIndows *.ico
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Update (deprecated - use Eclipse>Equinox>p2) (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: Dejan Glozic CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
Depends on:
Blocks:
 
Reported: 2005-06-09 22:56 EDT by Dejan Glozic CLA
Modified: 2005-06-17 09:30 EDT (History)
4 users (show)

See Also:


Attachments
The code that picks the first image from WINDOW_IMAGES that is 16x16 and does not use alpha transparency (1.89 KB, patch)
2005-06-13 16:21 EDT, Dejan Glozic CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dejan Glozic CLA 2005-06-09 22:56:33 EDT
When product image is a single *.ico file, SWT loads it into an Image and this 
icon image has the size of the largest image in the icon. 

We need to be able to select 16x16 version from the image data somehow.
Comment 1 Dejan Glozic CLA 2005-06-09 22:57:24 EDT
Right now I have worked around the problem by scaling the image when not 16x16 
but there must be a better way.
Comment 2 Steve Northover CLA 2005-06-10 10:03:09 EDT
Due to bug 99253, Eclipse should no longer be using .ico files.  In any case, 
one .ico file can contain many images.  You can load them using an ImageLoader 
and select the ImageData you want from the array as needed.  Is that what you 
are asking?
Comment 3 Dejan Glozic CLA 2005-06-10 10:06:09 EDT
I am simply trying to react to whatever images are returned to me from the 
IProduct class (as defined in the products extension point). These days we are 
all over the place as to which images we are putting there.

If there are several images listed there and some are gifs, some are pngs:

1) do you see anything wrong in me creating an Image object for each URL and 
testing the bounds to see which one is 16x16
2) If I have one gif 16x16 and one png 16x16, which one is 'better' and how do 
I tell programmatically?
Comment 4 Steve Northover CLA 2005-06-10 10:12:28 EDT
1) IMPORTANT: Can you confirm that nobody is using .ICO files?
2) If you intend to use the icon in a shell, use Shell.setImages() and the 
best image from the list will be used, depending on the purpose.
Comment 5 Dejan Glozic CLA 2005-06-10 10:19:47 EDT
No, I want to use the icon for a TreeItem that represents the product.
Comment 6 Dejan Glozic CLA 2005-06-10 10:20:36 EDT
re icons, I have seen eclipse.ico files in org.eclipse.platform and 
org.eclipse.sdk last night but it seems that MVM is on the ball changing that.

Things happen fast these days, hard to follow :-).
Comment 7 Dejan Glozic CLA 2005-06-10 10:24:49 EDT
Yes, they are gone. Instead, the WINDOW_IMAGES property now has something like 
this:

eclipse.gif,eclipse32.gif,eclipse48.gif,eclipse.png,eclipse32.png,eclipse48.png

So how I have two imags that will be 16x16 (eclipse.gif, eclipse.png). When I 
create the Image object from URLImageDescriptor, how can I tell that 
eclipse.png is 'better' (i.e. transparent or something)?
Comment 8 Steve Northover CLA 2005-06-10 14:16:56 EDT
You should not be using images with alpha in widgets anywhere other than in 
the Shell icon unless you are drawing the image yourself.  On Windows 2000, we 
construct a mask from the alpha and this can look bad depending on the alpha 
values.  You can find out which images have alpha using Image.getImageData() 
and ImageData.getTransparencyType().
Comment 9 Dejan Glozic CLA 2005-06-13 16:04:31 EDT
(In reply to comment #8)
> You should not be using images with alpha in widgets anywhere other than in 
> the Shell icon unless you are drawing the image yourself.  On Windows 2000, 
we 
> construct a mask from the alpha and this can look bad depending on the alpha 
> values.  You can find out which images have alpha using Image.getImageData() 
> and ImageData.getTransparencyType().

Steve, there are three transparency types that can be returned 
from 'getTransparencyType'? To confirm, I should not use the icon that returns 
SWT.TRANSPARENCY_ALPHA. What about SWT.TRANSPARENCY_MASK? I assume 
SWT.TRANSPARENCY_PIXEL would be the one used by formats like GIF and is kosher 
for widgets like TreeItem.setImage().

Comment 10 Steve Northover CLA 2005-06-13 16:11:10 EDT
Avoid SWT.TRANSPARENCY_ALPHA.
Comment 11 Dejan Glozic CLA 2005-06-13 16:13:58 EDT
Okeedokee.
Comment 12 Dejan Glozic CLA 2005-06-13 16:20:31 EDT
Proposed code change: add a check for the image transparency data and skip an 
image that uses TRANSPARENCY_ALPHA (see the attached patch).
Comment 13 Dejan Glozic CLA 2005-06-13 16:21:11 EDT
Created attachment 22968 [details]
The code that picks the first image from WINDOW_IMAGES that is 16x16 and does not use alpha transparency
Comment 14 Dejan Glozic CLA 2005-06-14 14:20:05 EDT
Konrad, can you take a look at the patch and add your vote?
Comment 15 Dejan Glozic CLA 2005-06-14 15:01:29 EDT
Dorian, need your approval too.
Comment 16 Konrad Kolosowski CLA 2005-06-14 15:05:51 EDT
+1
Comment 17 Dorian Birsan CLA 2005-06-14 15:11:38 EDT
+1
Comment 18 Dejan Glozic CLA 2005-06-14 15:14:57 EDT
Released.