summaryrefslogtreecommitdiff
path: root/indra/llimage/llimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage/llimage.cpp')
-rw-r--r--indra/llimage/llimage.cpp41
1 files changed, 7 insertions, 34 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 5ef3e9de3b..1ea0ac2714 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -290,42 +290,15 @@ BOOL LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height,
// Should do some simple bounds checking
U32 i;
- U32 to_offset;
- U32 from_offset;
- if (!reverse_y)
+ for (i = 0; i < height; i++)
{
- for (i = 0; i < height; i++)
- {
- to_offset = (y_pos + i)*getWidth() + x_pos;
- if (stride != 0)
- {
- from_offset = i*stride;
- }
- else
- {
- from_offset = i*width*getComponents();
- }
- memcpy(getData() + to_offset*getComponents(), /* Flawfinder: ignore */
- data + from_offset, getComponents()*width);
- }
- }
- else
- {
- for (i = 0; i < height; i++)
- {
- to_offset = (y_pos + i)*getWidth() + x_pos;
- if (stride != 0)
- {
- from_offset = (height - 1 - i)*stride;
- }
- else
- {
- from_offset = (height - 1 - i)*width*getComponents();
- }
- memcpy(getData() + to_offset*getComponents(), /* Flawfinder: ignore */
- data + from_offset, getComponents()*width);
- }
+ const U32 row = reverse_y ? height - 1 - i : i;
+ const U32 from_offset = row * ((stride == 0) ? width*getComponents() : stride);
+ const U32 to_offset = (y_pos + i)*getWidth() + x_pos;
+ memcpy(getData() + to_offset*getComponents(), /* Flawfinder: ignore */
+ data + from_offset, getComponents()*width);
}
+
return TRUE;
}