diff options
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/integration_tests/llimage_libtest/llimage_libtest.cpp | 11 | ||||
-rwxr-xr-x | indra/llimage/llimage.cpp | 46 | ||||
-rwxr-xr-x | indra/llimage/llimage.h | 1 |
3 files changed, 56 insertions, 2 deletions
diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 009be0941e..69cea33911 100755 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -119,8 +119,7 @@ static bool sAllDone = false; // Load filter from file LLSD load_filter_from_file(const std::string& file_path) { - std::cout << "Loading filter settings from : " << file_path << std::endl; - + //std::cout << "Loading filter settings from : " << file_path << std::endl; llifstream filter_xml(file_path); if (filter_xml.is_open()) { @@ -213,6 +212,10 @@ void execute_filter(const LLSD& filter_data, LLPointer<LLImageRaw> raw_image) LLColor3 color((float)(filter_data[i][2].asReal()),(float)(filter_data[i][3].asReal()),(float)(filter_data[i][4].asReal())); raw_image->filterEqualize((S32)(filter_data[i][1].asReal()),color); } + else if (filter_name == "screen") + { + raw_image->screenFilter((S32)(filter_data[i][1].asReal())); + } } } @@ -818,6 +821,10 @@ int main(int argc, char** argv) { raw_image->filterEqualize((S32)(filter_param),LLColor3::white); } + else if (filter_name == "screen") + { + raw_image->screenFilter((S32)(filter_param)); + } else if (filter_name != "") { // We're interpreting the filter as a filter file name diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 977bb09b63..ae3de32788 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -1312,6 +1312,52 @@ void LLImageRaw::colorCorrect(const U8* lut_red, const U8* lut_green, const U8* } } +void LLImageRaw::screenFilter(const S32 wave_length) +{ + const S32 components = getComponents(); + llassert( components >= 1 && components <= 4 ); + + S32 width = getWidth(); + S32 height = getHeight(); + + U8* dst_data = getData(); + for (S32 j = 0; j < height; j++) + { + for (S32 i = 0; i < width; i++) + { + F32 value = (sinf(2*F_PI*i/wave_length)*sinf(2*F_PI*j/wave_length)+1.0)*255.0/2.0; + //F32 value = (sinf(2*F_PI*i/wave_length)+1.0)*255.0/2.0; // will do line + U8 dst_value = (dst_data[VRED] >= (U8)(value) ? 255 : 0); + if (mVignetteMode == VIGNETTE_MODE_NONE) + { + dst_data[VRED] = dst_value; + dst_data[VGREEN] = dst_value; + dst_data[VBLUE] = dst_value; + } + else + { + F32 alpha = getVignetteAlpha(i,j); + if (mVignetteMode == VIGNETTE_MODE_BLEND) + { + // Blends with the source image on the edges + F32 inv_alpha = 1.0 - alpha; + dst_data[VRED] = inv_alpha * dst_data[VRED] + alpha * dst_value; + dst_data[VGREEN] = inv_alpha * dst_data[VGREEN] + alpha * dst_value; + dst_data[VBLUE] = inv_alpha * dst_data[VBLUE] + alpha * dst_value; + } + else // VIGNETTE_MODE_FADE + { + // Fade to black on the edges + dst_data[VRED] = alpha * dst_value; + dst_data[VGREEN] = alpha * dst_value; + dst_data[VBLUE] = alpha * dst_value; + } + } + dst_data += components; + } + } +} + void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma, F32 min) { mVignetteMode = mode; diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index cc91f95624..ed17f1af21 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -299,6 +299,7 @@ public: // Filter Primitives void colorTransform(const LLMatrix3 &transform); void colorCorrect(const U8* lut_red, const U8* lut_green, const U8* lut_blue); + void screenFilter(const S32 wave_length); void setVignette(EVignetteMode mode, F32 gamma, F32 min); U32* getBrightnessHistogram(); |