[winpr,utils] fix PNG bpp extraction

This commit is contained in:
akallabeth 2024-08-19 11:31:28 +02:00
parent 7f84bd5c81
commit 4b7727bd4e
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
1 changed files with 5 additions and 4 deletions

View File

@ -940,14 +940,15 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
NULL, NULL) != 1)
goto fail;
size_t bpp = PNG_IMAGE_PIXEL_SIZE(color_type);
const png_byte channelcount = png_get_channels(png_ptr, info_ptr);
const size_t bpp = channelcount * bit_depth;
row_pointers = png_get_rows(png_ptr, info_ptr);
if (row_pointers)
{
const size_t stride = width * bpp;
const size_t stride = width * bpp / 8ull;
const size_t png_stride = png_get_rowbytes(png_ptr, info_ptr);
const size_t size = width * height * bpp;
const size_t size = width * height * bpp / 8ull;
const size_t copybytes = stride > png_stride ? png_stride : stride;
rc = malloc(size);
@ -962,7 +963,7 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
*pSize = size;
*pWidth = width;
*pHeight = height;
*pBpp = bpp * 8;
*pBpp = bpp;
}
}
fail: