[OpenJDK 2D-Dev] BufferedImage.getTileGridXOffset() not compliant with its specification?
Sergey.Bylokhov at oracle.com
Mon Mar 9 22:24:30 UTC 2020
On 3/9/20 6:29 am, Martin Desruisseaux wrote:
> Thanks for the analysis. I can volunteer for creating the CSR if I can have some pointers (e.g. template) to follow?
Let's start with the fix/test. Send me a patch and I will upload it to the cr.openjdk, so will be able to send an official review request.
> Indeed, I though that Graphics2D may have "if (image instanceof BufferedImage)" optimizations that hides the issue. My plan was to create a test with a RenderedImage wrapping a BufferedImage, which would prevent Graphics2D to use such fast track, and see how it behaves. What I can said however is that Graphics2D works well with multi-tiled images compliant with the specification, such as javax.media.jai.TiledImage .
> For the formula used for "pixel coordinates to tile indices" calculation, we can use source code of  as a reference.
> Le 09/03/2020 à 01:29, Sergey Bylokhov a écrit :
>> I have checked the history of these methods and their usage.
>> These methods were added to the BufferedImage back in 1997 when the
>> generic support of rendered images was added. Since then these methods
>> were used in the implementation of Graphics2D.drawRenderedImage(), but
>> in fact for BufferedImage they are never called . I think it is
>> possible to change getTileGridXOffset()/getTileGridYOffset to return 0.
>> But it will be necessary to create a CSR, since the change has
>> compatibility impact.
>>  https://github.com/openjdk/client/blob/master/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L2662
Best regards, Sergey.
More information about the 2d-dev