RFR: JDK-8015739: Background of JInternalFrame is located out of JInternalFrame [v4]
Alexey Ivanov
aivanov at openjdk.org
Tue Oct 4 18:52:34 UTC 2022
On Tue, 4 Oct 2022 18:32:33 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>>> Out of curiosity, can this test use `BufferedImage` to render `JInternalFrame` into?
>>
>> @aivanov-jdk Thank you for reviewing. I wanted to clarify whether you meant saving just the JInternalFrame into BufferedImage?
>
>> > Out of curiosity, can this test use `BufferedImage` to render `JInternalFrame` into?
>>
>> @aivanov-jdk Thank you for reviewing. I wanted to clarify whether you meant saving just the JInternalFrame into BufferedImage?
>
> Yes, just `JInternalFrame`. Yet I was talking about rendering rather than capturing from the screen.
> @aivanov-jdk Regarding saving the screen capture -
>
> When JIF bounds are used, a partial image of JInternalFrame (JIF) is saved. Hence I'm using the entire outer JFrame bounds to capture the screenshot.
Could be… It shouldn't. Anyway, I have no problem with capturing the entire `JFrame`.
>
> For the screenCapture I wanted to use **BufferedImage's getScaledInstance()** to create the scaled version (code snippet below), but experiencing issues while saving it. Currently I'm scaling the original image and re-drawing it using graphics object.
This is definitely not what we want. It just up-scales or down-scales the current image stored in `BufferedImage`.
When you run in a HiDPI environment or with `uiScale` set explicitly to a value greater than 1.0, the number of pixels is higher. `Robot.createScreenCapture` up-scales the passed in rectangle, captures all the pixels and then down-scales the captured screenshot to the user's space coordinates.
At the same time, [`createMultiResolutionScreenCapture`](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/Robot.html#createScreenCapture(java.awt.Rectangle)) returns a `MultiResolutionImage` which contains two variants: (1) the base image with the user specified size, down-scaled from the screen; (2) native resolution image with the device size pixels. The second variant will preserve all the pixels seen on the screen.
-------------
PR: https://git.openjdk.org/jdk/pull/10274
More information about the client-libs-dev
mailing list