|
Quick Lists
|
|
Bug ID:
|
4175560
|
|
Votes
|
40
|
|
Synopsis
|
setIconImage no longer handles transparent GIFs
|
|
Category
|
java:classes_awt
|
|
Reported Against
|
1.2
, 1.2.2
, 1.2fcs
, 1.2rc1
, 1.2rc2
, 1.2beta4
|
|
Release Fixed
|
1.3(kestrel)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
4180215
,
4244067
|
|
Submit Date
|
22-SEP-1998
|
|
Description
|
Erik,
Run this program ("BadIcon.java", attached) with JDK 1.2 and JDK 1.1.6
on a Windows NT platform. (It may be a problem on all platforms.)
The frame's Icon (on Windows, shown in the task bar and in the window's
title bar) has a black background under JDK 1.2, but in JDK 1.1.6, it is
correctly transparent.
Something new you are doing in JDK 1.2 does not handle the GIF
transparent pixels correctly using Frame.setIconImage().
This is still a problem with JDK 1.2 beta 4.1.
Here is the code. I forwarded the code and the
GIF image to Erik Larsen. (I don't know how to
include the image in this form :-) But if you
have a 32x32 transparent GIF to test with, then
use that.
--
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
public class BadIcon {
public static void main(String[] args) {
Image image;
try {
URL url = BadIcon.class.getResource("leif32.gif");
Toolkit tk = Toolkit.getDefaultToolkit();
image = tk.createImage((ImageProducer)url.getContent());
Frame frame = new Frame();
frame.setIconImage(image);
frame.show();
} catch (Exception e) {
System.err.println("Error loading ImageIcon "+BadIcon.class.getResou
rce("leif32.gif"));
e.printStackTrace();
}
}
}
--
Thanks,
Rich
(Review ID: 39230)
======================================================================
whenn setting frame icon image using transparent GIF
transperent color is replaced with black.
(Review ID: 95609)
======================================================================
|
|
Work Around
|
none
======================================================================
|
|
Evaluation
|
Running the provided code produced the following results:
Under Solaris-sparc:
jdk1.1.[5,6,7,8]: Icon INCORRECTLY displayed transparent GIF
jdk1.2.2: Icon CORRECTLY displayed transparent GIF
Under NT4.0sp3:
jdk1.1.[6-8]: Icon CORRECTLY displayed transparent GIF
jdk1.2.2: Icon INCORRECTLY displayed transparent GIF (as per the description)
xxxxx@xxxxx 1999-02-08
Kestrel update:
Neither Solaris-sparc, nor WinNT correctly display transparent GIF icons, as of kestrel-FCS-D.
xxxxx@xxxxx 1999-08-30
I've found the problem on the win32 side.
In native code (awt_Frame.cpp), AwtFrame::MakeSetIcon() calls a function called
create_mask(). This creates the icon mask which tells Windows what part of the
icon should be transparent. create_mask(), however, simply creates a solid rectangle - thus, win32 icons have no transparent areas. This will instead need to examine the image to be used as the icon for pixels containing transparent alpha values.
Moving on to locate the problem on Solaris.
xxxxx@xxxxx 1999-09-20
My first solution was to use the iconMask and iconPixmap attributes of
the native XWindow. This worked like a charm under CDE/dtwm, but as far
as I can tell on olwm this can only yield a two color icon (white for the
foreground and the background color). This doesn't seem acceptable, especially
considering that the current release offers full color icons.
Instead, I'm going to try manually replacing transparent pixels with the background color. The first problem I've run into is that SystemColors.window,
which according to the docs is supposed to be the background color for a native
window, appears as if it's the wrong color. I'll check that out as well.
xxxxx@xxxxx 1999-09-30
The Win32 side was fairly trivial to fix. I drew the image into an ARGB
BufferedImage, checked the pixels for alpha values == 0, and created a
bitmask from these data.
The Solaris side turned a bit tricky. It was a bit of a trick to actually get
the correct window background color. SystemColor.window.getRGB() just wasn't
quite right. I added a Java-level wrapper to the awtJNI_GetColorForVis()
native function, which matches the Color object properly.
So the final solution again involves drawing into a BufferedImage and hunting for alpha pixels. Instead of creating a mask, the corresponding pixels in the
image are replaced with the background color. Because icons are displayed in the default visual of the screen they're on, I created a BufferedImage using the default GraphicsConfiguration. I also moved pSetIconImage and pGetIconSize from MWindowPeer to MFramePeer because the setIconImage() method
is in java.awt.Frame, not java.awt.Window.
xxxxx@xxxxx 1999-10-06
|
|
Comments
|
Submitted On 05-JAN-1999
hawk0080
I have an application that uses gifs that have transparent
backgrounds. In jdk1.1.6 and jdk1.1.7 the gifs were
displayed correctly. ie. the backgrounds looked transparent.
When I switched to using jdk1.2 the backgrounds of the
images showed up. The images are used for icons. I want them
to have the same background color as the panel they are on. This
color changes from plattform to platform hence the need for a transparent
background on my icon images. Thanks Steve
Submitted On 08-FEB-1999
bcpullen
I have similar results and an additional problem,
which I reported over a week ago but have not
seen here yet.
On my Win95 taskbar, when the application has
the focus, the whole icon becomes black. Upon
losing focus you can see the icon again. This
worked okay in prior JDK's.
Submitted On 23-APR-1999
queenSR
I've been having the same problem (on WIN NT) so I
decided to use two images and a window listener.
When the window is activated I load one image
(blue background to match the title bar) and when
the window is deactivated I use the other (gray
background).
This only problem with this method is that when
the window is inactive and the title bar is
pressed, as long as the the mouse button is down
the java cup image is display in the taskbar.
Hope this helps!
Shelly
Submitted On 03-DEC-1999
sballen
I support an applet that uses transparent gifs as icons and button images.
Currently, the source code is compiled with jdk 1.1.8. When the client is
Windows 98, all of the transparent gifs have a black background.
The transparent gifs look fine when the client is Windows NT SP 5.
Submitted On 18-APR-2001
rajesh_bhATIA
I am facing the problem of the Icon not displaying on the
corner of the frame even after using setIconImage().I am
sure the image is in the correct path.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |