I want to get the color for specific coordinates inside a
WritableImage snap = gc.getCanvas().snapshot(null, null);
snap.getPixelReader().getArgb(x, y); //This just gets the color without assigning it.
Canvas buffers the drawing instructions prescribed by invoking the methods of a
GraphicsContext. There are no pixels to read until the
Canvas is rendered in a later pulse, and the internal format of the instruction buffer is not exposed in the API.
As an alternative, consider drawing into a
BufferedImage, illustrated here, which allows access to the image's pixels directly and via its
WritableRaster. Adding the following line to this complete example outputs the expected value for opaque red in ARGB order: