diff options
-rwxr-xr-x | indra/integration_tests/llimage_libtest/llimage_libtest.cpp | 40 | ||||
-rwxr-xr-x | indra/llimage/llimage.cpp | 33 | ||||
-rwxr-xr-x | indra/llimage/llimage.h | 4 |
3 files changed, 75 insertions, 2 deletions
diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 6c23a6a866..58d7f53dd1 100755 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -716,7 +716,45 @@ int main(int argc, char** argv) { raw_image->filterEqualize((S32)(filter_param)); } - + // Test for some "a la Instagram" filters + else if (filter_name == "Lomofi") + { + raw_image->setVignette(VIGNETTE_MODE_BLEND,4.0,0.0); + raw_image->filterLinearize(0.2); + } + else if (filter_name == "Sutro") + { + raw_image->filterLinearize(0.2); + raw_image->setVignette(VIGNETTE_MODE_FADE,4.0,0.5); + raw_image->filterSepia(); + } + else if (filter_name == "Inkwell") + { + raw_image->filterLinearize(0.0); + raw_image->filterGrayScale(); + } + else if (filter_name == "Poprocket") + { + LLColor4U color = LLColor4U::red; + color.setAlpha((U8)(0.2 * 255.0)); + raw_image->filterLinearize(0.0); + raw_image->setVignette(VIGNETTE_MODE_FADE,4.0,0.5); + raw_image->filterColorize(color); + } + else if (filter_name == "Gotham") + { + raw_image->filterLinearize(0.0); + raw_image->filterColorBalance(1.0,1.0,20.0); + raw_image->filterGrayScale(); + } + else if (filter_name == "Toaster") + { + raw_image->filterContrast(0.8); + raw_image->setVignette(VIGNETTE_MODE_FADE,4.0,0.5); + raw_image->filterBrightness(10); + raw_image->filterColorBalance(0.5,1.0,1.0); + } + // Save file if (out_file != out_end) { diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index d84989f9c8..3d86abb26d 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -1045,6 +1045,22 @@ void LLImageRaw::filterGamma(F32 gamma) colorCorrect(gamma_lut,gamma_lut,gamma_lut); } +void LLImageRaw::filterColorBalance(F32 gamma_red, F32 gamma_green, F32 gamma_blue) +{ + U8 gamma_red_lut[256]; + U8 gamma_green_lut[256]; + U8 gamma_blue_lut[256]; + + for (S32 i = 0; i < 256; i++) + { + gamma_red_lut[i] = (U8)(255.0 * (llclampf((float)(pow((float)(i)/255.0,gamma_red))))); + gamma_green_lut[i] = (U8)(255.0 * (llclampf((float)(pow((float)(i)/255.0,gamma_green))))); + gamma_blue_lut[i] = (U8)(255.0 * (llclampf((float)(pow((float)(i)/255.0,gamma_blue))))); + } + + colorCorrect(gamma_red_lut,gamma_green_lut,gamma_blue_lut); +} + void LLImageRaw::filterLinearize(F32 tail) { // Get the histogram @@ -1191,6 +1207,23 @@ void LLImageRaw::filterBrightness(S32 add) colorCorrect(brightness_lut,brightness_lut,brightness_lut); } +void LLImageRaw::filterMinMax(S32 min, S32 max) +{ + U8 contrast_lut[256]; + min = llclampb(min); + max = llclampb(max); + + F32 slope = 255.0/(F32)(max - min); + F32 translate = -slope*min; + + for (S32 i = 0; i < 256; i++) + { + contrast_lut[i] = (U8)(llclampb((S32)(slope*i + translate))); + } + + colorCorrect(contrast_lut,contrast_lut,contrast_lut); +} + // Filter Primitives void LLImageRaw::colorTransform(const LLMatrix3 &transform) { diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 404f1c0769..6e58453da5 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -289,7 +289,9 @@ public: void filterColorize(const LLColor4U& color); // Colorize with color. Alpha will be taken into account for colorization intensity. void filterContrast(F32 slope); // Change contrast according to slope: > 1.0 more contrast, < 1.0 less contrast void filterBrightness(S32 add); // Change brightness according to add: > 0 brighter, < 0 darker - + void filterColorBalance(F32 gamma_red, F32 gamma_green, F32 gamma_blue); // Change the color balance applying gammas to each channel + void filterMinMax(S32 min, S32 max); // Redistribute contrast / brightness between min and max in a linear way + // Filter Primitives void colorTransform(const LLMatrix3 &transform); void colorCorrect(const U8* lut_red, const U8* lut_green, const U8* lut_blue); |