Thursday, December 20, 2012

JavaFX example, get PixelReader for Image

Interface javafx.scene.image.PixelReader defines methods for retrieving the pixel data from an Image or other surface containing pixels. To get PixelReader, call getPixelReader() method of the associated Image object.

package testjavafx;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelReader;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

 * @web
public class TestJavaFX extends Application {
    public void start(Stage primaryStage) {
        Text text = new Text();
        Image image = new Image("");
        ImageView imageView = new ImageView();
        PixelReader pixelReader = image.getPixelReader();
        text.setText("PixelFormat: " + pixelReader.getPixelFormat());
        VBox vBox = new VBox();
        vBox.getChildren().addAll(imageView, text);

        StackPane root = new StackPane();
        Scene scene = new Scene(root, 500, 300);

    public static void main(String[] args) {

JavaFX example, get PixelReader for Image
JavaFX example, get PixelReader for Image

No comments:

Post a Comment