diff options
Diffstat (limited to 'indra/llimage/llimage.cpp')
-rw-r--r-- | indra/llimage/llimage.cpp | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 73c23fa8d8..575ad5363d 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -55,13 +55,9 @@ std::string LLImage::sLastErrorMessage; LLMutex* LLImage::sMutex = NULL; //static -void LLImage::initClass(LLWorkerThread* workerthread) +void LLImage::initClass() { sMutex = new LLMutex(NULL); - if (workerthread) - { - LLImageWorker::initImageWorker(workerthread); - } LLImageJ2C::openDSO(); } @@ -69,7 +65,6 @@ void LLImage::initClass(LLWorkerThread* workerthread) void LLImage::cleanupClass() { LLImageJ2C::closeDSO(); - LLImageWorker::cleanupImageWorker(); delete sMutex; sMutex = NULL; } @@ -316,6 +311,21 @@ void LLImageRaw::deleteData() LLImageBase::deleteData(); } +void LLImageRaw::setDataAndSize(U8 *data, S32 width, S32 height, S8 components) +{ + if(data == getData()) + { + return ; + } + + deleteData(); + + LLImageBase::setSize(width, height, components) ; + LLImageBase::setDataAndSize(data, width * height * components) ; + + sGlobalRawMemory += getDataSize(); +} + BOOL LLImageRaw::resize(U16 width, U16 height, S8 components) { if ((getWidth() == width) && (getHeight() == height) && (getComponents() == components)) @@ -816,6 +826,51 @@ void LLImageRaw::copyScaled( LLImageRaw* src ) } } +//scale down image by not blending a pixel with its neighbors. +BOOL LLImageRaw::scaleDownWithoutBlending( S32 new_width, S32 new_height) +{ + LLMemType mt1(mMemType); + + S8 c = getComponents() ; + llassert((1 == c) || (3 == c) || (4 == c) ); + + S32 old_width = getWidth(); + S32 old_height = getHeight(); + + S32 new_data_size = old_width * new_height * c ; + llassert_always(new_data_size > 0); + + F32 ratio_x = (F32)old_width / new_width ; + F32 ratio_y = (F32)old_height / new_height ; + if( ratio_x < 1.0f || ratio_y < 1.0f ) + { + return TRUE; // Nothing to do. + } + ratio_x -= 1.0f ; + ratio_y -= 1.0f ; + + U8* new_data = new U8[new_data_size] ; + llassert_always(new_data != NULL) ; + + U8* old_data = getData() ; + S32 i, j, k, s, t; + for(i = 0, s = 0, t = 0 ; i < new_height ; i++) + { + for(j = 0 ; j < new_width ; j++) + { + for(k = 0 ; k < c ; k++) + { + new_data[s++] = old_data[t++] ; + } + t += (S32)(ratio_x * c + 0.1f) ; + } + t += (S32)(ratio_y * old_width * c + 0.1f) ; + } + + setDataAndSize(new_data, new_width, new_height, c) ; + + return TRUE ; +} BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) { |