Example usage for java.awt.image ImageConsumer SINGLEFRAMEDONE

List of usage examples for java.awt.image ImageConsumer SINGLEFRAMEDONE

Introduction

In this page you can find the example usage for java.awt.image ImageConsumer SINGLEFRAMEDONE.

Prototype

int SINGLEFRAMEDONE

To view the source code for java.awt.image ImageConsumer SINGLEFRAMEDONE.

Click Source Link

Document

One frame of the image is complete but there are more frames to be delivered.

Usage

From source file:MainClass.java

public void imageComplete(int status) {
    if ((status == IMAGEERROR) || (status == IMAGEABORTED)) {
        consumer.imageComplete(status);//from   ww  w.  j  a  va2 s.c om
        return;
    } else {
        int xWidth = imageWidth / iterations;
        if (xWidth <= 0)
            xWidth = 1;
        int newPixels[] = new int[xWidth * imageHeight];
        int iColor = overlapColor.getRGB();
        for (int x = 0; x < (xWidth * imageHeight); x++)
            newPixels[x] = iColor;
        int t = 0;
        for (; t < (imageWidth - xWidth); t += xWidth) {
            consumer.setPixels(t, 0, xWidth, imageHeight, ColorModel.getRGBdefault(), newPixels, 0, xWidth);
            consumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
            try {
                Thread.sleep(delay);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        int left = imageWidth - t;
        if (left > 0) {
            consumer.setPixels(imageWidth - left, 0, left, imageHeight, ColorModel.getRGBdefault(), newPixels,
                    0, xWidth);
            consumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
        }
        consumer.imageComplete(STATICIMAGEDONE);
    }
}