1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Optimize getImageAverageColor

also fixes a bug with non-square handling

before:
  getImageAverageColor [us] _____________________  804x  11.253

after:
  imageAverageColorInline [us] __________________  804x   0.557
This commit is contained in:
sfan5 2024-12-30 22:17:52 +01:00
parent ded8c25e34
commit f37f9a6f0b
5 changed files with 111 additions and 90 deletions

View file

@ -6,6 +6,7 @@
#include "irrlichttypes.h"
#include <rect.h>
#include <SColor.h>
namespace irr::video
{
@ -26,6 +27,10 @@ namespace irr::video
*/
void imageCleanTransparent(video::IImage *src, u32 threshold);
/* Returns the gamma-correct average color of the image, with transparent pixels
* ignored. */
video::SColor imageAverageColor(const video::IImage *img);
/* Scale a region of an image into another image, using nearest-neighbor with
* anti-aliasing; treat pixels as crisp rectangles, but blend them at boundaries
* to prevent non-integer scaling ratio artifacts. Note that this may cause