aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llimage')
-rw-r--r--linden/indra/llimage/llimage.cpp2
-rw-r--r--linden/indra/llimage/llpngwrapper.cpp18
-rw-r--r--linden/indra/llimage/llpngwrapper.h3
3 files changed, 5 insertions, 18 deletions
diff --git a/linden/indra/llimage/llimage.cpp b/linden/indra/llimage/llimage.cpp
index e933750..3a8dc3b 100644
--- a/linden/indra/llimage/llimage.cpp
+++ b/linden/indra/llimage/llimage.cpp
@@ -269,7 +269,7 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
269 : LLImageBase() 269 : LLImageBase()
270{ 270{
271 mMemType = LLMemType::MTYPE_IMAGERAW; 271 mMemType = LLMemType::MTYPE_IMAGERAW;
272 if(allocateDataSize(width, height, components)) 272 if(allocateDataSize(width, height, components) && data)
273 { 273 {
274 memcpy(getData(), data, width*height*components); 274 memcpy(getData(), data, width*height*components);
275 } 275 }
diff --git a/linden/indra/llimage/llpngwrapper.cpp b/linden/indra/llimage/llpngwrapper.cpp
index 0dd991a..2274a38 100644
--- a/linden/indra/llimage/llpngwrapper.cpp
+++ b/linden/indra/llimage/llpngwrapper.cpp
@@ -56,8 +56,6 @@ LLPngWrapper::LLPngWrapper()
56 mCompressionType( 0 ), 56 mCompressionType( 0 ),
57 mFilterMethod( 0 ), 57 mFilterMethod( 0 ),
58 mFinalSize( 0 ), 58 mFinalSize( 0 ),
59 mHasBKGD(false),
60 mBackgroundColor(),
61 mGamma(0.f) 59 mGamma(0.f)
62{ 60{
63} 61}
@@ -117,9 +115,9 @@ void LLPngWrapper::writeFlush(png_structp png_ptr)
117} 115}
118 116
119// Read the PNG file using the libpng. The low-level interface is used here 117// Read the PNG file using the libpng. The low-level interface is used here
120// because we want to do various transformations (including setting the 118// because we want to do various transformations (including applying gama)
121// matte background if any, and applying gama) which can't be done with 119// which can't be done with the high-level interface.
122// the high-level interface. The scanline also begins at the bottom of 120// The scanline also begins at the bottom of
123// the image (per SecondLife conventions) instead of at the top, so we 121// the image (per SecondLife conventions) instead of at the top, so we
124// must assign row-pointers in "reverse" order. 122// must assign row-pointers in "reverse" order.
125BOOL LLPngWrapper::readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop) 123BOOL LLPngWrapper::readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop)
@@ -207,8 +205,7 @@ void LLPngWrapper::normalizeImage()
207 // 2. Convert grayscales to RGB 205 // 2. Convert grayscales to RGB
208 // 3. Create alpha layer from transparency 206 // 3. Create alpha layer from transparency
209 // 4. Ensure 8-bpp for all images 207 // 4. Ensure 8-bpp for all images
210 // 5. Apply background matte if any 208 // 5. Set (or guess) gamma
211 // 6. Set (or guess) gamma
212 209
213 if (mColorType == PNG_COLOR_TYPE_PALETTE) 210 if (mColorType == PNG_COLOR_TYPE_PALETTE)
214 { 211 {
@@ -235,12 +232,6 @@ void LLPngWrapper::normalizeImage()
235 { 232 {
236 png_set_strip_16(mReadPngPtr); 233 png_set_strip_16(mReadPngPtr);
237 } 234 }
238 mHasBKGD = png_get_bKGD(mReadPngPtr, mReadInfoPtr, &mBackgroundColor);
239 if (mHasBKGD)
240 {
241 png_set_background(mReadPngPtr, mBackgroundColor,
242 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
243 }
244 235
245#if LL_DARWIN 236#if LL_DARWIN
246 const F64 SCREEN_GAMMA = 1.8; 237 const F64 SCREEN_GAMMA = 1.8;
@@ -267,7 +258,6 @@ void LLPngWrapper::updateMetaData()
267 mBitDepth = png_get_bit_depth(mReadPngPtr, mReadInfoPtr); 258 mBitDepth = png_get_bit_depth(mReadPngPtr, mReadInfoPtr);
268 mColorType = png_get_color_type(mReadPngPtr, mReadInfoPtr); 259 mColorType = png_get_color_type(mReadPngPtr, mReadInfoPtr);
269 mChannels = png_get_channels(mReadPngPtr, mReadInfoPtr); 260 mChannels = png_get_channels(mReadPngPtr, mReadInfoPtr);
270 mHasBKGD = png_get_bKGD(mReadPngPtr, mReadInfoPtr, &mBackgroundColor);
271} 261}
272 262
273// Method to write raw image into PNG at dest. The raw scanline begins 263// Method to write raw image into PNG at dest. The raw scanline begins
diff --git a/linden/indra/llimage/llpngwrapper.h b/linden/indra/llimage/llpngwrapper.h
index 2e6c1dc..0c3168c 100644
--- a/linden/indra/llimage/llpngwrapper.h
+++ b/linden/indra/llimage/llpngwrapper.h
@@ -94,9 +94,6 @@ private:
94 94
95 U32 mFinalSize; 95 U32 mFinalSize;
96 96
97 bool mHasBKGD;
98 png_color_16p mBackgroundColor;
99
100 F64 mGamma; 97 F64 mGamma;
101 98
102 std::string mErrorMessage; 99 std::string mErrorMessage;