-
Bug
-
Resolution: Fixed
-
P4
-
1.1.7, 1.2.2, 1.3.0
-
kestrel
-
generic, sparc
-
generic, solaris_2.6
Name: rlT66838 Date: 07/09/99
Animated GIFs with transparent backgrounds do not render correctly if the image is scaled. Non-animated GIFs and animated GIFs with non-transparent backgrounds can be scaled and rendered properly. Animated GIFs with transparent backgrounds are rendered properly only if they are not scaled.
This example was tested with JDK 1.1.8 with Swing 1.1.1-beta2 on Windows NT4(SP4) as well as 1.2.2
================
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.swing.*;
import javax.swing.event.*;
public class animtest extends JFrame
{
public animtest()
{
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
ImageIcon transparent = null;
ImageIcon nontransparent = null;
try {
nontransparent = new ImageIcon(new URL("http://java.sun.com/products/jfc/tsc/page_1_art/Swing-64.gif"));
transparent = new ImageIcon(new URL("http://www.thejavahut.com/gmove.gif"));
}
catch (Exception e) {}
// the images render correctly if
// the code below is commented out
/**/
// scale images to double size
Image img = nontransparent.getImage();
img = img.getScaledInstance(2*img.getWidth(null),
2*img.getHeight(null), Image.SCALE_DEFAULT);
nontransparent = new ImageIcon(img);
img.flush();
Image img2 = transparent.getImage();
img2 = img2.getScaledInstance(2*img.getWidth(null),
2*img.getHeight(null), Image.SCALE_DEFAULT);
transparent = new ImageIcon(img2);
img2.flush();
/**/
getContentPane().setLayout(new GridLayout(1,2));
getContentPane().add(new JLabel(nontransparent));
getContentPane().add(new JLabel(transparent));
pack();
show();
}
public static void main(String[] args)
{
new animtest();
}
}
(Review ID: 85430)
======================================================================
- duplicates
-
JDK-4226683 Icon Image fails silently with hardcoded timeout
- Closed
-
JDK-4272382 The ImageIcon.loadImage() method wait only 5 seconds.
- Closed
- relates to
-
JDK-4302818 Animated GIF eats CPU when not visible
- Resolved