-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
x86
-
windows_nt
Name: yyT116575 Date: 12/08/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I am running in 16 bit color on Windows NT 4.0, SP4.
Running JDK 1.2.2 appletviewer (java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)), the source code
included paints transparent pixels properly (they appear as gray). But running
the exact same code in JDK1.3.0 appletviewer, they are not transparent and are
painted black.
If I change the mode to True Color (24bit), then the transparent pixels are
properly painted in JDK1.3.0.
When I run my unsimplified code (not included), the failed transparent pixels
are painted different colors besides black, it may depend on last painted pixel
or some other thing.
Code...
// file: TestTransparent.java
import java.awt.*;
import java.awt.image.*;
import java.applet.*;
public class TestTransparent extends Applet {
static final byte[] CR = {
0, 0, 0, 0, -26, -1, -1, -1, -128, 0, 0, 0, -1, -1, -1, 0};
static final byte[] CG = {
0, 0, -78, -78, 0, 0, -56, -1, -128, 0, -1, -1, 0, 0, -1, 0};
static final byte[] CB = {
0, -78, 0, -78, 0, -1, 0, -1, -128, -1, 0, -1, 0, -1, 0, 0};
BufferedImage tileImages;
int wdg = 40;
int square = 40;
public void init() {
IndexColorModel icm = new IndexColorModel(4, 15, CR, CG, CB, 15);
tileImages = new BufferedImage(
square, square, BufferedImage.TYPE_BYTE_INDEXED, icm);
MultiPixelPackedSampleModel mppsm = new MultiPixelPackedSampleModel(
DataBuffer.TYPE_BYTE, square, square, 4);
DataBuffer db = mppsm.createDataBuffer();
WritableRaster wr = Raster.createPackedRaster(db, square, square, 4, null);
/*
file image data reading code omitted
*/
int t = 0;
// make the top left edge transparent
for (int i=wdg;i>=0;i--) {
for (int j=0;j<i; j++) {
int x = j;
int y = wdg-i;
int elem = t*(square/2) + y*(square/2) + x/2;
int oldE = db.getElem(elem);
int val = (x&1) == 1 ? (oldE & 0xF0) + 15 : (oldE & 0x0F) + (15 << 4);
db.setElem(elem, val); // transparent index
}
}
tileImages.setData(wr);
}
public void paint(Graphics g) {
g.setColor(Color.lightGray);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.black);
g.drawImage(getTileImage(), 20, 20, this);
}
Image getTileImage() {
return tileImages.getSubimage(0, 0, square, square);
}
}
//file TestTransparent.html
<HTML>
<HEAD>
<TITLE>Transparency Test</TITLE>
</HEAD>
<BODY>
<applet code="TestTransparent.class" WIDTH=100 HEIGHT=100>
</applet>
</BODY>
</HTML>
(Review ID: 113531)
======================================================================