Examples of ImageConsumer


Examples of java.awt.image.ImageConsumer

        // 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);
          }
      }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.