Package java.awt.image

Examples of java.awt.image.PixelGrabber


            return bimage.getColorModel().hasAlpha();
        }

        // Use a pixel grabber to retrieve the image's color model;
        // grabbing a single pixel is usually sufficient
        PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);

        try {
            pg.grabPixels();
        } catch (InterruptedException e) {
        }

        // Get the image's color model
        ColorModel cm = pg.getColorModel();

        return cm.hasAlpha();
    }
View Full Code Here


    if (width < 1 || height < 1)
    {
      return null;
    }
    int[] pixels = new int[width * height];
    PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
    try
    {
      pg.grabPixels();
    }
    catch (InterruptedException e)
    {
      return null;
    }
    if ((pg.getStatus() & ImageObserver.ABORT) != 0)
    {
      return null;
    }
    RGB24Image result = new MemoryRGB24Image(width, height);
    int offset = 0;
View Full Code Here

  public GifEncoder(Image image, ProgressMonitor monitor) throws AWTException {
    width_ = (short)image.getWidth(null);
    height_ = (short)image.getHeight(null);

    int values[] = new int[width_ * height_];
    PixelGrabber grabber;
    if (monitor != null) {
      grabber = new MyGrabber(monitor, image, 0, 0, width_, height_, values, 0, width_);
    } else {
      grabber = new PixelGrabber(image, 0, 0, width_, height_, values, 0, width_);
    }

    try {
      if (grabber.grabPixels() != true)
        throw new AWTException(Strings.get("grabberError") + ": "
          + grabber.status());
    } catch (InterruptedException e) {
      ;
    }
   
    byte r[][] = new byte[width_][height_];
View Full Code Here

            latestPixels = new int[w * h];
        }
        if (previousPixels == null) {
            previousPixels = new int[w * h];
        }
        PixelGrabber latestPixelGrabber = new PixelGrabber(latest, 0, 0, w, h, latestPixels, 0, w);

        try {
            latestPixelGrabber.grabPixels();
        } catch (InterruptedException e) {
            System.out.println("interrupted waiting for pixels");
        }

        if ((latestPixelGrabber.getStatus() & ImageObserver.ABORT) != 0) {
            System.out.println("image fetch aborted or errored");
        }

        if (previousPixels != null) {
            motionLevel = 0;
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

         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

            int height = src.getHeight(null);


            //BufferedImage result = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

            PixelGrabber pg = new PixelGrabber(src, 0, 0, width, height, true);

            pg.grabPixels();

            int[] srcpixels = (int[]) pg.getPixels();

            int[] resPixels = new int[srcpixels.length];

            for (int i = width + 1; i < srcpixels.length - width - 1; i++)
            {
View Full Code Here

  /* -- */

  public ImageColorDialog(Image image) {
    this.image = image;
    PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, true);

    try {
      pg.grabPixels();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    pixels = (int[]) pg.getPixels();

    init();
    pack();
    setLocationRelativeTo(getOwner());
    setModal(true);
View Full Code Here

    /**
     * Returns a vector of the data in the given image.
     */
    private static GVector getData(Image image, int x, int y, int width, int height) {
        int[] pixels = new int[width * height];
        PixelGrabber pg = new PixelGrabber(image, x, y, width, height, pixels, 0, width);
        try { pg.grabPixels(); }
        catch(InterruptedException e) { throw new RuntimeException(e); }
       
        GVector data = new GVector(3 * pixels.length);
        for(int i = 0; i < pixels.length; i++) {
            int red   = (pixels[i] >> 16) & 0xff;
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.