BitmapStream: fix grayscale AVIF decoding

BitmapStream creates a BBitmap without specifying a bytes per row, but
then check the bytes per row matches the header. It is better to ask
BBitmap for the desired bytes per row to avoid any difference in
padding.

Change-Id: Ie1facfd423ad888a14757a0fffc9e8cdf72ef832
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6301
Tested-by: Automation <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
PulkoMandy
2023-04-04 18:37:03 +00:00
committed by Adrien Destugues
parent cc889ed79a
commit 095b381310
+3 -2
View File
@@ -150,7 +150,7 @@ BBitmapStream::WriteAt(off_t pos, const void* data, size_t size)
if (fHeader.bounds.left > 0.0 || fHeader.bounds.top > 0.0)
DEBUGGER("non-origin bounds!");
fBitmap = new (std::nothrow )BBitmap(fHeader.bounds,
fHeader.colors);
0, fHeader.colors, fHeader.rowBytes);
if (fBitmap == NULL)
return B_ERROR;
if (!fBitmap->IsValid()) {
@@ -160,7 +160,8 @@ BBitmapStream::WriteAt(off_t pos, const void* data, size_t size)
return error;
}
if ((uint32)fBitmap->BytesPerRow() != fHeader.rowBytes) {
fprintf(stderr, "BitmapStream %" B_PRId32 " %" B_PRId32 "\n",
fprintf(stderr, "BitmapStream BytesPerRow width %" B_PRId32 " does not match "
"value declared in header %" B_PRId32 "\n",
fBitmap->BytesPerRow(), fHeader.rowBytes);
return B_MISMATCHED_VALUES;
}