RFR: 8323108: BufferedImage.setData(Raster) should not cast float and double values to integers

Martin Desruisseaux duke at openjdk.org
Sun Jan 7 23:32:53 UTC 2024


On Thu, 9 Nov 2023 18:12:19 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> But can we solve both issues, add optimization w/o creating the new objects?

Not with the current `Rectangle` API as far as I can see. If the goal is maximal performances, the current code is likely better. The use of `Rectangle.intersection(Rectangle)` was proposed for safety rather than performance, because `Rectangle` is robust to integer underflow and overflow. However, I think that the current `WritableRaster.setRect(Raster)` code can underflow/overflow only if the checks performed at `Raster` construction time were bypassed, for example by modifying the protected fields after construction.

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

PR Comment: https://git.openjdk.org/jdk/pull/13797#issuecomment-1804395307


More information about the client-libs-dev mailing list