I want to read an image and print ARGB value of all pixels.
This is how I try to achieve that:
public static void main(String[] ar){ Image image = new Image("file:///C:/Users/PC2/Desktop/duke_44x80.png"); //ERROR HERE ImageView imageView = new ImageView(); imageView.setImage(image); PixelReader pixelReader = image.getPixelReader(); for(int x = 0; x < image.getWidth(); ++x){ for(int y = 0; y < image.getHeight(); ++y){ System.out.print(pixelReader.getArgb(x, y) + ", "); } System.out.println(); } } But when I try to run it, I get an error at line Image image = new Image(...);
Exception in thread "main" java.lang.RuntimeException: Internal graphics not initialized yet at javafx.graphics/com.sun.glass.ui.Screen.getScreens(Screen.java:70) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.getScreens(QuantumToolkit.java:699) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.getMaxRenderScale(QuantumToolkit.java:726) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.loadImage(QuantumToolkit.java:735) at javafx.graphics/javafx.scene.image.Image.loadImage(Image.java:1052) at javafx.graphics/javafx.scene.image.Image.initialize(Image.java:802) at javafx.graphics/javafx.scene.image.Image.<init>(Image.java:618) at test.core.MainCore.main(MainCore.java:11) How to fix this error?