Package java.awt.image

Examples of java.awt.image.PixelGrabber


      {
        final int nRows = Math.max(Math.min(32767 / (this.width * (this.bytesPerPixel + 1)), rowsLeft), 1);

        final int[] pixels = new int[this.width * nRows];

        final PixelGrabber pg = new PixelGrabber(this.image, 0, startRow,
            this.width, nRows, pixels, 0, this.width);
        try
        {
          pg.grabPixels();
        }
        catch (Exception e)
        {
          logger.error("interrupted waiting for pixels!", e);
          return false;
        }
        if ((pg.getStatus() & ImageObserver.ABORT) != 0)
        {
          logger.error("image fetch aborted or errored");
          return false;
        }

View Full Code Here


  }

  public static MemoryImageSource rotate(Image image, CardDimensions dimensions) {
    int buffer[] = new int[dimensions.frameWidth * dimensions.frameHeight];
    int rotate[] = new int[dimensions.frameHeight * dimensions.frameWidth];
    PixelGrabber grabber = new PixelGrabber(image, 0, 0, dimensions.frameWidth, dimensions.frameHeight, buffer, 0, dimensions.frameWidth);
    try {
      grabber.grabPixels();
    }
    catch(InterruptedException e) {
      e.printStackTrace();
    }
    for(int y = 0; y < dimensions.frameHeight; y++) {
View Full Code Here

         m_w = getWidth();
         m_h = getHeight();
     int x = 0;
     int y = 0;
         m_aPixels = new int[m_w * m_h];
         PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, m_h, m_aPixels, 0, m_w);
         try {
             pg.grabPixels();
         } catch (InterruptedException e) {
             System.err.println("interrupted waiting for pixels!");
             return;
         }
         if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
             System.err.println("image fetch aborted or errored");
             return;
         }
         m_bGrabbed = true;
    }
View Full Code Here

        // apply filter using default AWT toolkit
        Image img = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(image.getSource(), filter));

        // use a pixel grabber to retrieve the image's color model;
        // grabbing a single pixel is usually sufficient
        PixelGrabber pg = new PixelGrabber(img, 0, 0, 1, 1, false);
        try {
            pg.grabPixels();
        } catch (InterruptedException e) {
            // ignore
        }

        // recast the AWT image into a BufferedImage (using alpha RGB)
        BufferedImage result = new BufferedImage(
            img.getWidth(null),
            img.getHeight(null),
            pg.getColorModel().hasAlpha() ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB);

        // draw the generated image to the result canvas and return
        Graphics2D g = result.createGraphics();
        g.drawImage(img, 0, 0, null);
        g.dispose();
View Full Code Here

          // Pixel Arrays
          int[] thisPixels = new int[width * height];
          int[] otherPixels = new int[width * height];

          // Pixel die im Kollisionsbereich liegen in die Arrays laden
          PixelGrabber grabber = new PixelGrabber(currentImage,
              Math.abs(hitbox.x - thisArea.getBounds().x), Math.abs(hitbox.y - thisArea.getBounds().y),
              width, height, thisPixels, 0, width);
          grabber.grabPixels();
          grabber = new PixelGrabber(((Sprite)other).getCurrentImage(),
              Math.abs(other.getHitbox().x - thisArea.getBounds().x), Math.abs(other.getHitbox().y - thisArea.getBounds().y),
              width, height, otherPixels, 0, width);
          grabber.grabPixels();
         
          ColorModel cm = grabber.getColorModel();
         
          // Prüfen ob in den Pixeln der jeweilig gleichen Position etwas ist
          for (int i = 0; i < thisPixels.length; i++)
          {
            if (cm.getAlpha(thisPixels[i]) != 0 && cm.getAlpha(otherPixels[i]) != 0)
View Full Code Here

    int width = sx2 - sx1;
    int height = sy2 - sy1;
    int destWidth = dx2 - dx1;
    int destHeight = dy2 - dy1;
    int[] pixels = new int[width * height];
    PixelGrabber pg = new PixelGrabber(img, sx1, sy1, sx2 - sx1, sy2 - sy1,
        pixels, 0, width);
    try {
      pg.grabPixels();
    } catch (InterruptedException e) {
      return false;
    }
    AffineTransform matrix = new AffineTransform(_transform);
    matrix.translate(dx1, dy1);
View Full Code Here

        private int h, w, pixels[];
        public ImageInfo(Image img) throws InterruptedException {
            w = img.getWidth(null);
            h = img.getHeight(null);
            pixels = new int[w*h];
            PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);
            pg.grabPixels();
        }
View Full Code Here

        private int h, w, pixels[];
        public ImageInfo(Image img) throws InterruptedException {
            w = img.getWidth(null);
            h = img.getHeight(null);
            pixels = new int[w*h];
            PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);
            pg.grabPixels();
        }
View Full Code Here

        private int h, w, pixels[];
        public ImageInfo(Image img) throws InterruptedException {
            w = img.getWidth(null);
            h = img.getHeight(null);
            pixels = new int[w*h];
            PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);
            pg.grabPixels();
        }
View Full Code Here

     * @return the bitmap as an array.
     * @throws Exception if an error occured while generating the array
     */
    public int[] getImage() throws Exception {
        int tmpMap[] = new int[this.width * this.height];
        PixelGrabber pg = new PixelGrabber(this.ip, 0, 0, this.width,
                                           this.height, tmpMap, 0, this.width);
        pg.setDimensions(this.width, this.height);
        pg.setColorModel(this.cm);
        pg.setHints(this.hints);
        pg.setProperties(this.properties);
        try {
            pg.grabPixels();
        } catch (InterruptedException intex) {
            /**@todo Use a better exception than Exception */
            throw new Exception("Image grabbing interrupted : "
                                + intex.getMessage());
        }
View Full Code Here

TOP

Related Classes of java.awt.image.PixelGrabber

Copyright © 2018 www.massapicom. 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.