Fix pixel data size regressions
This commit is contained in:
parent
d224912bd5
commit
b2b9b83d80
2 changed files with 8 additions and 7 deletions
|
|
@ -5237,7 +5237,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||||
{
|
{
|
||||||
int blockWidth = (width + 3)/4;
|
int blockWidth = (width + 3)/4;
|
||||||
int blockHeight = (height + 3)/4;
|
int blockHeight = (height + 3)/4;
|
||||||
unsigned long long dataSizeBytes = blockWidth*blockHeight*8;
|
unsigned long long dataSizeBytes = (unsigned long long)blockWidth*blockHeight*8;
|
||||||
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -5248,7 +5248,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||||
{
|
{
|
||||||
int blockWidth = (width + 3)/4;
|
int blockWidth = (width + 3)/4;
|
||||||
int blockHeight = (height + 3)/4;
|
int blockHeight = (height + 3)/4;
|
||||||
unsigned long long dataSizeBytes = blockWidth*blockHeight*16;
|
unsigned long long dataSizeBytes = (unsigned long long)blockWidth*blockHeight*16;
|
||||||
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -5256,7 +5256,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||||
{
|
{
|
||||||
int blockWidth = (width + 3)/4;
|
int blockWidth = (width + 3)/4;
|
||||||
int blockHeight = (height + 3)/4;
|
int blockHeight = (height + 3)/4;
|
||||||
unsigned long long dataSizeBytes = blockWidth*blockHeight*4;
|
unsigned long long dataSizeBytes = (unsigned long long)blockWidth*blockHeight*4;
|
||||||
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -5267,7 +5267,7 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
||||||
if ((format >= RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) &&
|
if ((format >= RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) &&
|
||||||
(format <= RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16))
|
(format <= RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16))
|
||||||
{
|
{
|
||||||
unsigned long long dataSizeBytes = (width*height*bpp) >> 3; // Get size in bytes (dividing by 8)
|
unsigned long long dataSizeBytes = ((unsigned long long)width*height*bpp) >> 3; // Get size in bytes (dividing by 8)
|
||||||
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
if (dataSizeBytes < INT_MAX) dataSize = (int)dataSizeBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2693,8 +2693,9 @@ void ImageRotate(Image *image, int degrees)
|
||||||
int width = (int)(fabsf(image->width*cosRadius) + fabsf(image->height*sinRadius));
|
int width = (int)(fabsf(image->width*cosRadius) + fabsf(image->height*sinRadius));
|
||||||
int height = (int)(fabsf(image->height*cosRadius) + fabsf(image->width*sinRadius));
|
int height = (int)(fabsf(image->height*cosRadius) + fabsf(image->width*sinRadius));
|
||||||
|
|
||||||
int bytesPerPixel = GetPixelDataSize(width, height, image->format);
|
int dataSize = GetPixelDataSize(width, height, image->format);
|
||||||
unsigned char *rotatedData = (unsigned char *)RL_CALLOC(bytesPerPixel, 1);
|
int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
|
||||||
|
unsigned char *rotatedData = (unsigned char *)RL_CALLOC(dataSize, 1);
|
||||||
|
|
||||||
if (rotatedData != NULL)
|
if (rotatedData != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -5514,7 +5515,7 @@ int GetPixelDataSize(int width, int height, int format)
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long dataSizeBytes = (width*height*bpp) >> 3; // Get size in bytes (dividing by 8)
|
unsigned long long dataSizeBytes = ((unsigned long long)width*height*bpp) >> 3; // Get size in bytes (dividing by 8)
|
||||||
|
|
||||||
if (dataSizeBytes < INT_MAX)
|
if (dataSizeBytes < INT_MAX)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue