On Mon, 3 Oct 2022 06:41:03 GMT, Jayathirth D V <[email protected]> wrote:

>> src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java
>>  line 1463:
>> 
>>> 1461:             return false;
>>> 1462:         }
>>> 1463:         if (compressionType == BI_RLE4 && bpp != 4) {
>> 
>> I'm confused. You say you are relaxing the test to allow 15bpp, but I don't 
>> see where you're removing
>> anything that would have rejected 15bpp.
>> 
>> And how does this prevent the un-specified exception being thrown ?
>
> Hi Phil,
> 
> We never had any bpp check to verify what standard bpp's should be allowed in 
> BMP.
> Because of this when we tried to decode 2 bpp PNG img and write it to BMP we 
> used to get IOOBE as captured in https://bugs.openjdk.org/browse/JDK-8262297. 
> So under this bug, check was added to allow only standard bpp's for BMP 
> encoding : 
> https://github.com/openjdk/jdk/commit/c73319354399596ab2b9aab0a7f62e8fa0ab9365.
>  
> 
> But this caused regression of many jtreg tests which were using 
> USHORT_555_RGB to encode BMP image(we round off this 15bpp to 16bpp and at 
> later stage : 
> https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java#L472
>  and store it in 16bit data buffer). So i relaxed this check which caused 
> jtreg regressions to allow 15bpp also.
> 
> Since we straight away reject non-standard bits per pixel (like 2 bpp) for 
> BMP encoding, we will throw IOException instead to going ahead and throwing 
> non-documented exceptions like IOOBE.

Ah, the bit you weren't / aren't explaining is that the reason I'm not seeing 
the check which would have dis-allowed 15bpp 
is that you backed it out ages ago 
https://github.com/openjdk/jdk/commit/84aa0a191b085a3d7cb338fd5e67281d0e4b57be
because of the failures it caused.

So now that code is being re-added but this time allowing 15bpp

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

PR: https://git.openjdk.org/jdk/pull/10419

Reply via email to