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


Java PixelGrabber.status方法代码示例

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


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

示例1: createImage

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
    * Cretae a BufferedImage from an ImageProducer.
    * @param producer the ImageProducer
    * @return a new TYPE_INT_ARGB BufferedImage
    */
   public static BufferedImage createImage(ImageProducer producer) {
	PixelGrabber pg = new PixelGrabber(producer, 0, 0, -1, -1, null, 0, 0);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
		throw new RuntimeException("Image fetch interrupted");
	}
	if ((pg.status() & ImageObserver.ABORT) != 0)
		throw new RuntimeException("Image fetch aborted");
	if ((pg.status() & ImageObserver.ERROR) != 0)
		throw new RuntimeException("Image fetch error");
	BufferedImage p = new BufferedImage(pg.getWidth(), pg.getHeight(), BufferedImage.TYPE_INT_ARGB);
	p.setRGB(0, 0, pg.getWidth(), pg.getHeight(), (int[])pg.getPixels(), 0, pg.getWidth());
	return p;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:21,代码来源:ImageUtils.java

示例2: createImage

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
    * Cretae a BufferedImage from an ImageProducer.
    * @param producer the ImageProducer
    * @return a new TYPE_INT_ARGB BufferedImage
    */
   public static BufferedImage createImage(ImageProducer producer) {
	PixelGrabber pg = new PixelGrabber(producer, 0, 0, -1, -1, null, 0, 0);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
		throw new RuntimeException("Image fetch interrupted");
	}
	if ((pg.status() & ImageObserver.ABORT) != 0) {
                   throw new RuntimeException("Image fetch aborted");
               }
	if ((pg.status() & ImageObserver.ERROR) != 0) {
                   throw new RuntimeException("Image fetch error");
               }
	BufferedImage p = new BufferedImage(pg.getWidth(), pg.getHeight(), BufferedImage.TYPE_INT_ARGB);
	p.setRGB(0, 0, pg.getWidth(), pg.getHeight(), (int[])pg.getPixels(), 0, pg.getWidth());
	return p;
}
 
开发者ID:WebcamStudio,项目名称:webcamstudio,代码行数:23,代码来源:ImageUtils.java

示例3: getPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
private static int[][] getPixels(Image image) throws IOException {
    int w = image.getWidth(null);
    int h = image.getHeight(null);
    int pix[] = new int[w * h];
    PixelGrabber grabber = new PixelGrabber(image, 0, 0, w, h, pix, 0, w);

    try {
        if (!grabber.grabPixels()) {
            throw new IOException("Grabber returned false: " + grabber.status());
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    int pixels[][] = new int[w][h];
    for (int x = w; x-- > 0; ) {
        for (int y = h; y-- > 0; ) {
            pixels[x][y] = pix[y * w + x];
        }
    }

    return pixels;
}
 
开发者ID:EmhyrVarEmreis,项目名称:WorldOfMoreWires,代码行数:24,代码来源:ImageLoadingDialog.java

示例4: getPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Snag the pixels from an image.
 */
public static int[][] getPixels(Image image) throws IOException {
    int w = image.getWidth(null);
    int h = image.getHeight(null);
    int pix[] = new int[w * h];
    PixelGrabber grabber = new PixelGrabber(image, 0, 0, w, h, pix, 0, w);

    try {
        if (!grabber.grabPixels()) {
            throw new IOException("Grabber returned false: " +
                    grabber.status());
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    int pixels[][] = new int[w][h];
    for (int x = w; x-- > 0; ) {
        for (int y = h; y-- > 0; ) {
            pixels[x][y] = pix[y * w + x];
        }
    }

    return pixels;
}
 
开发者ID:EmhyrVarEmreis,项目名称:WorldOfMoreWires,代码行数:28,代码来源:TestQuantize.java

示例5: getPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static int[][] getPixels(java.awt.Image image) throws IOException {
	int w = image.getWidth(null);
	int h = image.getHeight(null);
	int pix[] = new int[w * h];
	PixelGrabber grabber = new PixelGrabber(image, 0, 0, w, h, pix, 0, w);

	try {
		if (grabber.grabPixels() != true) {
			throw new IOException("Grabber returned false: " + grabber.status());
		}
	} catch (InterruptedException e) {
		throw new RuntimeException(e);
	}

	int pixels[][] = new int[w][h];
	for (int x = w; x-- > 0;) {
		for (int y = h; y-- > 0;) {
			pixels[x][y] = pix[y * w + x];
		}
	}

	return pixels;
}
 
开发者ID:testobject,项目名称:visual-scripting,代码行数:24,代码来源:ImageUtil.java

示例6: ImageFunction2D

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public ImageFunction2D(Image image, int edgeAction, boolean alpha) {
PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, null, 0, -1);
try {
	pg.grabPixels();
} catch (InterruptedException e) {
	throw new RuntimeException("interrupted waiting for pixels!");
}
if ((pg.status() & ImageObserver.ABORT) != 0) {
	throw new RuntimeException("image fetch aborted");
}
init((int[])pg.getPixels(), pg.getWidth(), pg.getHeight(), edgeAction, alpha);
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:13,代码来源:ImageFunction2D.java

示例7: getTopoRegionSet

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Gets a set of location coordinates representing a topographical region.
 * @param imageMapName the topographical region map image.
 * @return set of location coordinates.
 */
private Set<Coordinates> getTopoRegionSet(String imageMapName) {
	Set<Coordinates> result = new HashSet<Coordinates>(3000);
	/* [landrus, 26.11.09]: don't use the system classloader in a webstart env. */
	URL imageMapURL = getClass().getResource("/images/" + imageMapName);
	ImageIcon mapIcon = new ImageIcon(imageMapURL);
	Image mapImage = mapIcon.getImage();

	int[] mapPixels = new int[300 * 150];
	PixelGrabber topoGrabber = new PixelGrabber(mapImage, 0, 0, 300, 150, mapPixels, 0, 300);
	try {
		topoGrabber.grabPixels();
       } catch (InterruptedException e) {
           logger.log(Level.SEVERE,"grabber error" + e);
       }
       if ((topoGrabber.status() & ImageObserver.ABORT) != 0)
           logger.info("grabber error");
       
       for (int x = 0; x < 150; x++) {
       	for (int y = 0; y < 300; y++) {
       		int pixel = mapPixels[(x * 300) + y];
       		Color color = new Color(pixel);
       		if (Color.white.equals(color)) {
       			double pixel_offset = (Math.PI / 150D) / 2D;
       			double phi = (((double) x / 150D) * Math.PI) + pixel_offset;
       			double theta = (((double) y / 150D) * Math.PI) + Math.PI + pixel_offset;
       			if (theta > (2D * Math.PI)) theta -= (2D * Math.PI);
       			result.add(new Coordinates(phi, theta));
       		}
       	}
       }
	
	return result;
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:39,代码来源:RandomMineralMap.java

示例8: loadHotspots

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Load areothermal hot spots from volcanic map image.
 */
private void loadHotspots() {
	hotspots = new HashSet<Coordinates>(700);
	URL imageMapURL = getClass().getResource("/images/" + AREOTHERMAL_MAP_NAME);
	ImageIcon mapIcon = new ImageIcon(imageMapURL);
	Image mapImage = mapIcon.getImage();

	int[] mapPixels = new int[300 * 150];
	PixelGrabber grabber = new PixelGrabber(mapImage, 0, 0, 300, 150, mapPixels, 0, 300);
	try {
		grabber.grabPixels();
	} catch (InterruptedException e) {
		logger.log(Level.SEVERE,"grabber error" + e);
	}
	if ((grabber.status() & ImageObserver.ABORT) != 0)
		logger.info("grabber error");

	for (int x = 0; x < 150; x++) {
		for (int y = 0; y < 300; y++) {
			int pixel = mapPixels[(x * 300) + y];
			Color color = new Color(pixel);
			if (Color.white.equals(color)) {
				double pixel_offset = (Math.PI / 150D) / 2D;
				double phi = (((double) x / 150D) * Math.PI) + pixel_offset;
				double theta = (((double) y / 150D) * Math.PI) + Math.PI + pixel_offset;
				if (theta > (2D * Math.PI)) theta -= (2D * Math.PI);
				hotspots.add(new Coordinates(phi, theta));
			}
		}
	}
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:34,代码来源:AreothermalMap.java

示例9: GifEncoder

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
* Construct a GIFEncoder. The constructor will convert the image to
* an indexed color array. <B>This may take some time.</B><P>
* 
* @param image The image to encode. The image <B>must</B> be
* completely loaded.
* @exception AWTException Will be thrown if the pixel grab fails. This
* can happen if Java runs out of memory. It may also indicate that the image
* contains more than 256 colors.
* */
   public GifEncoder(Image image) throws AWTException {
width_ = (short)image.getWidth(null);
height_ = (short)image.getHeight(null);

int values[] = new int[width_ * height_];
PixelGrabber grabber = new PixelGrabber(
    image, 0, 0, width_, height_, values, 0, width_);

try {
    if(grabber.grabPixels() != true)
	throw new AWTException("Grabber returned false: " +
			       grabber.status());
}
catch (InterruptedException e) { ; }

byte r[][] = new byte[width_][height_];
byte g[][] = new byte[width_][height_];
byte b[][] = new byte[width_][height_];
int index = 0;
for (int y = 0; y < height_; ++y)
    for (int x = 0; x < width_; ++x) {
	r[x][y] = (byte)((values[index] >> 16) & 0xFF);
	g[x][y] = (byte)((values[index] >> 8) & 0xFF);
	b[x][y] = (byte)((values[index]) & 0xFF);  
	++index;
    }
ToIndexedColor(r, g, b);
   }
 
开发者ID:lucee,项目名称:Lucee4,代码行数:39,代码来源:GifEncoder.java

示例10: filter

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public ImageProducer filter(Image image1, Image image2, int x, int y, int w, int h) {
	int[] pixels1 = new int[w * h];
	int[] pixels2 = new int[w * h];
	int[] pixels3 = new int[w * h];
	PixelGrabber pg1 = new PixelGrabber(image1, x, y, w, h, pixels1, 0, w);
	PixelGrabber pg2 = new PixelGrabber(image2, x, y, w, h, pixels2, 0, w);
	try {
		pg1.grabPixels();
		pg2.grabPixels();
	} catch (InterruptedException e) {
		System.err.println("interrupted waiting for pixels!");
		return null;
	}
	if ((pg1.status() & ImageObserver.ABORT) != 0) {
		System.err.println("image fetch aborted or errored");
		return null;
	}
	if ((pg2.status() & ImageObserver.ABORT) != 0) {
		System.err.println("image fetch aborted or errored");
		return null;
	}

	for (int j = 0; j < h; j++) {
		for (int i = 0; i < w; i++) {
			int k = j * w + i;
			pixels3[k] = filterRGB(x+i, y+j, pixels1[k], pixels2[k]);
		}
	}
	return new MemoryImageSource(w, h, pixels3, 0, w);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:31,代码来源:ImageCombiningFilter.java

示例11: GIFEncoder

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Convenience constructor for class <CODE>GIFEncoder</CODE>. The argument
 * will be converted to an indexed color array. <B>This may take some
 * time.</B>
 * 
 * @param image
 *            The image to encode. The image <B>must</B> be completely
 *            loaded.
 * @exception AWTException
 *                Will be thrown if the pixel grab fails. This can happen if
 *                Java runs out of memory. It may also indicate that the
 *                image contains more than 256 colors.
 */
public GIFEncoder(Image image) throws AWTException {
	this.imageWidth = (short) image.getWidth(null);
	this.imageHeight = (short) image.getHeight(null);

	int values[] = new int[this.imageWidth * this.imageHeight];
	PixelGrabber grabber = new PixelGrabber(image, 0, 0, this.imageWidth, this.imageHeight, values, 0, this.imageWidth);

	try {
		if (grabber.grabPixels() != true)
			throw new AWTException("Grabber returned false: " + grabber.status());
	} // ends try

	catch (InterruptedException ie) {
	}

	byte[][] r = new byte[this.imageWidth][this.imageHeight];
	byte[][] g = new byte[this.imageWidth][this.imageHeight];
	byte[][] b = new byte[this.imageWidth][this.imageHeight];
	int index = 0;

	for (int y = 0; y < this.imageHeight; y++) {
		for (int x = 0; x < this.imageWidth; x++, index++) {
			r[x][y] = (byte) ((values[index] >> 16) & 0xFF);
			g[x][y] = (byte) ((values[index] >> 8) & 0xFF);
			b[x][y] = (byte) ((values[index]) & 0xFF);
		} // ends for

	} // ends for

	this.toIndexColor(r, g, b);
}
 
开发者ID:jplag,项目名称:jplag,代码行数:45,代码来源:GIFEncoder.java

示例12: BmpWriter

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * The constructor.
 * 
 * @param img
 */
public BmpWriter( Image img )
{
	if ( img == null )
	{
		return;
	}

	PixelGrabber pg = new PixelGrabber( img, 0, 0, -1, -1, true );

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

	if ( ( pg.status( ) & ImageObserver.ABORT ) != 0 )
	{
		return;
	}

	this.pix = (int[]) pg.getPixels( );
	this.width = pg.getWidth( );
	this.height = pg.getHeight( );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:33,代码来源:BmpWriter.java

示例13: GIFEncoder

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Construct a GIFEncoder. The constructor will convert the image to
 * an indexed color array. <B>This may take some time.</B><P>
 *
 * @param image The image to encode. The image <B>must</B> be
 * completely loaded.
 * @exception AWTException Will be thrown if the pixel grab fails. This
 * can happen if Java runs out of memory. It may also indicate that the image
 * contains more than 256 colors.
 * */
public GIFEncoder(Image image) throws AWTException {
  width_ = (short) image.getWidth(null);
  height_ = (short) image.getHeight(null);
  int values[] = new int[width_*height_];
  PixelGrabber grabber = new PixelGrabber(image, 0, 0, width_, height_, values, 0, width_);
  try {
    if(grabber.grabPixels()!=true) {
      throw new AWTException("Grabber returned false: "+grabber.status()); //$NON-NLS-1$
    }
  } catch(InterruptedException ex) {
    ex.printStackTrace();
  }
  byte r[][] = new byte[width_][height_];
  byte g[][] = new byte[width_][height_];
  byte b[][] = new byte[width_][height_];
  int index = 0;
  for(int y = 0; y<height_; ++y) {
    for(int x = 0; x<width_; ++x) {
      r[x][y] = (byte) ((values[index]>>16)&0xFF);
      g[x][y] = (byte) ((values[index]>>8)&0xFF);
      b[x][y] = (byte) ((values[index])&0xFF);
      ++index;
    }
  }
  ToIndexedColor(r, g, b);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:37,代码来源:GIFEncoder.java

示例14: setup_sphere

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/** Sets up Points and Colors for Sphere */
private void setup_sphere() {

	// Initialize variables
	int row, col_num, map_col;
	double phi, theta;
	double circum, offset;
	double ih_d = (double) map_height;

	// Initialize color arrays
	int[] pixels_color = new int[map_height * map_width];
	int[][] map_pixels = new int[map_width][map_height];

	// Grab mars_surface image into pixels_color array using PixelGrabber
	PixelGrabber pg_color = new PixelGrabber(marsMap, 0, 0, map_width, map_height,
			pixels_color, 0, map_width);
	try {
		pg_color.grabPixels();
	} catch (InterruptedException e) {
		logger.log(Level.SEVERE,Msg.getString("MarsGlobe.log.grabberError") + e); //$NON-NLS-1$
	}
	if ((pg_color.status() & ImageObserver.ABORT) != 0)
		logger.info(Msg.getString("MarsGlobe.log.grabberError")); //$NON-NLS-1$

	// Transfer contents of 1-dimensional pixels_color into 2-dimensional map_pixels
	for (int x = 0; x < map_width; x++)
		for (int y = 0; y < map_height; y++)
			map_pixels[x][y] = pixels_color[x + (y * map_width)];

	// Initialize variables
	//rho = map_height / Math.PI;
	offset = Math.PI / (2 * ih_d);

	// Go through each row and create Sphere_Color vector with it
	for (phi = offset; phi < Math.PI; phi += (Math.PI / ih_d)) {
		row = (int) Math.floor((phi / Math.PI) * ih_d);
		circum = 2 * Math.PI * (rho * Math.sin(phi));
		col_num = (int) Math.round(circum);
		sphereColor[row] = new Vector<Integer>(col_num);

		// Fill vector with colors
		for (theta = 0; theta < (2 * Math.PI);
				theta += ((Math.PI * 2) / circum)) {
			if (theta == 0) {
				map_col = 0;
			} else {
				map_col = (int) Math.floor((theta / Math.PI) * ih_d);
			}

			sphereColor[row].addElement(map_pixels[map_col][row]);
		}
	}
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:54,代码来源:MarsGlobe.java


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