當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。