Don't use DrawRect to clear an image, a pixel loop is an order of magnitude faster.

This commit is contained in:
Jeffery Myers 2020-12-29 08:04:25 -08:00
parent 75c6fd047b
commit a1584e0194

View File

@ -2348,7 +2348,8 @@ Rectangle GetImageAlphaBorder(Image image, float threshold)
// Clear image background with given color // Clear image background with given color
void ImageClearBackground(Image *dst, Color color) void ImageClearBackground(Image *dst, Color color)
{ {
ImageDrawRectangle(dst, 0, 0, dst->width, dst->height, color); for (int i = 0; i < dst->width * dst->height; ++i)
ImageDrawPixel(dst, i % dst->width, i / dst->height, color);
} }
// Draw pixel within an image // Draw pixel within an image