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


Java WritableImage.getPixelReader方法代码示例

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


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

示例1: update

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

示例2: startTimer

import javafx.scene.image.WritableImage; //导入方法依赖的package包/类
private void startTimer()
{
    timer = new AnimationTimer()
    {

        @Override
        public void handle(long now)
        {
            WritableImage image = dash.snapshot(new SnapshotParameters(), null);
            WritableImage imageCrop = new WritableImage(image.getPixelReader(), (int) getLayoutX(), (int) getLayoutY(), (int) getPrefWidth(), (int) getPrefHeight());
            view.setImage(imageCrop);
        }
    };

    timer.start();
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:17,代码来源:FrostedPanel.java

示例3: transferPixels

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

示例4: transferPixels

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

示例5: paint

import javafx.scene.image.WritableImage; //导入方法依赖的package包/类
@Override
public void paint(Canvas canvas, Point2D start, Point2D end) {
    WritableImage snapshot = canvas.snapshot(null, null);
    PixelReader reader = snapshot.getPixelReader();

    PaintApplication.getModel().setColor(reader.getColor((int) start.getX(), (int) start.getY()));
}
 
开发者ID:jointry,项目名称:jointry,代码行数:8,代码来源:PtSpuit.java

示例6: paint

import javafx.scene.image.WritableImage; //导入方法依赖的package包/类
@Override
public void paint(Canvas canvas, Point2D start, Point2D end) {
    SnapshotParameters params = new SnapshotParameters();
    params.setFill(Color.TRANSPARENT); //透過色をそのまま取得するため
    WritableImage snapshot = canvas.snapshot(params, null);

    //編集のためRWを取得
    PixelWriter writer = snapshot.getPixelWriter();
    PixelReader reader = snapshot.getPixelReader();

    Color fillColor = PaintApplication.getModel().getColor();
    Color seedColor = reader.getColor((int) start.getX(), (int) start.getY());

    //塗潰す色と同じであればなにもしない
    if (fillColor.equals(seedColor)) return;

    //塗りつぶす最大範囲
    double width = canvas.getWidth();
    double height = canvas.getHeight();

    //塗りつぶす位置リスト
    LinkedList<Point> queue = new LinkedList();
    queue.add(new Point((int) start.getX(), (int) start.getY()));

    while (queue.peek() != null) {
        Point point = queue.poll();

        //塗りつぶし対象の色ではないため
        if (!reader.getColor(point.x, point.y).equals(seedColor)) continue;

        writer.setColor(point.x, point.y, fillColor); //実際の塗りつぶし処理

        //上下左右のdotをキューへ登録し塗潰す色を検索
        if (point.x + 1 < width) queue.add(new Point(point.x + 1, point.y));
        if (point.y + 1 < height) queue.add(new Point(point.x, point.y + 1));
        if (point.x - 1 >= 0) queue.add(new Point(point.x - 1, point.y));
        if (point.y - 1 >= 0) queue.add(new Point(point.x, point.y - 1));
    }

    //加工済みの画像を再描画
    GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.drawImage(snapshot, 0, 0);
}
 
开发者ID:jointry,项目名称:jointry,代码行数:44,代码来源:PtFill.java


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