diff options
author | Cosmic Linden <cosmic@lindenlab.com> | 2024-03-19 16:03:57 -0700 |
---|---|---|
committer | Cosmic Linden <cosmic@lindenlab.com> | 2024-03-19 16:03:57 -0700 |
commit | 7792e62d3c9e3f8b2a27e7e9cbbc8db2c584b682 (patch) | |
tree | a083ed8e310e193e09f1008724c138e8f85d219d /indra/llimage | |
parent | 2a325fdebadd32a230f10b372b25ec5474e50f63 (diff) |
secondlife/viewer-issues#82: Don't allow transparent texture terrain
Diffstat (limited to 'indra/llimage')
-rw-r--r-- | indra/llimage/llimage.cpp | 22 | ||||
-rw-r--r-- | indra/llimage/llimage.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index acfc254b65..16609b60be 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -990,6 +990,28 @@ void LLImageRaw::verticalFlip() } +bool LLImageRaw::checkHasTransparentPixels() +{ + if (getComponents() != 4) + { + return false; + } + + U8* data = getData(); + U32 pixels = getWidth() * getHeight(); + + // check alpha channel for all 255 + for (U32 i = 0; i < pixels; ++i) + { + if (data[i * 4 + 3] != 255) + { + return true; + } + } + + return false; +} + bool LLImageRaw::optimizeAwayAlpha() { if (getComponents() == 4) diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index fc8d62cc96..93b58b2356 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -210,6 +210,8 @@ public: void verticalFlip(); + // Returns true if the image is not fully opaque + bool checkHasTransparentPixels(); // if the alpha channel is all 100% opaque, delete it // returns true if alpha channel was deleted bool optimizeAwayAlpha(); |