[OpenJDK 2D-Dev] BufferedImage.getTileGridXOffset() not compliant with its specification?

Martin Desruisseaux martin.desruisseaux at geomatys.com
Mon Mar 9 13:29:47 UTC 2020


Hello Sergey

Thanks for the analysis. I can volunteer for creating the CSR if I can 
have some pointers (e.g. template) to follow?

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 [1].

For the formula used for "pixel coordinates to tile indices" 
calculation, we can use source code of [2] as a reference.

[1] https://docs.oracle.com/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/TiledImage.html
[2] https://docs.oracle.com/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/PlanarImage.html#XToTileX(int,%20int,%20int)

     Regards,

         Martin


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 [1]. 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.
>
> [1] 
> https://github.com/openjdk/client/blob/master/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L2662

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


More information about the 2d-dev mailing list