On Tue, 4 Oct 2022 18:48:19 GMT, Alexey Ivanov <aiva...@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?
>> 
>> 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.

> @aivanov-jdk The extra pixel seems to be added due to JInternalFrame titlebar 
> and not from the paintBorder() code changes.

Good then. It's not from the border.

-------------

PR: https://git.openjdk.org/jdk/pull/10274

Reply via email to