mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-15 07:48:15 +00:00
Added raw image file reading data check
This commit is contained in:
@@ -225,14 +225,22 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
|
|||||||
default: TraceLog(WARNING, "Image format not suported"); break;
|
default: TraceLog(WARNING, "Image format not suported"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(image.data, size, 1, rawFile);
|
int bytes = fread(image.data, size, 1, rawFile);
|
||||||
|
|
||||||
// TODO: Check if data has been read
|
// Check if data has been read successfully
|
||||||
|
if (bytes < size)
|
||||||
|
{
|
||||||
|
TraceLog(WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName);
|
||||||
|
|
||||||
|
if (image.data != NULL) free(image.data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
image.width = width;
|
image.width = width;
|
||||||
image.height = height;
|
image.height = height;
|
||||||
image.mipmaps = 0;
|
image.mipmaps = 0;
|
||||||
image.format = format;
|
image.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
fclose(rawFile);
|
fclose(rawFile);
|
||||||
}
|
}
|
||||||
@@ -983,7 +991,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec)
|
|||||||
Color srcCol, dstCol;
|
Color srcCol, dstCol;
|
||||||
|
|
||||||
// Blit pixels, copy source image into destination
|
// Blit pixels, copy source image into destination
|
||||||
// TODO: Probably out-of-bounds blitting could be considering here instead of so much cropping...
|
// TODO: Probably out-of-bounds blitting could be considered here instead of so much cropping...
|
||||||
for (int j = dstRec.y; j < (dstRec.y + dstRec.height); j++)
|
for (int j = dstRec.y; j < (dstRec.y + dstRec.height); j++)
|
||||||
{
|
{
|
||||||
for (int i = dstRec.x; i < (dstRec.x + dstRec.width); i++)
|
for (int i = dstRec.x; i < (dstRec.x + dstRec.width); i++)
|
||||||
|
Reference in New Issue
Block a user