humbleui

chromalchemy 2022-09-26T17:19:30.642909Z

Can I save a Humbleui window, or sub-rect as a bitmap/png programmatically? I see there there might be something close to .. (-> app event surface canvas .saveScreenshot)

Niki 2022-09-27T12:22:42.066179Z

You can get image with (-> canvas .getSurface .makeImageSnapshot)

Niki 2022-09-27T12:23:45.994929Z

Then (-> image (.encodeToData EncodedImageFormat/PNG) .getBytes)

Niki 2022-09-27T12:24:00.241619Z

and save to file

chromalchemy 2022-09-27T12:46:04.640659Z

Thanks. And you apply that to any element, or to the “window”?

Niki 2022-09-27T14:04:39.687179Z

You get canvas inside -draw method in a component

Niki 2022-09-27T14:06:54.832549Z

If you start from window, well, take a look at this example https://github.com/HumbleUI/Skija/blob/ad8c71118d2758cbd8fa1b4509c6bb228257ba05/examples/bitmap/src/RenderToBitmap.java

Niki 2022-09-27T14:07:25.718909Z

One option might be to create surface in memory, take canvas from it and the render app on that surface instead of one allocated by JWM

chromalchemy 2022-09-27T22:00:03.996099Z

Ok will try it out, thanks!