Hi lads!
Soooo here I am back in Newbie & Debugging… :persecutioncomplex:
In fact, I’d need a little help on this one… You see, I have this 2D GUI which has water flowing at the bottom, like so:
//deleted image for spoiler reasons
As you may notice, I’d like to have the whole thing reflected in the water part. The reflection you can see on the image is the result of an early attempt to do so, but I now have to rewrite it, because of a few things:
• the black plants are not reflecting properly;
• there is this overlaying problem at the surface (see purple zone);
• what I use for the moment is quite resource-consuming, so I only render a new reflection every .5 second or so.
Until now, I actually drew a screen capture of the over-water zone, using java.awt.Robot’s methods… :
This is the last thing for me to do on this GUI before being able to move on, so here’s the thing:
I guess it would be better to copy the contents of the java.awt.Graphics2D object — before painting the plants and the water — inside a java.awt.image.BufferedImage object, and then to paint it back, upside down, where I currently draw the screen capture.
That’s why I have been wondering (and wandering on the internet for quite a long time)… How does one make a BufferedImage from Graphics2D? Something that would work a little like that maybe? ???
BufferedImage img;
img = g2d.toImage();//where g2d is a Graphics2D object
I’d be very thankful if anyone could help me out by pointing out that one method I’ve been missing the whole time, or maybe by indicating an alternative solution ;D
Thanks
J0