3

I've got an application window using JavaFX. This window contains a simple WebView to display a HTML document. Inside the HTML document, there is a script tag, executing a Java function, which returns the pixels as int[]. I'm using the following code to draw the image onto the canvas:

var context = canvas.getContext('2d');
var imageData = context.createImageData(canvas.width, canvas.height);
var buffer8 = new Uint8ClampedArray(imageData.data.buffer);
var buffer32 = new Uint32Array(imageData.data.buffer);
buffer32.set(pixels);
context.putImageData(imageData, 0, 0);

This works, however performance is about 0.07 seconds per frame, giving me a total of ~ 15 FPS, using a 640x480 canvas currently. My goal is to get at last 30fps for 1920x1080 (currently 5 FPS), and even higher values. The only solution i come up with is to create/populate the whole buffer at once on the java side, but i have no idea how to manage that. Any help would be appreciated.

Andre Mohren
  • 303
  • 1
  • 3
  • 7
  • Instead of trying to pass an image to WebView, I suggest you create a Group with the WebView on the bottom and a WritableImage in an ImageView on top (positioned where you want it to overlay the WebView) and use a [PixelWriter](https://community.oracle.com/thread/2436712) or set the pixels of the Image (rather than a writable image, you could also create new images as needed and [set them into the ImageView](http://stackoverflow.com/questions/16721917/display-rtp-mjpeg) as you wish.) – jewelsea Aug 29 '16 at 22:45
  • Thats the fallback solution actualy. As this would make the goal i try to archive almost impossible: multiple images in layers with html decorated windows around them. – Andre Mohren Sep 04 '16 at 07:47

0 Answers0