Search in sources :

Example 71 with WritableImage

use of javafx.scene.image.WritableImage in project JFoenix by jfoenixadmin.

the class JFXColorPickerUI method getSLCricle.

private Image getSLCricle(int width, int height) {
    WritableImage raster = new WritableImage(width, height);
    PixelWriter pixelWriter = raster.getPixelWriter();
    Point2D center = new Point2D((double) width / 2, (double) height / 2);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            double dy = x - center.getX();
            double dx = y - center.getY();
            pixelWriter.setColor(x, y, getColor(dx, dy));
        }
    }
    return raster;
}
Also used : WritableImage(javafx.scene.image.WritableImage) Point2D(javafx.geometry.Point2D) PixelWriter(javafx.scene.image.PixelWriter)

Example 72 with WritableImage

use of javafx.scene.image.WritableImage in project jgnash by ccavanaugh.

the class ChartUtilities method takeSnapshot.

private static WritableImage takeSnapshot(final Pane pane) {
    Map<Chart, Boolean> animationMap = new HashMap<>();
    // Need to disable chart animations for printing
    pane.getChildren().stream().filter(node -> node instanceof Chart).forEach(node -> {
        animationMap.put((Chart) node, ((Chart) node).getAnimated());
        // Need to disable animation for printing
        ((Chart) node).setAnimated(false);
    });
    final SnapshotParameters snapshotParameters = new SnapshotParameters();
    snapshotParameters.setTransform(new Scale(SNAPSHOT_SCALE_FACTOR, SNAPSHOT_SCALE_FACTOR));
    final WritableImage image = pane.snapshot(snapshotParameters, null);
    // Restore animation
    for (Map.Entry<Chart, Boolean> entry : animationMap.entrySet()) {
        entry.getKey().setAnimated(entry.getValue());
    }
    return image;
}
Also used : StaticUIMethods(jgnash.uifx.StaticUIMethods) MainView(jgnash.uifx.views.main.MainView) WritableImage(javafx.scene.image.WritableImage) IOException(java.io.IOException) HashMap(java.util.HashMap) SnapshotParameters(javafx.scene.SnapshotParameters) Chart(javafx.scene.chart.Chart) File(java.io.File) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) FileChooser(javafx.stage.FileChooser) ResourceUtils(jgnash.resource.util.ResourceUtils) Clipboard(javafx.scene.input.Clipboard) Locale(java.util.Locale) ImageView(javafx.scene.image.ImageView) FileUtils(jgnash.util.FileUtils) Map(java.util.Map) ImageIO(javax.imageio.ImageIO) SwingFXUtils(javafx.embed.swing.SwingFXUtils) Scale(javafx.scene.transform.Scale) ClipboardContent(javafx.scene.input.ClipboardContent) Pane(javafx.scene.layout.Pane) WritableImage(javafx.scene.image.WritableImage) SnapshotParameters(javafx.scene.SnapshotParameters) HashMap(java.util.HashMap) Scale(javafx.scene.transform.Scale) HashMap(java.util.HashMap) Map(java.util.Map) Chart(javafx.scene.chart.Chart)

Example 73 with WritableImage

use of javafx.scene.image.WritableImage in project testing-video by testing-av.

the class FxImage method overlay.

public static void overlay(Consumer<WritableImage> consumer, FrameBuffer fb) {
    WritableImage image = new WritableImage(fb.Y.width, fb.Y.height);
    runAndWait(() -> consumer.accept(image));
    overlay(image, fb);
}
Also used : WritableImage(javafx.scene.image.WritableImage)

Example 74 with WritableImage

use of javafx.scene.image.WritableImage in project jvarkit by lindenb.

the class SimplePlot method saveImageAs.

/**
 * save char in file
 */
private void saveImageAs(final Chart chart, final File file) throws IOException {
    final WritableImage image = chart.snapshot(new SnapshotParameters(), null);
    final String format = (file.getName().toLowerCase().endsWith(".png") ? "png" : "jpg");
    ImageIO.write(SwingFXUtils.fromFXImage(image, null), format, file);
}
Also used : WritableImage(javafx.scene.image.WritableImage) SnapshotParameters(javafx.scene.SnapshotParameters)

Aggregations

WritableImage (javafx.scene.image.WritableImage)74 SnapshotParameters (javafx.scene.SnapshotParameters)26 PixelWriter (javafx.scene.image.PixelWriter)23 PixelReader (javafx.scene.image.PixelReader)13 IOException (java.io.IOException)12 Color (javafx.scene.paint.Color)11 BufferedImage (java.awt.image.BufferedImage)9 File (java.io.File)8 Image (javafx.scene.image.Image)7 ImageView (javafx.scene.image.ImageView)7 Point2D (javafx.geometry.Point2D)6 Group (javafx.scene.Group)5 Random (java.util.Random)4 Canvas (javafx.scene.canvas.Canvas)4 GraphicsContext (javafx.scene.canvas.GraphicsContext)4 Texture (com.almasb.fxgl.texture.Texture)3 OutputStream (java.io.OutputStream)3 Scene (javafx.scene.Scene)3 Background (javafx.scene.layout.Background)3 Scale (javafx.scene.transform.Scale)3