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


Java PixelGrabber.getHeight方法代码示例

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


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

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

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

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

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

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

示例8: getBufferedImageFromPixelGrabber

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
/**
 * Return a BufferedImage loaded from a Image, using a PixelGrabber. Good
 * for when you have an Image, not a BufferedImage, and don't know the width
 * and height. There is a performance penalty with this method, though.
 * 
 * @param image the source Image
 * @param x x start pixel - the horizontal pixel location in the returned
 *        image that the provided image will be set.
 * @param y y start pixel - the vertical pixel location in the returned
 *        image that the provided image will be set.
 * @param w crop width (-1 uses image width)
 * @param h crop height (-1 uses image height)
 * @param imageType the image color model. See BufferedImage.
 * @return BufferedImage if it can be created, null if anything goes wrong.
 */
public static BufferedImage getBufferedImageFromPixelGrabber(Image image, int x, int y, int w, int h, int imageType) {

    PixelGrabber pg = new PixelGrabber(image, x, y, w, h, true);
    int[] pixels = ImageHelper.grabPixels(pg);

    if (pixels == null) {
        return null;
    }

    w = pg.getWidth();
    h = pg.getHeight();
    pg = null;

    BufferedImage bi = new BufferedImage(w, h, imageType);
    logger.fine("BufferedImageHelper.getBufferedImage(): Got buffered image...");

    // bi.setRGB(0, 0, w, h, pixels, 0, w);
    /**
     * Looking at the standard BufferedImage code, an int[0] is allocated
     * for every pixel. Maybe the memory usage is optimized for that, but it
     * goes through a call stack for every pixel to do it. Let's just cycle
     * through the data and write the pixels directly into the raster.
     */
    WritableRaster raster = (WritableRaster) bi.getRaster();
    raster.setDataElements(0, 0, w, h, pixels);

    logger.fine("BufferedImageHelper.getBufferedImage(): set pixels in image...");

    return bi;
}
 
开发者ID:d2fn,项目名称:passage,代码行数:46,代码来源:BufferedImageHelper.java

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

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

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

示例12: init

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
private void init(Image image)
{
       PixelGrabber pixelGrabber = ImageUtil.getPixelGrabber(image, location);
	width = pixelGrabber.getWidth();
	height = pixelGrabber.getHeight();
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:7,代码来源:JPEGImage.java

示例13: makeObject

import java.awt.image.PixelGrabber; //导入方法依赖的package包/类
public static AnimationHelper makeObject(String fileName, int tileWidth, int tileHeight, Color col) {
	String key = fileName.trim().toLowerCase();
	AnimationHelper animation = (AnimationHelper) animations.get(key);
	if (animation == null) {
		Image image = GraphicsUtils.loadNotCacheImage(fileName);
		int c = col.getRGB();
		int wlength = image.getWidth(null) / tileWidth;
		int hlength = image.getHeight(null) / tileHeight;
		Image[][] images = new Image[wlength][hlength];
		for (int y = 0; y < hlength; y++) {
			for (int x = 0; x < wlength; x++) {
				images[x][y] = GraphicsUtils.createImage(tileWidth, tileHeight, true);
				Graphics g = images[x][y].getGraphics();
				g.drawImage(image, 0, 0, tileWidth, tileHeight, (x * tileWidth), (y * tileHeight),
						tileWidth + (x * tileWidth), tileHeight + (y * tileHeight), null);
				g.dispose();
				g = null;
				PixelGrabber pgr = new PixelGrabber(images[x][y], 0, 0, -1, -1, true);
				try {
					pgr.grabPixels();
				} catch (InterruptedException ex) {
					ex.getStackTrace();
				}
				int pixels[] = (int[]) pgr.getPixels();
				for (int i = 0; i < pixels.length; i++) {
					if (pixels[i] == c) {
						pixels[i] = 0;
					}
				}
				ImageProducer ip = new MemoryImageSource(pgr.getWidth(), pgr.getHeight(), pixels, 0,
						pgr.getWidth());
				images[x][y] = GraphicsUtils.toolKit.createImage(ip);
			}
		}
		Image[][] result = new Image[hlength][wlength];
		for (int y = 0; y < wlength; y++) {
			for (int x = 0; x < hlength; x++) {
				result[x][y] = images[y][x];
			}
		}
		images = null;
		animations.put(key, animation = makeObject(result[0], result[1], result[3], result[2]));
	}
	return animation;

}
 
开发者ID:cping,项目名称:RipplePower,代码行数:47,代码来源:AnimationHelper.java


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