-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta
-
x86
-
windows_95
Name: mc57594 Date: 01/13/2000
The following applet successfully produces a
picture of an "color palette" on Win95 when
it is either:
(1) run under JDK 1.0.2 using any settings of
RBITS, GBITS, BBITS which are non-negative
and add up to less than 32; or
(2) run under JDK 1.2 using only the exact
settings RBITS = GBITS = BBITS = 8.
However, running under JDK 1.2 using any other
combination of positive values of RBITS, GBITS,
BBITS produces a bogus bluish image.
Running under JDK 1.2 with any one of
RBITS, GBITS, or BBITS set to zero throws a
spurious IllegalArgumentException (what's
wrong with monochrome ColorModels? they
worked fine under JDK 1.0.2).
It doesn't seem to make any difference
for these tests whether JDK 1.0.2 or 1.2
is used to compile the applet.
[It seems like sun.awt.image.ImageRepresentation's
setPixels method isn't listening to the
ColorModel of the input pixel array.]
=====
ColorGraphApp.java
=====
import java.applet.*;
import java.awt.*;
public class ColorGraphApp extends Applet {
private ColorGraph graph;
private Image img;
private int grid = 100;
public void init() {
ColorGraph graph = new ColorGraph(grid);
img = createImage(graph);
}
public void paint(Graphics g) {
Rectangle bds = bounds(); // JDK1.2: Rectangle bds = getBounds();
int siz = Math.min(bds.width, bds.height);
g.drawImage(img, 0, 0, siz, siz, Color.white, this); // JDK1.2: g.drawImage(img, 0, 0, siz, siz, 0, 0, grid, grid, Color.white, this);
}
}
=====
ColorGraph.java
=====
import java.awt.*;
import java.awt.image.*;
public class ColorGraph implements ImageProducer {
public final static int RBITS = 8, GBITS = 8, BBITS = 8;
public final static int BITS = (RBITS + GBITS + BBITS);
public final static int RSHIFT = (GBITS + BBITS), GSHIFT = BBITS, BSHIFT = 0;
public final static int RMAX = (1<<RBITS)-1, GMAX = (1<<GBITS)-1, BMAX = (1<<BBITS)-1;
public final static int RPIX = (RMAX<<RSHIFT), GPIX = (GMAX<<GSHIFT), BPIX = (BMAX<<BSHIFT);
public final static float square(float x) { return x*x; }
private int grid;
private int[] pixels;
public ColorGraph(int grid) {
this.grid = grid;
}
public final void startProduction(ImageConsumer consumer) {
if(pixels == null) {
pixels = new int[grid*grid];
for(int i=0, k=0; i<grid; i++) for(int j=0; j<grid; j++) {
pixels[k++] = (int)(
((int)(RMAX*square((i-j+grid-1)/(float)(2*(grid-1)))) << RSHIFT)
| ((int)(GMAX*square((i+j)/(float)(2*(grid-1)))) << GSHIFT)
| ((int)(BMAX*square((grid-1-i)/(float)(grid-1))) << BSHIFT)
);
}
}
ColorModel colorModel = new DirectColorModel(BITS, RPIX, GPIX, BPIX);
consumer.setHints(ImageConsumer.COMPLETESCANLINES|ImageConsumer.TOPDOWNLEFTRIGHT|ImageConsumer.SINGLEPASS);
consumer.setColorModel(colorModel);
consumer.setDimensions(grid, grid);
consumer.setPixels(0, 0, grid, grid, colorModel, pixels, 0, grid);
consumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
public void requestTopDownLeftRightResend(ImageConsumer consumer) { startProduction(consumer); }
public void addConsumer(ImageConsumer consumer) {}
public boolean isConsumer(ImageConsumer consumer) { return true; }
public void removeConsumer(ImageConsumer consumer) {}
}
============================
Date: Fri, 22 Oct 1999 03:29:42 -0700
From: Paul Burchard <###@###.###>
To: chamness <###@###.###>
Subject: Re: (Review ID: 47557) createImage(ImageProducer) fails with most DirectColorModels
chamness wrote:
> We are going back through our old
> Bug Reports and are trying to find out if these
> issues are still relevant to our customers and
> want to know if the problem still exists in our
> more recent releases.
I am glad that you are reviewing all of these bug reports, but as you
can see from my bug report, I provided complete (yet brief) source code
for Sun to perform such tests itself.
You are in a better position to perform these tests, in any case, since
I use Linux exclusively now and Sun still does not offer its own
implementation (that's what's in question here) of Java on Linux.
--
----------------------------------------------------------------------
Paul Burchard <###@###.###> http://www.pobox.com/~burchard/
----------------------------------------------------------------------
(Review ID: 47557)
======================================================================
- relates to
-
JDK-4192756 MemoryImageSource creates wrong shape in 16 bit color
-
- Resolved
-