|
Java™ by example!
|
|
|
How do I morph an image into another one?
Morphing is short for metamorphosing, it refers to an animation technique in which one image is gradually turned into another.
This example morphs one image into another (with same width and height). It first precalculates R G and B array that contains for each pixel the change that should be applied to a (x, y) pixel in image 1 to get to the (x, y) pixel in image 2 after iterating for nFrames steps. Then it loops through the pixelvalues of the source image and adds the RGB change to it. After nFrames steps, the resulting image is image 2.
Test it out with:
Where ally.jpg is the source image lion.jpg is the destination image 200 is the number of frames in between 10 the delay in milliseconds between showing each frame
ally.jpg:

lion.jpg:

Further Information
Author of answer: Joris Van den Bogaert
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|