mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +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:
parent
ded8c25e34
commit
f37f9a6f0b
5 changed files with 111 additions and 90 deletions
|
@ -515,13 +515,14 @@ video::SColor TextureSource::getTextureAverageColor(const std::string &name)
|
|||
video::ITexture *texture = getTexture(name);
|
||||
if (!texture)
|
||||
return {0, 0, 0, 0};
|
||||
// Note: this downloads the texture back from the GPU, which is pointless
|
||||
video::IImage *image = driver->createImage(texture,
|
||||
core::position2d<s32>(0, 0),
|
||||
texture->getOriginalSize());
|
||||
if (!image)
|
||||
return {0, 0, 0, 0};
|
||||
|
||||
video::SColor c = ImageSource::getImageAverageColor(*image);
|
||||
video::SColor c = imageAverageColor(image);
|
||||
image->drop();
|
||||
|
||||
return c;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue