diff options
| author | cosmic-linden <111533034+cosmic-linden@users.noreply.github.com> | 2024-03-20 08:58:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 08:58:58 -0700 |
| commit | 93231d4eed69f7b869d4d10855a7ce6809b4a033 (patch) | |
| tree | 671182f101d48e852d277f501c6adfe7964d3784 /indra/llimage | |
| parent | 052a8a78e8b024bda1db6e5359c0d091b2a72d06 (diff) | |
| parent | e2a3edf6daed276d82767ce070dbbaf1d42dc427 (diff) | |
Merge pull request #1019 from secondlife/vi-82
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(); |
