当前位置: 首页>>代码示例>>Java>>正文


Java PixelGrabber.getStatus方法代码示例

本文整理汇总了Java中java.awt.image.PixelGrabber.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java PixelGrabber.getStatus方法的具体用法?Java PixelGrabber.getStatus怎么用?Java PixelGrabber.getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.PixelGrabber的用法示例。


在下文中一共展示了PixelGrabber.getStatus方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPixelGrabber

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static PixelGrabber getPixelGrabber(Image image, String location)
 {
     PixelGrabber pixelGrabber = new PixelGrabber(image, 0, 0, -1, -1, true);

     try
     {
         pixelGrabber.grabPixels();
     }
     catch (InterruptedException interruptedException)
     {
      if (Trace.error)
      {
       interruptedException.printStackTrace();
      }
         throw new RuntimeException("Failed to grab pixels for image " + location);
     }

  if (((pixelGrabber.getStatus() & ImageObserver.WIDTH) == 0) ||
((pixelGrabber.getStatus() & ImageObserver.HEIGHT) == 0))
  {
   throw new RuntimeException("Failed to grab pixels for image " + location);
  }

     return pixelGrabber;
 }
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:26,代码来源:ImageUtil.java

示例2: getPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Get the pixels from the BufferedImage. If anything goes wrong, returns
 * a int[0].
 */
protected int[] getPixels(Image img, int x, int y, int w, int h) {
   int[] pixels = new int[w * h];
   PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
   try {
      pg.grabPixels();
   } catch (InterruptedException e) {
      Debug.error("ImageTranslator: interrupted waiting for pixels!");
      return new int[0];
   }

   if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
      System.err.println("ImageTranslator: image fetch aborted or errored");
      return new int[0];
   }

   return pixels;
}
 
开发者ID:d2fn,项目名称:passage,代码行数:22,代码来源:EarthImagePlugIn.java

示例3: getPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Get the pixels from the BufferedImage. If anything goes wrong, returns a
 * int[0].
 */
protected int[] getPixels(Image img, int x, int y, int w, int h) {
    int[] pixels = new int[w * h];
    PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
        Debug.error("ImageTranslator: interrupted waiting for pixels!");
        return new int[0];
    }

    if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
        System.err.println("ImageTranslator: image fetch aborted or errored");
        return new int[0];
    }

    return pixels;
}
 
开发者ID:d2fn,项目名称:passage,代码行数:22,代码来源:ImageWarp.java

示例4: getImageSource

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
private ArrayImageSource getImageSource( Image image ) throws IOException
{
	ImageIcon imageIcon = new ImageIcon( image );
	int w = imageIcon.getIconWidth( );
	int h = imageIcon.getIconHeight( );
	int[] pixels = new int[w * h];

	try
	{
		PixelGrabber pg = new PixelGrabber( image, 0, 0, w, h, pixels, 0, w );
		pg.grabPixels( );
		if ( ( pg.getStatus( ) & ImageObserver.ABORT ) != 0 )
		{
			throw new IOException( "failed to load image contents" );
		}
	}
	catch ( InterruptedException e )
	{
		throw new IOException( "image load interrupted" );
	}

	ArrayImageSource imageSource = new ArrayImageSource( w, h, pixels );
	return imageSource;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:25,代码来源:PostscriptWriter.java

示例5: OctreeQuantizer

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Create a new octree and insert image data. This constructor is mostly
 * used by OctreeFilter.
 * @param im The image that provides pixel data to construct the tree
 */
public OctreeQuantizer(Image im)
{
  this();

  // first retrieve the pixels
  ImageLoader il = new ImageLoader(im);
  il.start();
  if(!il.waitFor()){
    throw new IllegalArgumentException(_LOG.getMessage(
      "PROBLEM_LOADING"));
  }
  int width = im.getWidth(il);
  int height = im.getHeight(il);
  int[] pixels = new int[width*height]; // going to hold all
  // the image's pixels
  
  PixelGrabber grabber = new PixelGrabber(im.getSource(), 0, 0,
                                          width, height,
                                          pixels, 0, width);
  try // get the pixels
  { 
    grabber.grabPixels();
  } 
  catch (InterruptedException e) 
  {
    throw new IllegalArgumentException(_LOG.getMessage(
      "GRABBING_PIXELS"));
  } 
  if ((grabber.getStatus() & ImageObserver.ABORT) != 0) 
  {
    throw new IllegalArgumentException(_LOG.getMessage(
      "ERROR_FETCHING_IMAGE", new Object[]{pixels.length,width,height}));
  }

  // add all pixels to the tree.
  for (int i = 0; i < pixels.length; i++)
    addColor(pixels[i]);

}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:45,代码来源:OctreeQuantizer.java

示例6: getPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static int[] getPixels(Image img, int x, int y, int w, int h) {
    int[] pixels = new int[w * h]; // PixelGrabber does the work of getting
                                   // actual RGB pixel values for // us from
                                   // the image.
    PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
        System.err.println("interrupted waiting for pixels!");
    }

    if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
        System.err.println("image fetch aborted or errored");
    }
    return pixels;
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:17,代码来源:TabUtilities.java

示例7: copyToBufferedImageManual

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * SCIPIO: Simple copy of a source image to a destination buffered image using a slow but surefire
 * transfer loop. WARN: slow and very slow.
 * Added 2017-07-14.
 * <p>
 * @return the destImage
 */
public static BufferedImage copyToBufferedImageManual(Image srcImage, BufferedImage destImage, RenderingHints renderingHints) {
    Graphics2D g = destImage.createGraphics();
    try {
        if (renderingHints != null) g.setRenderingHints(renderingHints);
        if (srcImage instanceof BufferedImage) {
            // FIXME: very slow
            if (ImageUtil.verboseOn()) Debug.logInfo("Executing manual BufferedImage pixel copy (very slow, but can avoid dithering)", module);
            BufferedImage srcBufImage = ((BufferedImage) srcImage);
            for (int x = 0; x < srcImage.getWidth(null); x++) {
                for (int y = 0; y < srcImage.getHeight(null); y++) {
                    destImage.setRGB(x, y, srcBufImage.getRGB(x, y));
                }
            }
        } else {
            // FIXME: even worse than above! creates a whole copy for nothing.
            if (ImageUtil.verboseOn()) Debug.logInfo("Executing manual Image double pixel copy (extremely slow, but can avoid dithering)", module);
            int[] pixels = new int[srcImage.getWidth(null)*srcImage.getHeight(null)];
            PixelGrabber pg = new PixelGrabber(srcImage, 0, 0, srcImage.getWidth(null), 
                    srcImage.getHeight(null), pixels, 0, srcImage.getWidth(null));
            try {
                pg.grabPixels();
            } catch (InterruptedException e) {
                throw new IllegalStateException("Couldn't get image pixels: " + e.getMessage(), e);
            }
            if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
                throw new IllegalStateException("Couldn't get image pixels: aborted");
            }
            for (int x = 0; x < srcImage.getWidth(null); x++) {
                for (int y = 0; y < srcImage.getHeight(null); y++) {
                    destImage.setRGB(x, y, pixels[y*srcImage.getWidth(null)+x]);
                }
            }
        }
    } finally { // SCIPIO: added finally
        g.dispose();
    }
    return destImage;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:46,代码来源:ImageTransform.java

示例8: AWTImageOpImage

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
   * Constructs an AWTImageOpImage.
   *
   * @param layout  Image layout.
   * @param image   The AWT image.
   */
  public AWTImageOpImage(Map config,
                         ImageLayout layout,
                         Image image) {
      // We don't know the width, height, and sample model yet
      super(layout = layoutHelper(layout, image), config,
            layout.getSampleModel(null),
            layout.getMinX(null), layout.getMinY(null),
            layout.getWidth(null), layout.getHeight(null));

      // Set the format tag if and only if we will use the RasterAccessor.
      if(getTileWidth() != getWidth() || getTileHeight() != getHeight()) {
          rasterFormatTag =
              new RasterFormatTag(getSampleModel(),
                                  RasterAccessor.TAG_BYTE_UNCOPIED);
      }

      // Grab the entire image
      this.pixels = new int[width * height];
      PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, height,
                                              pixels, 0, width);
      try {
          if (!grabber.grabPixels()) {
              if ((grabber.getStatus() & ImageObserver.ABORT) != 0) {
                  throw new RuntimeException(JaiI18N.getString("AWTImageOpImage2"));
} else {
                  throw new RuntimeException(grabber.getStatus() + JaiI18N.getString("AWTImageOpImage3"));
              }
          }
      } catch (InterruptedException e) {
          e.printStackTrace();
          throw new RuntimeException(JaiI18N.getString("AWTImageOpImage4"));
      }
  }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:40,代码来源:AWTImageOpImage.java

示例9: addAlphaToImage

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public void addAlphaToImage()
{
    int width=100;
    int height=100;
    int alphaMask = 0;
    int[] pixels = new int[width * height];

    PixelGrabber pg = new PixelGrabber(clockImage, 0, 0,
        width, height, pixels, 0, width);
    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;
    }
    for (int i=0; i<width*height; i++)
    {
        if ((i % width) == 0)
        {
            alphaMask = (alphaMask >> 24) & 0xff;
            alphaMask += 2;
            if (alphaMask > 255)
            {
                alphaMask = 255;
            }
            alphaMask = (alphaMask << 24) & 0xff000000;
        }
        pixels[i] = (pixels[i] & 0xffffff) | alphaMask;
    }
    clockImage= createImage(new MemoryImageSource(width, height, pixels,
        0, width));
}
 
开发者ID:Zenigata,项目名称:jago,代码行数:38,代码来源:TestEncoder.java

示例10: pickBestTransparency

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Look at the image and determine which Transparency is most appropriate. If it finds any translucent pixels it
 * returns Transparency.TRANSLUCENT, if it finds at least one purely transparent pixel and no translucent pixels it
 * will return Transparency.BITMASK, in all other cases it returns Transparency.OPAQUE, including errors
 * 
 * @param image
 * @return one of Transparency constants
 */
public static int pickBestTransparency(Image image) {
	// Take a shortcut if possible
	if (image instanceof BufferedImage) {
		return pickBestTransparency((BufferedImage) image);
	}

	// Legacy method
	// NOTE: This is a horrible memory hog
	int width = image.getWidth(null);
	int height = image.getHeight(null);
	int[] pixelArray = new int[width * height];
	PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixelArray, 0, width);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
		System.err.println("interrupted waiting for pixels!");
		return Transparency.OPAQUE;
	}
	if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
		System.err.println("image fetch aborted or errored");
		return Transparency.OPAQUE;
	}
	// Look for specific pixels
	boolean foundTransparent = false;
	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			// Get the next pixel
			int pixel = pixelArray[y * width + x];
			int alpha = (pixel >> 24) & 0xff;

			// Is there translucency or just pure transparency ?
			if (alpha > 0 && alpha < 255) {
				return Transparency.TRANSLUCENT;
			}
			if (alpha == 0 && !foundTransparent) {
				foundTransparent = true;
			}
		}
	}
	return foundTransparent ? Transparency.BITMASK : Transparency.OPAQUE;
}
 
开发者ID:RPTools,项目名称:rplib,代码行数:50,代码来源:ImageUtil.java

示例11: grabPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Take a PixelGrabber and get the pixels out of it.
 * 
 * @param pg PixelGrabber
 * @return int[] of pixels, null if anything bad happens.
 */
public static int[] grabPixels(PixelGrabber pg) {

    // Get only the pixels you need.
    // Use a pixel grabber to get the right pixels.
    try {
        pg.startGrabbing();

        boolean grabbed = pg.grabPixels();

        if (!grabbed) {
            Debug.error("ImageHelper.grabPixels(): Error in loading image");
            return null;
        }

        int framebitCount = 0;
        while (true) {
            int status = pg.getStatus();

            if (Debug.debugging("image")) {
                Debug.output("ImageHelper.grabPixels(): status = " + status);
            }

            if ((status & ImageObserver.ALLBITS) != 0) {
                break;
            }
            if ((status & ImageObserver.FRAMEBITS) != 0) {
                // Give some cycles to be sure - some times it
                // seems
                // to not really be ready,
                if (framebitCount < 20) {
                    framebitCount++;
                }
                break;
            }
            if ((status & ImageObserver.ERROR) != 0) {
                Debug.error("ImageHelper.grabPixels(): Error in loading image");
                return null;
            }
            Thread.sleep(100);
        }
        return (int[]) pg.getPixels();

    } catch (InterruptedException ie) {
        return null;
    }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:53,代码来源:ImageHelper.java


注:本文中的java.awt.image.PixelGrabber.getStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。