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


Java PixelReader.getArgb方法代码示例

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


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

示例1: getMask

import javafx.scene.image.PixelReader; //导入方法依赖的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

示例2: Face

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
public Face(Image image, int startX, int startY, int width, int height, int interval, boolean reverseX, boolean reverseY,
		Supplier<Box> supplier, BiConsumer<Box, Point2D> consumer) {
	PixelReader reader = image.getPixelReader();
	for (int x = 0; x < width; x++)
		for (int y = 0; y < height; y++) {
			int argb;
			if ((argb = reader.getArgb(startX + (reverseX ? width - x - 1 : x) * interval,
					startY + (reverseY ? height - y - 1 : y) * interval)) != 0) {
				Box pixel = supplier.get();
				consumer.accept(pixel, new Point2D(x, y));
				pixel.setMaterial(createMaterial(Color.rgb(
						(argb >> 16) & 0xFF, (argb >> 8) & 0xFF, (argb >> 0) & 0xFF)));
				getChildren().add(pixel);
			}
		}
}
 
开发者ID:InfinityStudio,项目名称:minecraft-jfx-skin,代码行数:17,代码来源:SkinMultipleCubes.java

示例3: resampleImage

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
/**
 * This method receives an image scales it
 * @param input Input image
 * @param scaleFactor Output scale factor
 * @return The resampled image
 */
public Image resampleImage(Image input, int scaleFactor) {
    int W = (int) input.getWidth();
    int H = (int) input.getHeight();
    WritableImage output = new WritableImage(
            W * scaleFactor,
            H * scaleFactor
    );
    PixelReader reader = input.getPixelReader();
    PixelWriter writer = output.getPixelWriter();
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            int argb = reader.getArgb(x, y);
            for (int dy = 0; dy < scaleFactor; dy++) {
                for (int dx = 0; dx < scaleFactor; dx++) {
                    writer.setArgb(x * scaleFactor + dx, y * scaleFactor + dy, argb);
                }
            }
        }
    }
    return output;
}
 
开发者ID:DarkLBP,项目名称:Krothium-Launcher,代码行数:28,代码来源:Kernel.java

示例4: update

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
public void update(Path2D p2d) {
    setPath(resultpath, p2d);
    Path p = makePath();
    WritableImage wimg = new WritableImage(TESTW, TESTH);
    renderPath(p2d, p, wimg);
    PixelReader pr = wimg.getPixelReader();
    GraphicsContext gc = resultcv.getGraphicsContext2D();
    gc.save();
    for (int y = 0; y < TESTH; y++) {
        for (int x = 0; x < TESTW; x++) {
            boolean inpath = p2d.contains(x + 0.5, y + 0.5);
            boolean nearpath = near(p2d, x + 0.5, y + 0.5, warn);
            int pixel = pr.getArgb(x, y);
            renderPixelStatus(gc, x, y, pixel, inpath, nearpath);
        }
    }
    gc.restore();
}
 
开发者ID:bourgesl,项目名称:marlin-fx,代码行数:19,代码来源:TestNonAARasterization.java

示例5: transferPixels

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
/**
 * Transfer pixels from the rendering buffer to the winner/alpha maps.
 *
 * @param img Rendering buffer
 * @param x1 Left
 * @param x2 Right
 * @param y1 Bottom
 * @param y2 Top
 * @param layer Output array
 * @param c Entity number
 */
public void transferPixels(WritableImage img, int x1, int x2, int y1, int y2, int[][] layer, int c) {
  assert (c > 0);
  PixelReader reader = img.getPixelReader();
  for(int y = y1, py = 0; y < y2; y++, py++) {
    final int[] rowy = layer[y];
    for(int x = x1, px = 0; x < x2; x++, px++) {
      int col = reader.getArgb(px, py);
      int alpha = (col & 0xFF);
      // Always ignore cover less than 10%
      if(alpha < 0x19) {
        continue;
      }
      // Clip value range to positive bytes,
      // alpha = alpha > 0x7F ? 0x7F : alpha;
      int oldalpha = rowy[x] >>> 24;
      if(alpha == 0xFF || alpha >= oldalpha) {
        rowy[x] = (alpha << 24) | c;
      }
    }
  }
}
 
开发者ID:kno10,项目名称:reversegeocode,代码行数:33,代码来源:BuildLayeredIndexSliced.java

示例6: transferPixels

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
/**
 * Transfer pixels from the rendering buffer to the winner/alpha maps.
 *
 * @param img
 *            Rendering buffer
 * @param x1
 *            Left
 * @param x2
 *            Right
 * @param y1
 *            Bottom
 * @param y2
 *            Top
 * @param winner
 *            Output array
 * @param c
 *            Entity number
 */
public void transferPixels(WritableImage img, int x1, int x2, int y1,
		int y2, int[][] winner, int c) {
	PixelReader reader = img.getPixelReader();
	for (int y = y1, py = 0; y < y2; y++, py++) {
		for (int x = x1, px = 0; x < x2; x++, px++) {
			int col = reader.getArgb(px, py);
			int alpha = (col & 0xFF);
			// Always ignore cover less than 10%
			if (alpha < 0x19) {
				continue;
			}
			// Clip value range to positive bytes,
			alpha = alpha > 0x7F ? 0x7F : alpha;
			byte oldalpha = (byte) (winner[y][x] >>> 24);
			if (alpha == 0x7F || (alpha > 0 && alpha >= oldalpha)) {
				winner[y][x] = (alpha << 24) | c;
			}
		}
	}
}
 
开发者ID:kno10,项目名称:reversegeocode,代码行数:39,代码来源:BuildLayeredIndex.java

示例7: testARGB

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
private void testARGB(PixelReader reader, int width, int height) {
    for (int i = 0; i < 10; i++) {
        WritableImage dest = new WritableImage(width, height);
        PixelWriter writer = dest.getPixelWriter();

        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                // reading a pixel from src image,
                // then writing a pixel to dest image
                //Color color = reader.getColor(x, y);
                //writer.setColor(x, y, color);

                // this way is also OK
                int argb = reader.getArgb(x, y);
                writer.setArgb(x, y, argb);


            }
        }

    }
}
 
开发者ID:amoAHCP,项目名称:JavaOne2015JavaFXPitfalls,代码行数:23,代码来源:PixelWriterTest.java

示例8: brightnessSum

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
/**
    * Returns the sum of the red, green, and blue components of all the pixels
    * of an image within a region.
    *
    * If the region extends outside the bounds of the image, each pixel
    * outside the bounds of the image is considered to have a value of zero.
    *
    * @param image the image to sum. This must not be null.
    * @param region The region of the image to sum pixels from. This must not
    * be null.
    * @return The sum of components
    */
   private static long brightnessSum(Image image, Rectangle region) {
final PixelReader reader = image.getPixelReader();
long sum = 0;
for (int y = region.y; y < region.y + region.height + 1; y++) {
    for (int x = region.x; x < region.x + region.width + 1; x++) {
	if (x >= 0 && x < image.getWidth() && y >= 0 && y < image
		.getHeight()) {
	    int argb = reader.getArgb(x, y);
	    // Sum the red, green, and blue components to get a value
	    // between 0 and 765
	    long brightness = ((argb >> 16) & 0xFF) + ((argb >> 8) & 0xFF) + (argb & 0xFF);
	    sum += brightness;
	}
    }
}
return sum;
   }
 
开发者ID:samcrow,项目名称:FrameViewer-AnTracks,代码行数:30,代码来源:TemplateTracker.java

示例9: enlarge

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
public static Image enlarge(Image srcSkin, int multiple) {
	WritableImage newSkin = new WritableImage((int) srcSkin.getWidth() * multiple, (int) srcSkin.getHeight() * multiple);
	PixelReader reader = srcSkin.getPixelReader();
	PixelWriter writer = newSkin.getPixelWriter();
	
	for (int x = 0, lenX = (int) srcSkin.getWidth(); x < lenX; x++)
		for (int y = 0, lenY = (int) srcSkin.getHeight(); y < lenY; y++)
			for (int mx = 0; mx < multiple; mx++)
				for (int my = 0; my < multiple; my++) {
					int argb = reader.getArgb(x, y);
					writer.setArgb(x * multiple + mx, y * multiple + my, argb);
				}
	
	return newSkin;
}
 
开发者ID:InfinityStudio,项目名称:minecraft-jfx-skin,代码行数:16,代码来源:SkinHelper.java

示例10: testAAAWarmup

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
@Test
public void testAAAWarmup() {
    Image src = new Image("file:/Users/amo/Pictures/April_Mai/DSCF5453.jpg");
    PixelReader reader = src.getPixelReader();

    int width = (int) src.getWidth();
    int height = (int) src.getHeight();

    long startTime = System.currentTimeMillis();
    for (int i = 0; i < 2; i++) {
        WritableImage dest = new WritableImage(width, height);
        PixelWriter writer = dest.getPixelWriter();

        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                // reading a pixel from src image,
                // then writing a pixel to dest image
                Color color = reader.getColor(x, y);
                writer.setColor(x, y, color);

                // this way is also OK
                int argb = reader.getArgb(x, y);
                writer.setArgb(x, y, argb);
            }
        }

    }


}
 
开发者ID:amoAHCP,项目名称:JavaOne2015JavaFXPitfalls,代码行数:31,代码来源:PixelWriterTest.java

示例11: copyImage

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
public Image copyImage(PixelReader reader, int imageWidth, int imageHeight, int offsetX, int offsetY) {
	WritableImage dest = new WritableImage(imageWidth, imageHeight);
	PixelWriter writer = dest.getPixelWriter();
	for (int x = 0; x < imageWidth; x++) {
		for (int y = 0; y < imageHeight; y++) {
			// reading a pixel from src image,
			// then writing a pixel to dest image
			int col = reader.getArgb(x + offsetX, y + offsetY);
			writer.setArgb(x, y, col);
		}
	}
	return dest;
}
 
开发者ID:rfrerich,项目名称:hex4j,代码行数:14,代码来源:TileMapImages.java

示例12: changeOpacity

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
/**
 * @param image
 * @param opacity
 *            value range from 0 to 255
 * @return
 */
static public WritableImage changeOpacity(Image image, int opacity) {
	int height = (int) image.getHeight();
	int width = (int) image.getWidth();
	WritableImage im2 = new WritableImage(width, height);
	PixelReader reader = image.getPixelReader();
	opacity = ((opacity & 0xFF) << 24);
	for (int y = 0; y < height; y++)
		for (int x = 0; x < width; x++) {
			int argb = reader.getArgb(x, y);
			argb = opacity | (argb & 0xFFFFFF);
			im2.getPixelWriter().setArgb(x, y, argb);
		}
	return im2;
}
 
开发者ID:lyrachord,项目名称:FX3DAndroid,代码行数:21,代码来源:ImagePalette.java

示例13: generateScratchBuffer

import javafx.scene.image.PixelReader; //导入方法依赖的package包/类
private int[][][] generateScratchBuffer(PixelReader pixelReader, int pixelRenderWidth, int height) {
    int[][][] out = new int[height][pixelRenderWidth][3];
    for (int y = 0; y < height; y++) {
        for (int x=0; x < pixelRenderWidth; x++) {
            int pixel = pixelReader.getArgb(x, y);
            out[y][x] = Palette.parseIntColor(pixel);
        }
    }
    return out;
}
 
开发者ID:badvision,项目名称:lawless-legends,代码行数:11,代码来源:ImageDitherEngine.java

示例14: overlay

import javafx.scene.image.PixelReader; //导入方法依赖的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


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