We are using vlcj to capture a webcam video and display it on the user screen. We capture it frame by frame, a 1280x720 image at around 30fps.
Our app UI is entirely JavaFX, and we are having problems displaying said frame.
Using Swing, we would do something like:
BufferedImage image; //create compatible image
public void onDisplay(int[] rgbBuffer){
image.setRGB(0,0,width, height, rgbBuffer, 0, width);
myJPane.repaint();
}
But JavaFX's Image class offers no such methods, and creating a BufferedImage
just to convert it to a JavaFX Image
(by using Image.impl_fromPlatformImage()
) is highly costly.
Question: How does one create a JavaFX Image
, that can be set to an ImageView
, based on a rgb int[]
? Is there a better (as in "faster") way to display it?
This functionality is not yet part of the JavaFX platform - for now I believe you have to use the BufferedImage method you are currently using.
You can track the feature Image Ops request. Anybody can sign up for a jira account and vote for the issue/add comments/detail use cases/etc or provide input to the design on the JavaFX development mailing list.