<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello</p>
<p align="justify">The <font face="monospace">BufferedImage</font>
Javadoc does not mention any constraint about the data type. In
practice, <font face="monospace">BufferedImage</font> with
floating point values can be rendered as well as integers (only
slower) provided that a compatible <font face="monospace">ColorModel</font>
was supplied at construction time. However calls to <font
face="monospace">setData(Raster)</font> unexpectedly cast
floating point values to integers. For example sample value 0.8
become 0. This is demonstrated by a test case, together with a
proposed fix, in the following pull request:<br>
</p>
<blockquote>
<p><a class="moz-txt-link-freetext" href="https://github.com/openjdk/jdk/pull/13797">https://github.com/openjdk/jdk/pull/13797</a><br>
</p>
</blockquote>
<p align="justify">The proposed fix is very simple: just replace the
whole method body by a call to <font face="monospace">WritableRaster.setRect(Raster)</font>,
which handles all supported data types correctly. The pull request
description contains code comparison for showing that this is
equivalent, except for robustness to integer underflow. The pull
request discusses the possible impact on behavior, which are:</p>
<ul>
<li>Change in behavior under integer underflow.</li>
<li>One more user-overrideable method get invoked.</li>
</ul>
<p>Martin</p>
<p><br>
</p>
</body>
</html>