Reputation: 753
I'm basically looking to make an image to be revealed as time passes, (i've got the settings for time etc) I'm just not sure how to set it to show the image pixel by pixel, growing in height. Aka, you start with no displayed image and then as time grows, it reveals more and more of the image, (going up) and finally reveals the image at the end.
It's like a transition in Java.
I've been messing around with it for ages, Googling everywhere for at least 3 hours. Can't get anywhere,
Here's my images as base:
BufferedImage img = null, img2 = null;
try {
img = ImageIO.read(new File("9278.png"));
img2 = ImageIO.read(new File("9279.png"));
} catch (IOException e) {
e.printStacktrace();
}
g.drawImage(img, 0, 0, null);
g.drawImage(img2, 0, 0, null);
Thanks
Upvotes: 1
Views: 594
Reputation: 5744
I'm assuming you want some sort of curtain effect, like when an image loads over a slow internet connection. I would approach it this way:
You want to use the setClip
method of your Graphics2D
object. Create a new Rectangle
of the size you want the image to be drawn in, and pass that to setClip
in graphics. This will cause the drawing of the image to be performed only inside the area specified by the rectangle.
Upvotes: 2
Reputation: 346
It's not an easy problem as you want somethings not directly integrated in swing, here's the example I used to do the same,
you probably need to adapt it, but it's a good example of what you need
Upvotes: 1