// Initialize the consumers.
Iterator it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.setHints(ImageConsumer.COMPLETESCANLINES
| ImageConsumer.SINGLEFRAME
| ImageConsumer.SINGLEPASS
| ImageConsumer.TOPDOWNLEFTRIGHT);
target.setDimensions(width, height);
}
// Work in scan-line order.
int[] newLine = new int[width];
int[] bands = new int[sampleModel.getNumBands()];
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
sampleModel.getPixel(x, y, bands, dataBuffer);
newLine[x] = colorModel.getDataElement(bands, 0);
}
// Tell the consumers about the new scan line.
it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.setPixels(0, y, width, 1, colorModel, newLine, 0, width);
}
}
// Tell the consumers that we're done.
it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
}
}