[I just saw Jim's reply but here's what I was going to send anyway].
On 9/30/2013 10:52 PM, Clemens Eisserer wrote:
Hi,
I am currently testing compatibility of the xrender pipeline with
different composition operations, and I noticed for AlphaComposite.SRC
the D3D and OGL pipelines store pre-multiplied colors in surfaces
without an alpha-channel.
For example the following code results in a black rectangle, instead
of a red one when rendering to a BufferedImage of type INT_RGB:
((Graphics2D) g).setComposite(AlphaComposite.Src);
g.setColor(new Color(255, 0, 0, 2));
g.fillRect(10, 10, 100, 100);
Is this intentional or should it be considered a bug?
Thanks, Clemens
Do you really mean rendering to a BufferedImage ?
I can reproduce this but only rendering directly to the D3D/OGL surface.
Does my example below capture what you mean ?
It sounds wrong as if there's no alpha channel the values should be stored
non-premultiplied.
Having said that if I set the source alpha to 0, then I'd expected
the dest RGB to be 0,0,0. And that is what the h/w pipes do, but
not the s/w pipe which just stores red.
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
public class SrcComp extends Canvas {
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
int w = getWidth();
int h = getHeight();
g2d.setColor(Color.black);
g2d.fillRect(0, 0, w, h);
g2d.setComposite(AlphaComposite.Src);
g2d.setColor(new Color(255, 0, 0, 0));
g2d.fillRect(50, 50, w/2, h/2);
}
public static void main(String[] args) {
SrcComp test = new SrcComp();
final Frame frame = new Frame();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
frame.dispose();
} });
frame.add(test);
frame.pack();
frame.setSize(600, 600);
frame.setVisible(true);
}
}
-phil.