-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.1
-
generic
-
generic
Name: bsC130419 Date: 08/02/2001
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
This was previously submitted under review id 126120. I have re-tested it with
JDK 1.3.1 and got the same behavior, so I'm resubmitting it against 1.3.1.
/**
* This class demonstrates a problem with the contents of GIF files being
* dithered on 256-color displays when Java loads and displays them, even
* when the contents use only web-safe colors (and when Java is able to
* render those same colors without dithering).
*
* To use:
* Compile the class.
* Run it as an application to create supporting files: java DitherBug
* Run it as an applet: appletviewer dither.html
*
* The applet should display a blue background with a 100 x 100 pixel icon
* in the center, which is the same color as the background, plus a word
* of text. The blue of the background and the blue of the icon should be
* seamless, but on 256-color displays, the icon is dithered. Running the
* applet inside a browser (Netscape 4.7, IE 5.0) using the Java Plug-in
* results in the same behavior, whereas loading the GIF file into the
* browser directly does not produce a dithered image.
*/
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
public class DitherBug extends JApplet
{
static final byte[] imageBytes = {
(byte)0x47, (byte)0x49, (byte)0x46, (byte)0x38, (byte)0x39, (byte)0x61,
(byte)0x64, (byte)0x00, (byte)0x64, (byte)0x00, (byte)0x91, (byte)0x00,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF,
(byte)0xFF, (byte)0x33, (byte)0x33, (byte)0x66, (byte)0xFF, (byte)0xFF,
(byte)0xFF, (byte)0x21, (byte)0xF9, (byte)0x04, (byte)0x01, (byte)0x00,
(byte)0x00, (byte)0x03, (byte)0x00, (byte)0x2C, (byte)0x00, (byte)0x00,
(byte)0x00, (byte)0x00, (byte)0x64, (byte)0x00, (byte)0x64, (byte)0x00,
(byte)0x00, (byte)0x02, (byte)0xD2, (byte)0x94, (byte)0x8F, (byte)0xA9,
(byte)0xCB, (byte)0xED, (byte)0x0F, (byte)0xA3, (byte)0x9C, (byte)0xB4,
(byte)0xDA, (byte)0x8B, (byte)0xB3, (byte)0xDE, (byte)0xBC, (byte)0xFB,
(byte)0x0F, (byte)0x86, (byte)0xE2, (byte)0x48, (byte)0x96, (byte)0xE6,
(byte)0x89, (byte)0xA6, (byte)0xEA, (byte)0xCA, (byte)0xB6, (byte)0xEE,
(byte)0x0B, (byte)0xC7, (byte)0xF2, (byte)0x4C, (byte)0xD7, (byte)0xF6,
(byte)0x8D, (byte)0xE7, (byte)0xFA, (byte)0xCE, (byte)0xF7, (byte)0xFE,
(byte)0x0F, (byte)0x0C, (byte)0x0A, (byte)0x87, (byte)0xC4, (byte)0xA2,
(byte)0xF1, (byte)0x88, (byte)0x4C, (byte)0x2A, (byte)0x97, (byte)0xCC,
(byte)0xA6, (byte)0xF3, (byte)0x09, (byte)0x8D, (byte)0x4A, (byte)0xA7,
(byte)0xD4, (byte)0xAA, (byte)0xF5, (byte)0x8A, (byte)0xCD, (byte)0x6A,
(byte)0xB1, (byte)0x81, (byte)0x6E, (byte)0x17, (byte)0xF1, (byte)0x15,
(byte)0x04, (byte)0x0C, (byte)0xE1, (byte)0x4E, (byte)0xD9, (byte)0x3B,
(byte)0x8E, (byte)0x85, (byte)0xCB, (byte)0x87, (byte)0x75, (byte)0xDA,
(byte)0x9C, (byte)0x76, (byte)0xAB, (byte)0xDF, (byte)0x6E, (byte)0xB4,
(byte)0x78, (byte)0x7C, (byte)0xF6, (byte)0x92, (byte)0xF5, (byte)0x77,
(byte)0x39, (byte)0x7B, (byte)0x3F, (byte)0xD7, (byte)0x16, (byte)0x87,
(byte)0x37, (byte)0x48, (byte)0x78, (byte)0x07, (byte)0x98, (byte)0xB7,
(byte)0xF7, (byte)0xC5, (byte)0x27, (byte)0x28, (byte)0x93, (byte)0x78,
(byte)0x28, (byte)0x07, (byte)0x39, (byte)0x78, (byte)0x08, (byte)0xD8,
(byte)0x37, (byte)0xD9, (byte)0xE8, (byte)0x48, (byte)0x37, (byte)0x19,
(byte)0xB9, (byte)0x88, (byte)0x66, (byte)0xA8, (byte)0xE8, (byte)0x59,
(byte)0x29, (byte)0x0A, (byte)0xF3, (byte)0xD8, (byte)0x59, (byte)0x69,
(byte)0x0A, (byte)0xA6, (byte)0x99, (byte)0x3A, (byte)0x5A, (byte)0x13,
(byte)0x29, (byte)0x79, (byte)0xFA, (byte)0x89, (byte)0x4A, (byte)0x69,
(byte)0xC7, (byte)0x48, (byte)0x39, (byte)0x57, (byte)0xEB, (byte)0x77,
(byte)0x69, (byte)0x67, (byte)0x6B, (byte)0x89, (byte)0xF8, (byte)0xC6,
(byte)0xBB, (byte)0x15, (byte)0x2C, (byte)0x3C, (byte)0x4C, (byte)0x5C,
(byte)0x6C, (byte)0x7C, (byte)0x8C, (byte)0x9C, (byte)0xAC, (byte)0xBC,
(byte)0xCC, (byte)0xDC, (byte)0xEC, (byte)0xFC, (byte)0x0C, (byte)0x1D,
(byte)0x2D, (byte)0x3D, (byte)0x4D, (byte)0x5D, (byte)0x6D, (byte)0x7D,
(byte)0x8D, (byte)0x9D, (byte)0xAD, (byte)0xBD, (byte)0xCD, (byte)0xDD,
(byte)0xED, (byte)0xFD, (byte)0x0D, (byte)0x1E, (byte)0x2E, (byte)0x3E,
(byte)0x4E, (byte)0x5E, (byte)0x6E, (byte)0x7E, (byte)0x8E, (byte)0x9E,
(byte)0xAE, (byte)0xBE, (byte)0xCE, (byte)0xDE, (byte)0xEE, (byte)0xFE,
(byte)0x2E, (byte)0x51, (byte)0x00, (byte)0x00, (byte)0x3B,
};
static String imageFilename = "blue.gif";
static Color color = new Color(0x333366);
public void init()
{
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(color);
getContentPane().add(panel);
try
{
ImageIcon icon = new ImageIcon(new URL(getCodeBase(), "blue.gif"));
JLabel label = new JLabel(icon);
panel.add(label, BorderLayout.CENTER);
}
catch (java.net.MalformedURLException e)
{
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException
{
FileOutputStream output = new FileOutputStream(imageFilename);
output.write(imageBytes);
output.close();
FileWriter writer = new FileWriter("dither.html");
writer.write("<HTML><BODY><APPLET CODE=\"DitherBug.class\""
+ " WIDTH=600 HEIGHT=400></APPLET></BODY></HTML>");
writer.close();
}
}
(Review ID: 126858)
======================================================================
- duplicates
-
JDK-4258700 Pure colors in images do not appear in their pure state in 8bits
- Open