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


Java PixelGrabber.getPixels方法代码示例

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


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

示例1: getImageToWrite

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Get the image to write. This is the mosaic image with alpha channel stripped, as this
 * doesn't work with the JPEG export.
 */
private BufferedImage getImageToWrite() throws InterruptedException {
	BufferedImage image = SwingFXUtils.fromFXImage(mainController.getMosaicImage(), null);
	final int[] RGB_MASKS = {0xFF0000, 0xFF00, 0xFF};
	final ColorModel rgbOpaque = new DirectColorModel(32, RGB_MASKS[0], RGB_MASKS[1], RGB_MASKS[2]);

	PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, true);
	pg.grabPixels();
	int width = pg.getWidth(), height = pg.getHeight();

	DataBuffer buffer = new DataBufferInt((int[]) pg.getPixels(), pg.getWidth() * pg.getHeight());
	WritableRaster raster = Raster.createPackedRaster(buffer, width, height, width, RGB_MASKS, null);
	BufferedImage bi = new BufferedImage(rgbOpaque, raster, false, null);
	
	return bi;
}
 
开发者ID:mrpolyonymous,项目名称:BrickifyFX,代码行数:20,代码来源:OutputPaneController.java

示例2: init

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
private void init(Image image)
{
       PixelGrabber pixelGrabber = ImageUtil.getPixelGrabber(image, location);

	width = pixelGrabber.getWidth();
	height = pixelGrabber.getHeight();
	Object p = pixelGrabber.getPixels();

	if (p != null)
	{
		Class ct = p.getClass().getComponentType();
		if (ct != null)
		{
			if (ct.equals(Integer.TYPE))
				pixels = (int[])p;
			else if (ct.equals(Byte.TYPE))
				throw new IllegalStateException("int[] of pixels expected, received byte[] instead.");
		}
	}
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:21,代码来源:LosslessImage.java

示例3: initialize

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Initialize all the structures and parameters.
 *
 * @throws Exception
 */
public void initialize() throws Exception {
    if (originalImage == null) {
        throw new Exception("Cannot segment a NULL image.");
    }
    // Region border thickness.
    borderThickness = 0;
    pg = new PixelGrabber(originalImage, 0, 0, -1, -1, true);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
        System.err.println(e.getMessage());
    }
    width = pg.getWidth();
    height = pg.getHeight();
    imageRaster = (int[]) pg.getPixels();
    aspectRatio = (double) height / (double) width;
    numPixels = width * height;
    // Algorithm-specific thresholds.
    logdelta = 2.0 * Math.log(6.0 * numPixels);
    // Small regions are those that contain less than 0.1% of image pixels.
    smallRegionSize = (int) (0.001 * numPixels);
}
 
开发者ID:datapoet,项目名称:hubminer,代码行数:28,代码来源:SRMSegmentation.java

示例4: writeObject

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Code derived from
 * http://www.dcs.shef.ac.uk/~tom/Java/Power/image_serialization.html
 */
private void writeObject(ObjectOutputStream objectstream)
      throws IOException {

   // write non-transient, non-static data
   objectstream.defaultWriteObject();
   PixelGrabber grabber = new PixelGrabber(bitmap, 0, 0, -1, -1, true);

   if (colorModel == COLORMODEL_IMAGEICON && bitmap != null) {
      try {
         grabber.grabPixels();
      } catch (InterruptedException e) {
         System.out.println("error grabbing pixels");
      }

      Object pix = grabber.getPixels();
      Dimension dim = new Dimension(bitmap.getWidth(this), bitmap.getHeight(this));
      objectstream.writeObject(dim);
      objectstream.writeObject(pix);
   }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:25,代码来源:OMRasterObject.java

示例5: transparencyBlackColor

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * 将黑色颜色部分透明化
 * 
 * @param img
 * @return
 */
final static public Image transparencyBlackColor(final Image img) {
	int width = img.getWidth(null);
	int height = img.getHeight(null);
	PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, true);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	int pixels[] = (int[]) pg.getPixels();
	int length = pixels.length;
	for (int i = 0; i < length; i++) {
		if (pixels[i] == 0) {
			pixels[i] = 0xffffff;
		}
	}
	return toolKit.createImage(new MemoryImageSource(width, height, pixels, 0, width));
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:25,代码来源:GraphicsUtils.java

示例6: hashImage

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * 生成Image的hash序列
 * 
 * @param img
 * @return
 */
public static int hashImage(Image img) {
	int hash_result = 0;
	int width = img.getWidth(null);
	int height = img.getHeight(null);
	hash_result = (hash_result << 7) ^ height;
	hash_result = (hash_result << 7) ^ width;
	PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, true);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	int pixels[] = (int[]) pg.getPixels();
	for (int pixel = 0; pixel < 20; ++pixel) {
		int x = (pixel * 50) % width;
		int y = (pixel * 100) % height;
		hash_result = (hash_result << 7) ^ pixels[x + width * y];
	}
	return hash_result;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:27,代码来源:GraphicsUtils.java

示例7: convert

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
private FloatArray2D convert(java.awt.Image img) {

		FloatArray2D image;
		PixelGrabber grabber = new PixelGrabber(img, 0, 0, -1, -1, true);
		try {
			grabber.grabPixels();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		int[] data = (int[]) grabber.getPixels();

		image = new FloatArray2D(grabber.getWidth(), grabber.getHeight());
		for (int d = 0; d < data.length; d++)
			image.data[d] = normTo1(RGB2Grey(data[d]));
		return image;
	}
 
开发者ID:myshzzx,项目名称:mlib,代码行数:17,代码来源:JavaSIFT.java

示例8: DirectGif89Frame

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
DirectGif89Frame(Image img) throws IOException {
	PixelGrabber pg = new PixelGrabber(img, 0, 0, -1, -1, true);
	String errmsg = null;
	try {
		if (!pg.grabPixels()) {
			errmsg = "can't grab pixels from image";
		}
	}
	catch (InterruptedException e) {
		errmsg = "interrupted grabbing pixels from image";
	}
	if (errmsg != null) {
		throw new IOException(errmsg + " (" + getClass().getName() + ")");
	}
	theWidth = pg.getWidth();
	theHeight = pg.getHeight();
	argbPixels = (int[]) pg.getPixels();
	ciPixels = new byte[argbPixels.length];
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:20,代码来源:GifEncoder.java

示例9: grabPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
static int[] grabPixels(Object imageobj, int width, int height, 
                        int[] pixels, int startRow, int nRows) {
  java.awt.Image image = (java.awt.Image) imageobj;
  PixelGrabber pixelGrabber = (pixels == null ? new PixelGrabber(image, 0,
      0, width, height, true) : new PixelGrabber(image, 0, startRow, width, nRows, pixels, 0,
          width));
  try {
    pixelGrabber.grabPixels();
  } catch (InterruptedException e) {
    return null;
  }
  return (int[]) pixelGrabber.getPixels();
}
 
开发者ID:etomica,项目名称:etomica,代码行数:14,代码来源:Image.java

示例10: getImageIntPixels

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static int[] getImageIntPixels(Image image, int x, int y, int width, int height, boolean allowDeoptimizingDirectRead)
{
	if (image instanceof BufferedImage)
	{
		BufferedImage bim = (BufferedImage) image;
		WritableRaster raster = bim.getRaster();
		if (allowDeoptimizingDirectRead && raster.getParent() == null
				&& raster.getDataBuffer().getNumBanks() == 1)
		{
			DataBuffer b = bim.getRaster().getDataBuffer();
			if (b instanceof DataBufferInt)
			{
				int[] array = ((DataBufferInt) b).getData();
				return array;
			}
		}
		return bim.getRGB(x, y, width, height, null, 0, width);
	}
	PixelGrabber grabber = new PixelGrabber(image, x, y, width, height,
			true);
	try
	{
		grabber.grabPixels();
		return (int[]) grabber.getPixels();
	} catch (InterruptedException ex)
	{
		throw new RuntimeException("Pixel read operation was interrupted",
				ex);
	}
}
 
开发者ID:TOMIGalway,项目名称:cmoct-sourcecode,代码行数:31,代码来源:ImageUtils.java

示例11: getSplitImages

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * 分割指定图像为image[]
 * 
 * @param image
 * @param row
 * @param col
 * @return
 */
public static Image[] getSplitImages(Image image, int row, int col, boolean isFiltrate) {
	int index = 0;
	int wlength = image.getWidth(null) / row;
	int hlength = image.getHeight(null) / col;
	int l = wlength * hlength;
	Image[] abufferedimage = new Image[l];
	for (int y = 0; y < hlength; y++) {
		for (int x = 0; x < wlength; x++) {
			abufferedimage[index] = GraphicsUtils.createImage(row, col, true);
			Graphics g = abufferedimage[index].getGraphics();
			g.drawImage(image, 0, 0, row, col, (x * row), (y * col), row + (x * row), col + (y * col), null);
			g.dispose();
			g = null;
			PixelGrabber pgr = new PixelGrabber(abufferedimage[index], 0, 0, -1, -1, true);
			try {
				pgr.grabPixels();
			} catch (InterruptedException ex) {
			}
			int pixels[] = (int[]) pgr.getPixels();
			if (isFiltrate) {
				for (int i = 0; i < pixels.length; i++) {
					int[] rgbs = LColor.getRGBs(pixels[i]);
					if ((rgbs[0] == 247 && rgbs[1] == 0 && rgbs[2] == 255)
							|| (rgbs[0] == 255 && rgbs[1] == 255 && rgbs[2] == 255)) {
						pixels[i] = 0;
					}
				}
			}
			ImageProducer ip = new MemoryImageSource(pgr.getWidth(), pgr.getHeight(), pixels, 0, pgr.getWidth());
			abufferedimage[index] = toolKit.createImage(ip);
			index++;
		}
	}
	return abufferedimage;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:44,代码来源:GraphicsUtils.java

示例12: getSplit2Images

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * 分割指定图像为image[]
 * 
 * @param image
 * @param row
 * @param col
 * @return
 */
public static Image[][] getSplit2Images(Image image, int row, int col, boolean isFiltrate) {
	int wlength = image.getWidth(null) / row;
	int hlength = image.getHeight(null) / col;
	Image[][] abufferedimage = new Image[wlength][hlength];
	for (int y = 0; y < hlength; y++) {
		for (int x = 0; x < wlength; x++) {
			abufferedimage[x][y] = GraphicsUtils.createImage(row, col, true);
			Graphics g = abufferedimage[x][y].getGraphics();
			g.drawImage(image, 0, 0, row, col, (x * row), (y * col), row + (x * row), col + (y * col), null);
			g.dispose();
			g = null;
			PixelGrabber pgr = new PixelGrabber(abufferedimage[x][y], 0, 0, -1, -1, true);
			try {
				pgr.grabPixels();
			} catch (InterruptedException ex) {
				ex.getStackTrace();
			}
			int pixels[] = (int[]) pgr.getPixels();
			if (isFiltrate) {
				for (int i = 0; i < pixels.length; i++) {
					int[] rgbs = LColor.getRGBs(pixels[i]);
					if ((rgbs[0] == 247 && rgbs[1] == 0 && rgbs[2] == 255)
							|| (rgbs[0] == 255 && rgbs[1] == 0 && rgbs[2] == 255)
							|| (rgbs[0] == 0 && rgbs[1] == 0 && rgbs[2] == 0)) {
						pixels[i] = 0;
					}
				}
			}
			ImageProducer ip = new MemoryImageSource(pgr.getWidth(), pgr.getHeight(), pixels, 0, pgr.getWidth());
			abufferedimage[x][y] = toolKit.createImage(ip);
		}
	}
	return abufferedimage;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:43,代码来源:GraphicsUtils.java

示例13: getRMXPDialog

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public final static Image getRMXPDialog(String fileName, int width, int height) {
	if (lazyImages == null) {
		lazyImages = new HashMap<String, Image>(10);
	}
	Image dialog = GraphicsUtils.loadImage(fileName);
	int w = dialog.getWidth(null);
	int h = dialog.getHeight(null);
	PixelGrabber pg = new PixelGrabber(dialog, 0, 0, w, h, true);
	try {
		pg.grabPixels();
	} catch (InterruptedException e) {
	}
	int[] pixels = (int[]) pg.getPixels();
	int index = -1;
	int count = 0;
	int pixel;
	for (int i = 0; i < 5; i++) {
		pixel = pixels[(141 + i) + w * 12];
		if (index == -1) {
			index = pixel;
		}
		if (index == pixel) {
			count++;
		}
	}
	if (count == 5) {
		return getRMXPDialog(dialog, width, height, 16, 5);
	} else if (count == 1) {
		return getRMXPDialog(dialog, width, height, 27, 5);
	} else if (count == 2) {
		return getRMXPDialog(dialog, width, height, 20, 5);
	} else {
		return getRMXPDialog(dialog, width, height, 27, 5);
	}
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:36,代码来源:AVGDialog.java

示例14: getImageData

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
private int[] getImageData(Image img) {

		PixelGrabber grabber = new PixelGrabber(img, 0, 0, -1, -1, true);
		try {
			grabber.grabPixels();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		int[] data = (int[]) grabber.getPixels();
		return data;
	}
 
开发者ID:myshzzx,项目名称:mlib,代码行数:12,代码来源:FeatureCache.java

示例15: 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


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