Package java.awt.image

Examples of java.awt.image.PixelGrabber


        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


                // Convert it into a compatible raster
                return createCompatibleRaster(raster, r_image.getColorModel());
            }
        } else {
            // Convert it to a raster
            final PixelGrabber grabber = new PixelGrabber(image, 0, 0, image.getWidth(null),
                image.getHeight(null), true);
            if (grabber.grabPixels(10000)) {
                final int w = grabber.getWidth();
                final int h = grabber.getHeight();
                final WritableRaster raster = dstModel.createCompatibleWritableRaster(w, h);
                final int[] pixels = (int[]) grabber.getPixels();
                Object dataElems = null;
                for (int y = 0; y < h; y++) {
                    final int ofsY = y * w;
                    for (int x = 0; x < w; x++) {
                        final int rgb = pixels[ofsY + x];
View Full Code Here

                // Convert it into a compatible raster
                return createCompatibleRaster(raster, r_image.getColorModel());
            }
        } else {
            // Convert it to a raster
            final PixelGrabber grabber =
                new PixelGrabber(image, 0, 0, image.getWidth(null), image.getHeight(null), true);
            if (grabber.grabPixels()) {
                final int w = grabber.getWidth();
                final int h = grabber.getHeight();
                final WritableRaster raster = dstModel.createCompatibleWritableRaster(w, h);
                final int[] pixels = (int[]) grabber.getPixels();
                Object dataElems = null;
                for (int y = 0; y < h; y++) {
                    final int ofsY = y * w;
                    for (int x = 0; x < w; x++) {
                        final int rgb = pixels[ofsY + x];
View Full Code Here

                // Convert it into a compatible raster
                return createCompatibleRaster(raster, r_image.getColorModel());
            }
        } else {
            // Convert it to a raster
            final PixelGrabber grabber = new PixelGrabber(image, 0, 0, -1, -1, true);
            if (grabber.grabPixels()) {
                final int w = grabber.getWidth();
                final int h = grabber.getHeight();
                final WritableRaster raster = dstModel.createCompatibleWritableRaster(w, h);
                final int[] pixels = (int[]) grabber.getPixels();
                Object dataElems = null;
                for (int y = 0; y < h; y++) {
                    final int ofsY = y * w;
                    for (int x = 0; x < w; x++) {
                        final int rgb = pixels[ofsY + x];
View Full Code Here

    protected int[][] grabPixels(final Image image) {
        final int width = image.getWidth(null);
        final int lines = image.getHeight(null);
        final int pixels[] = new int[width * lines];
        final PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, lines, pixels, 0, width);
        grabber.setColorModel(ColorModel.getRGBdefault());
        try {
            if (grabber.grabPixels() && (grabber.status() & ImageObserver.ALLBITS) != 0) {
                final int[][] array = new int[lines][width];
                int srcPos = 0;
                for (int line = 0; line < lines; line++) {
                    array[line] = new int[width];
                    System.arraycopy(pixels, srcPos, array[line], 0, width);
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

            return false;
        }

        //Images have same dimension
        int[] pixels1 = new int[w1 * h1];
        PixelGrabber pg = new PixelGrabber(
            m_img1.getSource(), 0, 0, w1, h1, pixels1, 0, w1);
        pg.grabPixels();

        int[] pixels2 = new int[w2 * h2];
        PixelGrabber pg2 = new PixelGrabber(
            m_img2.getSource(), 0, 0, w2, h2, pixels2, 0, w2);
        pg2.grabPixels();

        m_imgDiff = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_ARGB);

        //First check if the the images differ.
        int lenAr = pixels1.length;
View Full Code Here

        int w = img.getWidth(null);
        int h = img.getHeight(null);
        int[] p = new int[w*h];
        BufferedImage bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bufferedImage.createGraphics();
        PixelGrabber pgObj = new PixelGrabber(img,0,0,w,h,p,0,w);
        int newInt = newColor.getRGB() & 0xFFFFFF;
        if(pgObj.grabPixels() && ((pgObj.getStatus() & ImageObserver.ALLBITS) != 0)){
          for(int cnt = 0; cnt < (w*h);cnt++)
            // if ( p[cnt] != 0xFFFFFF ) {
            //  System.out.println( "I: " + cnt + ": " + ACast.toHex4String(p[cnt]) + " + " + ACast.toHex4String(newInt) );
              bufferedImage.setRGB(cnt % w, cnt / w, p[cnt] | newInt);
            //} else {
View Full Code Here

    protected int[][] grabPixels(final Image image) {
        final int width = image.getWidth(null);
        final int lines = image.getHeight(null);
        final int pixels[] = new int[width * lines];
        final PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, lines, pixels, 0, width);
        grabber.setColorModel(ColorModel.getRGBdefault());
        try {
            if (grabber.grabPixels() && (grabber.status() & ImageObserver.ALLBITS) != 0) {
                final int[][] array = new int[lines][width];
                int srcPos = 0;
                for (int line = 0; line < lines; line++) {
                    array[line] = new int[width];
                    System.arraycopy(pixels, srcPos, array[line], 0, width);
View Full Code Here

                data[x][y] = 0;
            }
        }

        public void handlepixels(java.awt.Image img, int x, int y, int w, int h) {
            PixelGrabber pg = new PixelGrabber(img, x, y, w, h, false);
            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;
            }
            int[] pixels = (int[]) pg.getPixels();
            data = new int[h][w];
            for (int j = 0; j < h; j++) {
                for (int i = 0; i < w; i++) {
                    handlesinglepixel(x + i, y + j, pixels[j * w + i]);
                }
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.