<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Martin,<div class=""><br class=""></div><div class="">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.</div><div class="">I had already approved webrev.01 and still +1 for webrev.01.</div><div class=""><br class=""></div><div class="">And I think we should conclude the thread with Phil’s question about just returning 0 in these methods.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jay<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 25-Jun-2020, at 8:33 PM, Martin Desruisseaux <<a href="mailto:martin.desruisseaux@geomatys.com" class="">martin.desruisseaux@geomatys.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
<div class=""><p class="">Hello</p><p class="">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 <tt class="">BufferedImage</tt> subimage with <tt class="">Graphics2D</tt>
causes an exception to be thrown if we hide the fact that the
image is a <tt class="">BufferedImage</tt> instance, for preventing <tt class="">SunGraphics2D</tt>
to use its special cases for <tt class="">BufferedImage</tt>. Stack trace
is:</p>
<blockquote class="">
<pre class="">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)
</pre>
</blockquote><p class="">Replacing <tt class="">getTileGridXOffset()</tt> and <tt class="">getTileGridYOffset()</tt>
return values by 0 (as expected and as requested by method
contract) fix the bug.</p><p class="">This bug happens with any code that try to handle <tt class="">RenderedImage</tt>
tiles in a generic way, without making special case for <tt class="">BufferedImage</tt>
(we have encounter this issue today in Apache Spatial Information
System).</p><p class=""> Regards,</p><p class=""> Martin<br class="">
</p>
<pre class="">[1] <a class="moz-txt-link-freetext" href="https://bugs.openjdk.java.net/browse/JDK-8166038">https://bugs.openjdk.java.net/browse/JDK-8166038</a>
</pre>
</div>
<span id="cid:34B70CE8-54F7-4BC8-96D6-800B18345C1B"><SubimageDrawingTest.java></span></div></blockquote></div><br class=""></div></body></html>