类javafx.scene.image.WritableImage源码实例Demo

下面列出了怎么用javafx.scene.image.WritableImage的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: chart-fx   文件: WriteFxImage.java
/**
 * copy the given Image to a WritableImage
 * 
 * @param image the input image
 * @return clone of image
 */
public static WritableImage clone(Image image) {
    int height = (int) image.getHeight();
    int width = (int) image.getWidth();
    WritableImage writableImage = WritableImageCache.getInstance().getImage(width, height);
    PixelWriter pixelWriter = writableImage.getPixelWriter();
    if (pixelWriter == null) {
        throw new IllegalStateException(IMAGE_PIXEL_READER_NOT_AVAILABLE);
    }

    final PixelReader pixelReader = image.getPixelReader();
    if (pixelReader == null) {
        throw new IllegalStateException(IMAGE_PIXEL_READER_NOT_AVAILABLE);
    }
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            Color color = pixelReader.getColor(x, y);
            pixelWriter.setColor(x, y, color);
        }
    }
    return writableImage;
}
 
源代码2 项目: tools-ocr   文件: ExtendedAnimatedFlowContainer.java
private void updatePlaceholder(Node newView) {
    if (view.getWidth() > 0 && view.getHeight() > 0) {
        SnapshotParameters parameters = new SnapshotParameters();
        parameters.setFill(Color.TRANSPARENT);
        Image placeholderImage = view.snapshot(parameters,
                new WritableImage((int) view.getWidth(), (int) view.getHeight()));
        placeholder.setImage(placeholderImage);
        placeholder.setFitWidth(placeholderImage.getWidth());
        placeholder.setFitHeight(placeholderImage.getHeight());
    } else {
        placeholder.setImage(null);
    }
    placeholder.setVisible(true);
    placeholder.setOpacity(1.0);
    view.getChildren().setAll(placeholder, newView);
    placeholder.toFront();
}
 
源代码3 项目: chart-fx   文件: PeriodicScreenCapture.java
public void performScreenCapture() {
    try {
        final WritableImage image = primaryScene.snapshot(null);
        // open save in separate thread
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                writeImage(image);
            }
        }, 0);

        LOGGER.debug("this is called periodic on UI thread");
    } catch (final Exception e) {
        // continue at all costs
        LOGGER.error("error while writing screen captured image to file", e);
    }
}
 
源代码4 项目: latexdraw   文件: SVGDocumentGenerator.java
/**
 * Creates a thumbnail from the given selection in the given file.
 * @param templateFile The file of the future thumbnail.
 * @param selection The set of shapes composing the template.
 */
private void createTemplateThumbnail(final File templateFile, final javafx.scene.Group selection) {
	final Bounds bounds = selection.getBoundsInParent();
	final double scale = 70d / Math.max(bounds.getWidth(), bounds.getHeight());
	final WritableImage img = new WritableImage((int) (bounds.getWidth() * scale), (int) (bounds.getHeight() * scale));
	final SnapshotParameters snapshotParameters = new SnapshotParameters();

	snapshotParameters.setFill(Color.WHITE);
	snapshotParameters.setTransform(new Scale(scale, scale));
	selection.snapshot(snapshotParameters, img);

	final BufferedImage bufferedImage = SwingFXUtils.fromFXImage(img, null);

	try {
		ImageIO.write(bufferedImage, "png", templateFile);  //NON-NLS
	}catch(final IOException ex) {
		BadaboomCollector.INSTANCE.add(ex);
	}
	bufferedImage.flush();
}
 
源代码5 项目: chart-fx   文件: WritableImageCacheTests.java
@Test
public void testIterators() {
    final WritableImageCache cache = new WritableImageCache();
    assertEquals(0, cache.size(), "initial cache size");

    for (int i = 0; i < N_INITIAL_CACHE_OBJECTS; i++) {
        cache.add(new WritableImage(N_IMAGE_WIDTH, N_IMAGE_HEIGHT));
    }
    assertEquals(N_INITIAL_CACHE_OBJECTS, cache.size(), "allocated dummy arrays -- N.B. if this fails the testing environment likely has not have enough memory");

    final java.util.Iterator<WritableImage> iter = cache.iterator();
    int count = 0;
    while (iter.hasNext()) {
        final WritableImage element = iter.next();
        if (count == 0 || element == null) {
            iter.remove();
        }
        count++;
    }
    assertEquals(N_INITIAL_CACHE_OBJECTS, count);
}
 
源代码6 项目: chart-fx   文件: WritableImageCacheTests.java
private static double performanceCheckCached() {
    final WritableImageCache cache = new WritableImageCache();
    cache.add(new WritableImage(N_IMAGE_WIDTH, N_IMAGE_HEIGHT));

    final long start = System.nanoTime();
    for (int i = 0; i < N_ITERATIONS; i++) {
        WritableImage image = cache.getImage(N_IMAGE_WIDTH, N_IMAGE_HEIGHT);

        // simple check to minimise JIT optimisations
        if ((int) image.getWidth() != N_IMAGE_WIDTH) {
            throw new IllegalStateException("should not occur");
        }

        cache.add(image);
        image = null;
    }

    final long stop = System.nanoTime();

    return (stop - start) / (double) N_ITERATIONS;
}
 
源代码7 项目: chart-fx   文件: WritableImageCacheTests.java
private static double performanceCheckClassic() {
    final long start = System.nanoTime();
    for (int i = 0; i < N_ITERATIONS; i++) {
        WritableImage image = new WritableImage(N_IMAGE_WIDTH, N_IMAGE_HEIGHT);

        // simple check to minimise JIT optimisations
        if ((int) image.getWidth() != N_IMAGE_WIDTH) {
            throw new IllegalStateException("should not occur");
        }

        image = null;
    }

    final long stop = System.nanoTime();

    return (stop - start) / (double) N_ITERATIONS;
}
 
源代码8 项目: RadialFx   文件: RadialMovieMenuDemo.java
private void takeSnapshot(final Scene scene) {
// Take snapshot of the scene
final WritableImage writableImage = scene.snapshot(null);

// Write snapshot to file system as a .png image
final File outFile = new File("snapshot/radialmenu-snapshot-"
	+ snapshotCounter + ".png");
outFile.getParentFile().mkdirs();
try {
    ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png",
	    outFile);
} catch (final IOException ex) {
    System.out.println(ex.getMessage());
}

snapshotCounter++;
   }
 
源代码9 项目: metastone   文件: DigitFactory.java
public static void saveAllDigits() {
	Stage stage = new Stage(StageStyle.TRANSPARENT);
	DigitTemplate root = new DigitTemplate();
	Scene scene = new Scene(root);
	stage.setScene(scene);
	stage.show();

	SnapshotParameters snapshotParams = new SnapshotParameters();
	snapshotParams.setFill(Color.TRANSPARENT);
	root.digit.setText("-");
	for (int i = 0; i <= 10; i++) {
		WritableImage image = root.digit.snapshot(snapshotParams, null);

		File file = new File("src/" + IconFactory.RESOURCE_PATH + "/img/common/digits/" + root.digit.getText() + ".png");

		try {
			ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
		} catch (IOException e) {
			e.printStackTrace();
		}
		root.digit.setText("" + i);
	}

	stage.close();
}
 
源代码10 项目: oim-fx   文件: HeadImagePanel.java
private void setGrayImage(Image image) {
	if (null != image && !image.isBackgroundLoading()) {
		int imageWidth = (int) image.getWidth();
		int imageHeight = (int) image.getHeight();
		if (imageWidth > 0 && imageHeight > 0) {
			PixelReader pixelReader = image.getPixelReader();
			grayImage = new WritableImage(imageWidth, imageHeight);
			PixelWriter pixelWriter = grayImage.getPixelWriter();
			if (null != pixelWriter && null != pixelReader) {
				for (int y = 0; y < imageHeight; y++) {
					for (int x = 0; x < imageWidth; x++) {
						Color color = pixelReader.getColor(x, y);
						color = color.grayscale();
						pixelWriter.setColor(x, y, color);
					}
				}
			}
		} else {
			grayImage = null;
		}
	} else {
		grayImage = null;
	}
}
 
源代码11 项目: oim-fx   文件: HeadImageItemPane.java
private void setGrayImage(Image image) {
	if (null != image&&!image.isBackgroundLoading()) {
		int imageWidth = (int) image.getWidth();
		int imageHeight = (int) image.getHeight();
		if (imageWidth > 0 && imageHeight > 0) {
			PixelReader pixelReader = image.getPixelReader();
			grayImage = new WritableImage(imageWidth, imageHeight);
			PixelWriter pixelWriter = grayImage.getPixelWriter();
			for (int y = 0; y < imageHeight; y++) {
				for (int x = 0; x < imageWidth; x++) {
					Color color = pixelReader.getColor(x, y);
					color = color.grayscale();
					pixelWriter.setColor(x, y, color);
				}
			}
		} else {
			grayImage = null;
		}
	} else {
		grayImage = null;
	}
}
 
源代码12 项目: jace   文件: VideoDHGR.java
protected void displayLores(WritableImage screen, int xOffset, int y, int rowAddress) {
    int c1 = ((RAM128k) computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset) & 0x0FF;
    if ((y & 7) < 4) {
        c1 &= 15;
    } else {
        c1 >>= 4;
    }
    Color color = Palette.color[c1];
    // Unrolled loop, faster
    PixelWriter writer = screen.getPixelWriter();
    int xx = xOffset * 14;
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
    writer.setColor(xx++, y, color);
}
 
@Override
@BackgroundThread
protected void writeData(@NotNull final VarTable vars, final @NotNull Path resultFile) throws IOException {
    super.writeData(vars, resultFile);

    final Color color = UiUtils.from(vars.get(PROP_COLOR, ColorRGBA.class));

    final int width = vars.getInteger(PROP_WIDTH);
    final int height = vars.getInteger(PROP_HEIGHT);

    final WritableImage writableImage = new WritableImage(width, height);
    final PixelWriter pixelWriter = writableImage.getPixelWriter();

    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            pixelWriter.setColor(i, j, color);
        }
    }

    final BufferedImage bufferedImage = SwingFXUtils.fromFXImage(writableImage, null);

    try (final OutputStream out = Files.newOutputStream(resultFile)) {
        ImageIO.write(bufferedImage, "png", out);
    }
}
 
源代码14 项目: JFoenix   文件: ExtendedAnimatedFlowContainer.java
private void updatePlaceholder(Node newView) {
    if (view.getWidth() > 0 && view.getHeight() > 0) {
        SnapshotParameters parameters = new SnapshotParameters();
        parameters.setFill(Color.TRANSPARENT);
        Image placeholderImage = view.snapshot(parameters,
            new WritableImage((int) view.getWidth(), (int) view.getHeight()));
        placeholder.setImage(placeholderImage);
        placeholder.setFitWidth(placeholderImage.getWidth());
        placeholder.setFitHeight(placeholderImage.getHeight());
    } else {
        placeholder.setImage(null);
    }
    placeholder.setVisible(true);
    placeholder.setOpacity(1.0);
    view.getChildren().setAll(placeholder, newView);
    placeholder.toFront();
}
 
源代码15 项目: Quelea   文件: MobileServerPreference.java
private Image getQRImage() {
    if (qrImage == null) {
        QRCodeWriter qrCodeWriter = new QRCodeWriter();
        int qrWidth = 500;
        int qrHeight = 500;
        BitMatrix byteMatrix = null;
        try {
            byteMatrix = qrCodeWriter.encode(getMLURL(), BarcodeFormat.QR_CODE, qrWidth, qrHeight);
        } catch (WriterException ex) {
            LOGGER.log(Level.WARNING, "Error writing QR code", ex);
        }
        qrImage = MatrixToImageWriter.toBufferedImage(byteMatrix);
    }
    WritableImage fxImg = new WritableImage(500, 500);
    SwingFXUtils.toFXImage(qrImage, fxImg);
    return fxImg;
}
 
源代码16 项目: mcaselector   文件: NBTTreeView.java
private void onDragDetected(MouseEvent e) {
	if (getTreeItem() == getTreeView().getRoot()) {
		return;
	}
	Dragboard db = startDragAndDrop(TransferMode.MOVE);
	WritableImage wi = new WritableImage((int) getWidth(), (int) getHeight());
	Image dbImg = snapshot(null, wi);
	db.setDragView(dbImg);
	if (USE_DRAGVIEW_OFFSET) {
		db.setDragViewOffsetX(getWidth() / 2);
		db.setDragViewOffsetY(getHeight() / 2);
	}
	ClipboardContent cbc = new ClipboardContent();
	cbc.put(CLIPBOARD_DATAFORMAT, true);
	db.setContent(cbc);
	dragboardContent = getTreeItem();
	e.consume();
}
 
源代码17 项目: charts   文件: HeatMap.java
public HeatMap(final double WIDTH, final double HEIGHT, ColorMapping COLOR_MAPPING, final double SPOT_RADIUS, final boolean FADE_COLORS, final double HEAT_MAP_OPACITY, final OpacityDistribution OPACITY_DISTRIBUTION) {
    super();
    SNAPSHOT_PARAMETERS.setFill(Color.TRANSPARENT);
    spotList            = new ArrayList<>();
    spotImages          = new HashMap<>();
    colorMapping        = COLOR_MAPPING;
    mappingGradient     = colorMapping.getGradient();
    fadeColors          = FADE_COLORS;
    radius              = SPOT_RADIUS;
    opacityDistribution = OPACITY_DISTRIBUTION;
    spotImage           = createSpotImage(radius, opacityDistribution);
    monochrome          = new Canvas(WIDTH, HEIGHT);
    ctx                 = monochrome.getGraphicsContext2D();
    monochromeImage     = new WritableImage((int) WIDTH, (int) HEIGHT);
    setImage(heatMap);
    setMouseTransparent(true);
    setOpacity(HEAT_MAP_OPACITY);
    registerListeners();
}
 
源代码18 项目: RadialFx   文件: FuturistDemo.java
private void takeSnapshot(final Scene scene) {
// Take snapshot of the scene
final WritableImage writableImage = scene.snapshot(null);

// Write snapshot to file system as a .png image
final File outFile = new File("snapshot/"+getClass().getSimpleName().toLowerCase()+"-"
	+ snapshotCounter + ".png");
outFile.getParentFile().mkdirs();
try {
    ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png",
	    outFile);
} catch (final IOException ex) {
    System.out.println(ex.getMessage());
}

snapshotCounter++;
   }
 
源代码19 项目: MyBox   文件: FxmlImageManufacture.java
public static Image cropInsideFx(Image image, DoubleShape shape, Color bgColor) {
    if (image == null || shape == null || !shape.isValid()
            || bgColor == null) {
        return image;
    }
    int width = (int) image.getWidth();
    int height = (int) image.getHeight();
    PixelReader pixelReader = image.getPixelReader();
    WritableImage newImage = new WritableImage(width, height);
    PixelWriter pixelWriter = newImage.getPixelWriter();
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            if (shape.include(x, y)) {
                pixelWriter.setColor(x, y, bgColor);
            } else {
                pixelWriter.setColor(x, y, pixelReader.getColor(x, y));
            }
        }
    }
    return newImage;
}
 
源代码20 项目: latexdraw   文件: HelperTest.java
default <T extends Node> void assertNotEqualsSnapshot(final T node, final CmdFXVoid toExecBetweenSnap) {
	Bounds bounds = node.getBoundsInLocal();
	final SnapshotParameters params = new SnapshotParameters();

	final WritableImage oracle = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
	Platform.runLater(() -> node.snapshot(params, oracle));
	WaitForAsyncUtils.waitForFxEvents();

	if(toExecBetweenSnap != null) {
		toExecBetweenSnap.execute();
	}

	bounds = node.getBoundsInLocal();
	final WritableImage observ = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
	Platform.runLater(() -> node.snapshot(params, observ));
	WaitForAsyncUtils.waitForFxEvents();

	assertNotEquals("The two snapshots do not differ.", 100d, computeSnapshotSimilarity(oracle, observ), 0.001);
}
 
源代码21 项目: MyBox   文件: FxmlImageManufacture.java
public static Image horizontalImage(Image image) {
    int width = (int) image.getWidth();
    int height = (int) image.getHeight();
    PixelReader pixelReader = image.getPixelReader();
    WritableImage newImage = new WritableImage(width, height);
    PixelWriter pixelWriter = newImage.getPixelWriter();

    for (int j = 0; j < height; ++j) {
        int l = 0, r = width - 1;
        while (l <= r) {
            Color cl = pixelReader.getColor(l, j);
            Color cr = pixelReader.getColor(r, j);
            pixelWriter.setColor(l, j, cr);
            pixelWriter.setColor(r, j, cl);
            l++;
            r--;
        }
    }
    return newImage;
}
 
源代码22 项目: MyBox   文件: FxmlControl.java
public static Image snap(Node node) {
    try {
        final Bounds bounds = node.getLayoutBounds();
        double scale = dpiScale();
        int imageWidth = (int) Math.round(bounds.getWidth() * scale);
        int imageHeight = (int) Math.round(bounds.getHeight() * scale);
        final SnapshotParameters snapPara = new SnapshotParameters();
        snapPara.setFill(Color.TRANSPARENT);
        snapPara.setTransform(javafx.scene.transform.Transform.scale(scale, scale));
        WritableImage snapshot = new WritableImage(imageWidth, imageHeight);
        snapshot = node.snapshot(snapPara, snapshot);
        return snapshot;
    } catch (Exception e) {
        logger.debug(e.toString());
        return null;
    }

}
 
源代码23 项目: marathonv5   文件: ImageOperatorSample.java
private static void renderImage(WritableImage img, double gridSize, double hueFactor, double hueOffset) {
    PixelWriter pw = img.getPixelWriter();
    double w = img.getWidth();
    double h = img.getHeight();
    double xRatio = 0.0;
    double yRatio = 0.0;
    double hue = 0.0;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            xRatio = x/w;
            yRatio = y/h;
            hue = Math.sin(yRatio*(gridSize*Math.PI))*Math.sin(xRatio*(gridSize*Math.PI))*Math.tan(hueFactor/20.0)*360.0 + hueOffset;
            Color c = Color.hsb(hue, 1.0, 1.0);
            pw.setColor(x, y, c);
        }
    }
}
 
源代码24 项目: marathonv5   文件: ImageOperatorSample.java
private static void renderImage(WritableImage img, double gridSize, double hueFactor, double hueOffset) {
    PixelWriter pw = img.getPixelWriter();
    double w = img.getWidth();
    double h = img.getHeight();
    double xRatio = 0.0;
    double yRatio = 0.0;
    double hue = 0.0;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            xRatio = x/w;
            yRatio = y/h;
            hue = Math.sin(yRatio*(gridSize*Math.PI))*Math.sin(xRatio*(gridSize*Math.PI))*Math.tan(hueFactor/20.0)*360.0 + hueOffset;
            Color c = Color.hsb(hue, 1.0, 1.0);
            pw.setColor(x, y, c);
        }
    }
}
 
源代码25 项目: Medusa   文件: Helper.java
public static final Image createNoiseImage(final double WIDTH, final double HEIGHT, final Color DARK_COLOR, final Color BRIGHT_COLOR, final double ALPHA_VARIATION_IN_PERCENT) {
    if (Double.compare(WIDTH, 0) <= 0 || Double.compare(HEIGHT, 0) <= 0) return null;
    int                 width                   = (int) WIDTH;
    int                 height                  = (int) HEIGHT;
    double              alphaVariationInPercent = Helper.clamp(0.0, 100.0, ALPHA_VARIATION_IN_PERCENT);
    final WritableImage IMAGE                   = new WritableImage(width, height);
    final PixelWriter   PIXEL_WRITER            = IMAGE.getPixelWriter();
    final Random        BW_RND                  = new Random();
    final Random        ALPHA_RND               = new Random();
    final double        ALPHA_START             = alphaVariationInPercent / 100 / 2;
    final double        ALPHA_VARIATION         = alphaVariationInPercent / 100;
    for (int y = 0 ; y < height ; y++) {
        for (int x = 0 ; x < width ; x++) {
            final Color  NOISE_COLOR = BW_RND.nextBoolean() ? BRIGHT_COLOR : DARK_COLOR;
            final double NOISE_ALPHA = Helper.clamp(0.0, 1.0, ALPHA_START + ALPHA_RND.nextDouble() * ALPHA_VARIATION);
            PIXEL_WRITER.setColor(x, y, Color.color(NOISE_COLOR.getRed(), NOISE_COLOR.getGreen(), NOISE_COLOR.getBlue(), NOISE_ALPHA));
        }
    }
    return IMAGE;
}
 
源代码26 项目: phoebus   文件: ImageScaling.java
@Override
public void start(final Stage stage)
{
    // Image with red border
    final WritableImage image = new WritableImage(WIDTH, HEIGHT);
    final PixelWriter writer = image.getPixelWriter();
    for (int x=0; x<WIDTH; ++x)
    {
        writer.setColor(x, 0, Color.RED);
        writer.setColor(x, HEIGHT-1, Color.RED);
    }
    for (int y=0; y<HEIGHT; ++y)
    {
        writer.setColor(0, y, Color.RED);
        writer.setColor(WIDTH-1, y, Color.RED);
    }

    // Draw into canvas, scaling 'up'
    final Canvas canvas = new Canvas(800, 600);
    canvas.getGraphicsContext2D().drawImage(image, 0, 0, canvas.getWidth(), canvas.getHeight());

    final Scene scene = new Scene(new Group(canvas), canvas.getWidth(), canvas.getHeight());
    stage.setScene(scene);
    stage.show();
}
 
源代码27 项目: Enzo   文件: LcdSkin.java
private Image createNoiseImage(final double WIDTH, final double HEIGHT, final Color DARK_COLOR, final Color BRIGHT_COLOR, final double ALPHA_VARIATION_IN_PERCENT) {
    int width  = WIDTH <= 0 ? (int) PREFERRED_WIDTH : (int) WIDTH;
    int height = HEIGHT <= 0 ? (int) PREFERRED_HEIGHT : (int) HEIGHT;
    double alphaVariationInPercent      = getSkinnable().clamp(0, 100, ALPHA_VARIATION_IN_PERCENT);
    final WritableImage IMAGE           = new WritableImage(width, height);
    final PixelWriter   PIXEL_WRITER    = IMAGE.getPixelWriter();
    final Random        BW_RND          = new Random();
    final Random        ALPHA_RND       = new Random();
    final double        ALPHA_START     = alphaVariationInPercent / 100 / 2;
    final double        ALPHA_VARIATION = alphaVariationInPercent / 100;
    Color noiseColor;
    double noiseAlpha;
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            noiseColor = BW_RND.nextBoolean() == true ? BRIGHT_COLOR : DARK_COLOR;
            noiseAlpha = getSkinnable().clamp(0, 1, ALPHA_START + ALPHA_RND.nextDouble() * ALPHA_VARIATION);
            PIXEL_WRITER.setColor(x, y, Color.color(noiseColor.getRed(), noiseColor.getGreen(), noiseColor.getBlue(), noiseAlpha));
        }
    }
    return IMAGE;
}
 
源代码28 项目: jace   文件: VideoDHGR.java
protected void displayDoubleHires(WritableImage screen, int xOffset, int y, int rowAddress) {
    // Skip odd columns since this does two at once
    if ((xOffset & 0x01) == 1) {
        return;
    }
    int b1 = ((RAM128k) computer.getMemory()).getAuxVideoMemory().readByte(rowAddress + xOffset    );
    int b2 = ((RAM128k) computer.getMemory()).getMainMemory()    .readByte(rowAddress + xOffset    );
    int b3 = ((RAM128k) computer.getMemory()).getAuxVideoMemory().readByte(rowAddress + xOffset + 1);
    int b4 = ((RAM128k) computer.getMemory()).getMainMemory()    .readByte(rowAddress + xOffset + 1);
    int useColOffset = xOffset << 1;
    // This shouldn't be necessary but prevents an index bounds exception when graphics modes are flipped (Race condition?)
    if (useColOffset >= 77) {
        useColOffset = 76;
    }
    useColor[useColOffset    ] = (b1 & 0x80) != 0;
    useColor[useColOffset + 1] = (b2 & 0x80) != 0;
    useColor[useColOffset + 2] = (b3 & 0x80) != 0;
    useColor[useColOffset + 3] = (b4 & 0x80) != 0;
    int dhgrWord  = (0x07f & b1)      ;
        dhgrWord |= (0x07f & b2) <<  7;
        dhgrWord |= (0x07f & b3) << 14;
        dhgrWord |= (0x07f & b4) << 21;
    showDhgr(screen, TIMES_14[xOffset], y, dhgrWord);
}
 
源代码29 项目: chart-fx   文件: ContourDataSetRenderer.java
private void drawHeatMap(final GraphicsContext gc, final ContourDataSetCache lCache) {
    final long start = ProcessingProfiler.getTimeStamp();

    // N.B. works only since OpenJFX 12!! fall-back for JDK8 is the old implementation
    gc.setImageSmoothing(isSmooth());

    // process z quantisation to colour transform
    final WritableImage image = localCache.convertDataArrayToImage(lCache.reduced, lCache.xSize, lCache.ySize, getColorGradient());
    ProcessingProfiler.getTimeDiff(start, "color map");

    gc.drawImage(image, lCache.xDataPixelMin, lCache.yDataPixelMin, lCache.xDataPixelRange, lCache.yDataPixelRange);

    localCache.add(image);
    ProcessingProfiler.getTimeDiff(start, "drawHeatMap");
}
 
源代码30 项目: chart-fx   文件: ContourDataSetRenderer.java
private void drawHexagonHeatMap(final GraphicsContext gc, final ContourDataSetCache lCache) {
    final long start = ProcessingProfiler.getTimeStamp();

    // process z quantisation to colour transform
    final WritableImage image = localCache.convertDataArrayToImage(lCache.reduced, lCache.xSize, lCache.ySize, getColorGradient());

    final int tileSize = Math.max(getMinHexTileSizeProperty(), (int) lCache.xAxisWidth / lCache.xSize);
    final int nWidthInTiles = (int) (lCache.xAxisWidth / (tileSize * Math.sqrt(3))) + 1;

    final HexagonMap map2 = new HexagonMap(tileSize, image, nWidthInTiles, (q, r, imagePixelColor, map) -> {
        final Hexagon h = new Hexagon(q, r);
        h.setFill(imagePixelColor);
        h.setStroke(imagePixelColor);

        h.setStrokeWidth(0.5);
        map.addHexagon(h);
    });
    localCache.add(image);

    ProcessingProfiler.getTimeDiff(start, "drawHexagonMap - prepare");
    final double scaleX = lCache.xDataPixelRange / lCache.xAxisWidth;
    final double scaleY = lCache.yDataPixelRange / lCache.yAxisHeight;

    gc.save();
    gc.translate(lCache.xDataPixelMin, lCache.yDataPixelMin);
    gc.scale(scaleX, scaleY);

    map2.render(gc.getCanvas());
    gc.restore();

    // gc.drawImage(image, lCache.xDataPixelMin, lCache.yDataPixelMin, lCache.xDataPixelRange,
    // lCache.yDataPixelRange);

    ProcessingProfiler.getTimeDiff(start, "drawHexagonMap");
}
 
 类所在包
 同包方法