On Wed, 19 Mar 2025 13:06:56 GMT, Nikita Gubarkov <ngubar...@openjdk.org> wrote:
>> 8352407: PixelInterleavedSampleModel with unused components throws >> RasterFormatException: Incorrect pixel stride > > Nikita Gubarkov has updated the pull request incrementally with one > additional commit since the last revision: > > The previous approach was wrong for non-pixel interleaving. > > Just align the buffer size to the pixel stride instead, should be better. src/java.desktop/share/classes/java/awt/image/ComponentSampleModel.java line 285: > 283: // Align to the pixel stride. > 284: size = (size + pixelStride - 1) / pixelStride * pixelStride; > 285: Some thoughts I’d like to mention to ensure I understand the problem: This method should return the number of bytes required to store the image with given parameters—width, height, pixel stride, and scanline. It seems that the calculation could follow this approach: **starting offset + pointer to the last pixel + pixelStride** Is that a correct assumption? I have doubts that the logic in this method actually calculates the size properly, especially this line: int val = pixelStride * (width - 1); size += val; It seems like it should be: int val = pixelStride + pixelStride * (width - 1); or simply: int val = pixelStride * width; Or am I missing something? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24111#discussion_r2024148158