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


Java Image.getPixelReader方法代码示例

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


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

示例1: getResizedImage

import javafx.scene.image.Image; //导入方法依赖的package包/类
private Image getResizedImage(InputStream stream) {
    boolean preserveRatio = true;
    boolean smooth = true;

    Image image = new Image(stream,
            AppConstants.MAX_WINDOW_WIDTH,
            AppConstants.MAX_WINDOW_HEIGHT,
            preserveRatio,
            smooth);

    if (image.getPixelReader() == null) {
        LOG.error("Something is wrong with the selected image.");
        return null;
    }
    return image;
}
 
开发者ID:luxmeter,项目名称:puzzlefx,代码行数:17,代码来源:Controller.java

示例2: getMask

import javafx.scene.image.Image; //导入方法依赖的package包/类
@Override
public Set<Point2D> getMask(Image image, Color color) {
	PixelReader pixelReader = image.getPixelReader();
	Set<Point2D> mask = new HashSet<>();
	int pixel;
	boolean isTransparent, isBackgroundColor;
	for(int i =0; i < image.getWidth(); i++){
		for(int j = 0; j < image.getHeight(); j++){
			pixel = pixelReader.getArgb(i, j);
			//check the transparency of the pixel at (i,j)
			isTransparent = (pixel >> 24) == 0x00;				
			Color backgroundColor = pixelReader.getColor(i, j);
			isBackgroundColor = (color.equals(backgroundColor));
			if(!isTransparent && !isBackgroundColor){
				Point2D p = new Point2D(i,j);
				mask.add(p);
			}
		}
	}
	return mask;
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:22,代码来源:ImageTransformation.java

示例3: overlay

import javafx.scene.image.Image; //导入方法依赖的package包/类
/**
 * Use an image as an overlay. Quality rendering is not considered here as
 * this method purpose is for labels and technical marks. Chroma
 * downsampling just drops samples with odd <em>x</em> and <em>y</em>
 * coordinates. If image pixel has alpha value 0 then original canvas value
 * under it is losslessly retained. Otherwise ordinary rounding is used when
 * applying non fully transparent overlay data.
 */
public void overlay(Image image) {
    PixelReader reader = image.getPixelReader();

    for (int y = 0; y < Y.height; y++) {
        boolean hasChromaY = (y & 1) == 0;

        for (int x = 0; x < Y.width; x++) {
            boolean hasChromaX = (x & 1) == 0;

            // TODO PERF: make reading image data more efficient
            int argb = reader.getArgb(x, y);

            int alpha = argb >>> 24;
            if (alpha == 0) {
                continue; // transparent overlay -> skip math
            }

            double opacity = alpha / 255.0;
            double transparency = 1.0 - opacity;

            double overR = ((argb >> 16) & 0xff) / 255.0;
            double overG = ((argb >> 8) & 0xff) / 255.0;
            double overB = ((argb) & 0xff) / 255.0;

            YCbCr params = matrix;

            double overY = params.getY(overR, overG, overB);
            double oldY = params.fromLumaCode(Y.get(x, y));
            double newY = oldY * transparency + overY * opacity;
            Y.set(x, y, round(params.toLumaCode(newY)));

            if (hasChromaX && hasChromaY) {
                // for overlay chroma just drop in-between samples (equals
                // to nearest neighbor) there is no need of higher quality
                int cx = x >> 1, cy = y >> 1;

                double overCb = params.getCb(overY, overB);
                double oldCb = params.fromChromaCode(Cb.get(cx, cy));
                double newCb = oldCb * transparency + overCb * opacity;
                Cb.set(cx, cy, round(params.toChromaCode(newCb)));

                double overCr = params.getCr(overY, overR);
                double oldCr = params.fromChromaCode(Cr.get(cx, cy));
                double newCr = oldCr * transparency + overCr * opacity;
                Cr.set(cx, cy, round(params.toChromaCode(newCr)));
            }
        }
    }
}
 
开发者ID:testing-av,项目名称:testing-video,代码行数:58,代码来源:CanvasYCbCr.java

示例4: crop

import javafx.scene.image.Image; //导入方法依赖的package包/类
public static Image crop(Image img,int x,int y,int w,int h){
    PixelReader reader = img.getPixelReader();
    WritableImage newImage = new WritableImage(reader, x, y, w, h);
    return newImage;
}
 
开发者ID:ashish2199,项目名称:Aidos,代码行数:6,代码来源:ImageUtils.java


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