Example usage for javafx.scene.canvas GraphicsContext drawImage

List of usage examples for javafx.scene.canvas GraphicsContext drawImage

Introduction

In this page you can find the example usage for javafx.scene.canvas GraphicsContext drawImage.

Prototype

public void drawImage(Image img, double x, double y) 

Source Link

Document

Draws an image at the given x, y position using the width and height of the given image.

Usage

From source file:Main.java

/**
 * Creates an image canvas with the given width and height.
 *//* w ww  .j av  a 2s  .c  o m*/
public static Canvas createImageCanvas(String url, double width, double height) {
    ImageView img = new ImageView(new Image(url, width, height, false, true));
    final Canvas canvas = new Canvas(width, height);
    final GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.drawImage(img.getImage(), 0, 0);

    return canvas;
}