[OpenJDK 2D-Dev] RFR: 8166038 BufferedImage methods getTileGridXOffset() and getTileGridYOffset() return a non 0 value for sub images

Thu Jun 25 15:48:47 UTC 2020

Hi Martin,

There was no need for creating separate test case to override BufferedImage and see what happens but its good that we know the behaviour now.
I had already approved webrev.01 and still +1 for webrev.01.

And I think we should conclude the thread with Phil’s question about just returning 0 in these methods.


> On 25-Jun-2020, at 8:33 PM, Martin Desruisseaux <martin.desruisseaux at geomatys.com> wrote:
> Hello
> Following up on JDK-8166038 [1], in case it may help to justify the proposed fix, attached is another test case demonstrating the bug. Attempt to draw a BufferedImage subimage with Graphics2D causes an exception to be thrown if we hide the fact that the image is a BufferedImage instance, for preventing SunGraphics2D to use its special cases for BufferedImage. Stack trace is:
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: BufferedImages only have one tile with index 0,0
> 	at java.desktop/java.awt.image.BufferedImage.getTile(BufferedImage.java:1401)
> 	at SubimageDrawingTest$Wrapper.getTile(SubimageDrawingTest.java:136)
> 	at java.desktop/sun.java2d.SunGraphics2D.drawTranslatedRenderedImage(SunGraphics2D.java:2821)
> 	at java.desktop/sun.java2d.SunGraphics2D.drawRenderedImage(SunGraphics2D.java:2708)
> 	at SubimageDrawingTest.main(SubimageDrawingTest.java:31)
> Replacing getTileGridXOffset() and getTileGridYOffset() return values by 0 (as expected and as requested by method contract) fix the bug.
> This bug happens with any code that try to handle RenderedImage tiles in a generic way, without making special case for BufferedImage (we have encounter this issue today in Apache Spatial Information System).
>     Regards,
>         Martin
> [1] https://bugs.openjdk.java.net/browse/JDK-8166038 <https://bugs.openjdk.java.net/browse/JDK-8166038>
> <SubimageDrawingTest.java>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/2d-dev/attachments/20200625/114b816c/attachment.htm>

More information about the 2d-dev mailing list