> We use `Math.ceil()` at 2 places in BMPImageWriter and both of them are under > encodeRLE4() function. Also they are used only under absolute mode of > encoding. > > First usage `(int)Math.ceil((absVal-1)/2)` is while encoding data in each > scanline. Here absVal always starts with 3 and increments by 2, so > `Math.ceil()` is basically a no-op here and its usage can be removed. > > Second usage `(int)Math.ceil((absVal+1)/2)` is while encoding end of scanline > data. Here absVal can be even and we need to use `Math.ceil()` properly > otherwise padding will not be added properly. I have added regression test > which actually identifies this issue and it creates a corrupt encoded BMP > image. In this regression test we have odd number of distinct pixels at the > end of scanline and encoding without proper padding corrupts next scanline of > data. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
Jayathirth D V has updated the pull request incrementally with one additional commit since the last revision: Update ------------- Changes: - all: https://git.openjdk.org/jdk/pull/31447/files - new: https://git.openjdk.org/jdk/pull/31447/files/36ffb602..438756e1 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=31447&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=31447&range=00-01 Stats: 14 lines in 2 files changed: 6 ins; 5 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/31447.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/31447/head:pull/31447 PR: https://git.openjdk.org/jdk/pull/31447
