REVIEW: GetImageData() and GetImageAlphaBorder()
This commit is contained in:
parent
5d9df629d7
commit
e8b89b5ecf
1 changed files with 25 additions and 18 deletions
|
@ -459,6 +459,8 @@ Color *GetImageData(Image image)
|
|||
{
|
||||
Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color));
|
||||
|
||||
if (pixels == NULL) return pixels;
|
||||
|
||||
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
|
||||
else
|
||||
{
|
||||
|
@ -683,8 +685,12 @@ Vector4 *GetImageDataNormalized(Image image)
|
|||
// Get image alpha border rectangle
|
||||
Rectangle GetImageAlphaBorder(Image image, float threshold)
|
||||
{
|
||||
Rectangle crop = { 0 };
|
||||
|
||||
Color *pixels = GetImageData(image);
|
||||
|
||||
if (pixels != NULL)
|
||||
{
|
||||
int xMin = 65536; // Define a big enough number
|
||||
int xMax = 0;
|
||||
int yMin = 65536;
|
||||
|
@ -704,9 +710,10 @@ Rectangle GetImageAlphaBorder(Image image, float threshold)
|
|||
}
|
||||
}
|
||||
|
||||
Rectangle crop = { xMin, yMin, (xMax + 1) - xMin, (yMax + 1) - yMin };
|
||||
crop = (Rectangle){ xMin, yMin, (xMax + 1) - xMin, (yMax + 1) - yMin };
|
||||
|
||||
RL_FREE(pixels);
|
||||
}
|
||||
|
||||
return crop;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue