Demo

Here’s a snippet of J2ME ARMY KNIFE code. And, by the way, essentially the same code is used in the “Mask Overlay” section of the demo.

// Declare variables
int step = 0;
Image result = null;
ImageTransformationOverlayMask overlay;

// Initialize the mask overlay effect
overlay = new ImageTransformationOverlayMask();

// Set the image to use as a mask
overlay.setMaskImage(maskImage);

while (true)
{

// Set offsets (to create the scroll effect)
overlay.setVerticalOffset(step);
overlay.setHorizontalOffset(step);

// Process the source image
result = overlay.process(sourceImage);

// Draw the result on screen
g.drawImage ( result, 0, 0, Graphics.TOP | Graphics.LEFT );

// Increment the step
step++;

}

That’s how easy it is to create a mask overlay effect, complete with scrolling!