summaryrefslogtreecommitdiff
path: root/indra/llimage/llimage.cpp
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2024-03-19 16:03:57 -0700
committerCosmic Linden <cosmic@lindenlab.com>2024-03-19 16:03:57 -0700
commit7792e62d3c9e3f8b2a27e7e9cbbc8db2c584b682 (patch)
treea083ed8e310e193e09f1008724c138e8f85d219d /indra/llimage/llimage.cpp
parent2a325fdebadd32a230f10b372b25ec5474e50f63 (diff)
secondlife/viewer-issues#82: Don't allow transparent texture terrain
Diffstat (limited to 'indra/llimage/llimage.cpp')
-rw-r--r--indra/llimage/llimage.cpp22
1 files changed, 22 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)