diff options
author | Merov Linden <merov@lindenlab.com> | 2014-01-08 15:41:42 -0800 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2014-01-08 15:41:42 -0800 |
commit | 3161d822ab1336a347f1bb34574b5c4b8e747799 (patch) | |
tree | 5772b1577aa4589ef1ed8619b9fa8061d7f8f206 /indra | |
parent | c2a974f1556906f6ca69afb5942378c8dbf85169 (diff) |
ACME-1236 : WIP : Added mode and angle parameter to filterScreen (renamed for consistency)
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/integration_tests/llimage_libtest/llimage_libtest.cpp | 34 | ||||
-rwxr-xr-x | indra/llimage/llimage.cpp | 28 | ||||
-rwxr-xr-x | indra/llimage/llimage.h | 10 |
3 files changed, 59 insertions, 13 deletions
diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 69cea33911..90a7c09442 100755 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -98,7 +98,11 @@ static const char USAGE[] = "\n" " - 'darken' substracts <param> light to the image (<param> between 0 and 255).\n" " - 'linearize' optimizes the contrast using the brightness histogram. <param> is the fraction (between 0.0 and 1.0) of discarded tail of the histogram.\n" " - 'posterize' redistributes the colors between <param> classes per channel (<param> between 2 and 255).\n" -" - Any other value will be interpreted as a file name describing a sequence of filters and parameters to be applied to the input images\n" +" - 'newsscreen' applies a 2D sine screening to the red channel and output to black and white.\n" +" - 'horizontalscreen' applies a horizontal screening to the red channel and output to black and white.\n" +" - 'verticalscreen' applies a vertical screening to the red channel and output to black and white.\n" +" - 'slantedscreen' applies a 45 degrees slanted screening to the red channel and output to black and white.\n" +" - Any other value will be interpreted as a file name describing a sequence of filters and parameters to be applied to the input images.\n" " -v, --vignette <name> [<feather> <min>]\n" " Apply a circular central vignette <name> to the filter using the optional <feather> and <min> values. Admissible names:\n" " - 'blend' : the filter is applied with full intensity in the center and blends with the image to the periphery.\n" @@ -214,7 +218,17 @@ void execute_filter(const LLSD& filter_data, LLPointer<LLImageRaw> raw_image) } else if (filter_name == "screen") { - raw_image->screenFilter((S32)(filter_data[i][1].asReal())); + std::string screen_name = filter_data[i][1].asString(); + EScreenMode mode = SCREEN_MODE_2DSINE; + if (screen_name == "2Dsine") + { + mode = SCREEN_MODE_2DSINE; + } + else if (screen_name == "line") + { + mode = SCREEN_MODE_LINE; + } + raw_image->filterScreen(mode,(S32)(filter_data[i][2].asReal()),(F32)(filter_data[i][3].asReal())); } } } @@ -821,9 +835,21 @@ int main(int argc, char** argv) { raw_image->filterEqualize((S32)(filter_param),LLColor3::white); } - else if (filter_name == "screen") + else if (filter_name == "newsscreen") + { + raw_image->filterScreen(SCREEN_MODE_2DSINE,(S32)(filter_param),0.0); + } + else if (filter_name == "horizontalscreen") + { + raw_image->filterScreen(SCREEN_MODE_LINE,(S32)(filter_param),0.0); + } + else if (filter_name == "verticalscreen") + { + raw_image->filterScreen(SCREEN_MODE_LINE,(S32)(filter_param),90.0); + } + else if (filter_name == "slantedscreen") { - raw_image->screenFilter((S32)(filter_param)); + raw_image->filterScreen(SCREEN_MODE_LINE,(S32)(filter_param),45.0); } else if (filter_name != "") { diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index ae3de32788..a30646d846 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -1000,7 +1000,7 @@ void LLImageRaw::filterSaturate(F32 saturation) colorTransform(transfo); } -void LLImageRaw::filterRotate(F32 alpha) +void LLImageRaw::filterRotate(F32 angle) { // Matrix to Lij LLMatrix3 r_a; @@ -1024,9 +1024,9 @@ void LLImageRaw::filterRotate(F32 alpha) // Local color rotation transform LLMatrix3 r; - alpha *= DEG_TO_RAD; - r.setRows(LLVector3( cosf(alpha), sinf(alpha), 0.0), - LLVector3(-sinf(alpha), cosf(alpha), 0.0), + angle *= DEG_TO_RAD; + r.setRows(LLVector3( cosf(angle), sinf(angle), 0.0), + LLVector3(-sinf(angle), cosf(angle), 0.0), LLVector3( 0.0, 0.0, 1.0)); // Global color rotation transform @@ -1312,7 +1312,7 @@ void LLImageRaw::colorCorrect(const U8* lut_red, const U8* lut_green, const U8* } } -void LLImageRaw::screenFilter(const S32 wave_length) +void LLImageRaw::filterScreen(EScreenMode mode, const S32 wave_length, const F32 angle) { const S32 components = getComponents(); llassert( components >= 1 && components <= 4 ); @@ -1320,14 +1320,28 @@ void LLImageRaw::screenFilter(const S32 wave_length) S32 width = getWidth(); S32 height = getHeight(); + F32 sin = sinf(angle*DEG_TO_RAD); + F32 cos = cosf(angle*DEG_TO_RAD); + 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 + F32 value = 0.0; + F32 d = 0.0; + switch (mode) + { + case SCREEN_MODE_2DSINE: + value = (sinf(2*F_PI*i/wave_length)*sinf(2*F_PI*j/wave_length)+1.0)*255.0/2.0; + break; + case SCREEN_MODE_LINE: + d = sin*i - cos*j; + value = (sinf(2*F_PI*d/wave_length)+1.0)*255.0/2.0; + break; + } U8 dst_value = (dst_data[VRED] >= (U8)(value) ? 255 : 0); + if (mVignetteMode == VIGNETTE_MODE_NONE) { dst_data[VRED] = dst_value; diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index ed17f1af21..f2bb91a329 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -95,6 +95,12 @@ typedef enum e_vignette_mode VIGNETTE_MODE_FADE = 2 } EVignetteMode; +typedef enum e_screen_mode +{ + SCREEN_MODE_2DSINE = 0, + SCREEN_MODE_LINE = 1 +} EScreenMode; + //============================================================================ // library initialization class @@ -283,7 +289,7 @@ public: void filterGrayScale(); // Convert to grayscale void filterSepia(); // Convert to sepia void filterSaturate(F32 saturation); // < 1.0 desaturates, > 1.0 saturates - void filterRotate(F32 alpha); // Rotates hue according to alpha, alpha is an angle in degrees + void filterRotate(F32 angle); // Rotates hue according to angle, angle in degrees // Filter Operations : Color Corrections // When specified, the LLColor3 alpha parameter indicates the intensity of the effect for each color channel @@ -299,7 +305,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 filterScreen(EScreenMode mode, const S32 wave_length, const F32 angle); void setVignette(EVignetteMode mode, F32 gamma, F32 min); U32* getBrightnessHistogram(); |