A
aksel.schmidt
i have a component living in the glasspane, partly transparent to
allow see through to the background
now i want to take a 'snapshot' of the transparent component to make
som animations in the glasspane with (slide transition etc.) - but i
cannot make the transparency information appear on the buffered image
- i use:
public static BufferedImage createImage(JComponent component) {
Dimension d = component.getSize();
if (d.width == 0) {
d = component.getPreferredSize();
component.setSize(d);
}
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
BufferedImage image = gc.createCompatibleImage(d.width,
d.height, Transparency.TRANSLUCENT);
Graphics2D g2d = image.createGraphics();
component.paint(g2d);
g2d.dispose();
return image;
}
how do i paint a transparent component on an image?
thanks!
Aksel,
denmark
allow see through to the background
now i want to take a 'snapshot' of the transparent component to make
som animations in the glasspane with (slide transition etc.) - but i
cannot make the transparency information appear on the buffered image
- i use:
public static BufferedImage createImage(JComponent component) {
Dimension d = component.getSize();
if (d.width == 0) {
d = component.getPreferredSize();
component.setSize(d);
}
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
BufferedImage image = gc.createCompatibleImage(d.width,
d.height, Transparency.TRANSLUCENT);
Graphics2D g2d = image.createGraphics();
component.paint(g2d);
g2d.dispose();
return image;
}
how do i paint a transparent component on an image?
thanks!
Aksel,
denmark