+
+int UtcDaliPixelBufferMask06(void)
+{
+ TestApplication application;
+ tet_infoline("Test application of alpha mask to same size RGBA8888 image");
+
+ unsigned int width = 10u;
+ unsigned int height = 10u;
+ Devel::PixelBuffer maskData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ Mask1stQuadrant(maskData);
+
+ width = 10u;
+ height = 10u;
+ Devel::PixelBuffer imageData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ FillCheckerboard(imageData);
+
+ imageData.ApplyMask( maskData, 1.0f, false );
+
+ // Test that the pixel format has been promoted to RGBA8888
+ DALI_TEST_EQUALS( imageData.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
+
+ // Test that a pixel in the first quadrant has no alpha value
+ unsigned char* buffer = imageData.GetBuffer();
+ DALI_TEST_EQUALS( buffer[3], 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( buffer[7], 0x00u, TEST_LOCATION );
+
+ // Test that an odd pixel in the second quadrant has full alpha value
+ DALI_TEST_EQUALS( buffer[39], 0xffu, TEST_LOCATION );
+
+ // Test that an even pixel in the second quadrant has no alpha value
+ DALI_TEST_EQUALS( buffer[27], 0x00u, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliPixelBufferMask07(void)
+{
+ TestApplication application;
+ tet_infoline("Test scaling of source image to match alpha mask" );
+
+ unsigned int width = 20u;
+ unsigned int height = 20u;
+ Devel::PixelBuffer maskData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ MaskCenterSquare(maskData);
+
+ // +----------+
+ // | XXXXXX |
+ // | XXXXXX |
+ // | XXXXXX |
+ // | XXXXXX |
+ // *----------+
+
+ width = 10u;
+ height = 10u;
+ Devel::PixelBuffer imageData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ AlternateQuadrants( imageData );
+
+ // +-----XXXXX+
+ // | XXXXX|
+ // | XXXXX|
+ // |XXXXX |
+ // |XXXXX |
+ // *XXXXX-----+
+
+ imageData.ApplyMask( maskData, 2.0f, true );
+
+ // +----------+
+ // | XXX |
+ // | XXX |
+ // | XXX |
+ // | XXX |
+ // *----------+
+
+ tet_infoline("Test that the image has been scaled to match the alpha mask" );
+ DALI_TEST_EQUALS( imageData.GetWidth(), 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageData.GetHeight(), 20, TEST_LOCATION );
+
+ tet_infoline( "Test that pixels in the outer eighths have no alpha\n" );
+
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 0, 0), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 9, 4), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 15, 4), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 19, 4), 0x00u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 0, 19), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 8, 18), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 15,17), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 19,16), 0x00u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 0, 1), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 1, 7), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 2, 10), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 3, 19), 0x00u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 19, 1), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 18, 7), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 17, 10), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 16, 19), 0x00u, TEST_LOCATION );
+
+ tet_infoline( "Test that pixels in the center have full alpha\n" );
+
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 12, 8), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 8, 12), 0xffu, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPixelBufferMask08(void)
+{
+ TestApplication application;
+ tet_infoline("Test scaling of source image to larger than the alpha mask" );
+
+ unsigned int width = 32u;
+ unsigned int height = 20u;
+ Devel::PixelBuffer maskData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ AlternateQuadrants( maskData );
+
+ // +-----XXXXX+
+ // | XXXXX|
+ // | XXXXX|
+ // |XXXXX |
+ // |XXXXX |
+ // *XXXXX-----+
+
+ width = 20u;
+ height = 16u;
+ Devel::PixelBuffer imageData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ MaskCenterSquare(imageData);
+
+ // +----------+
+ // | XXXXXX |
+ // | XXXXXX |
+ // | XXXXXX |
+ // | XXXXXX |
+ // *----------+
+
+ imageData.ApplyMask( maskData, 4.0f, true );
+
+ // +-----XXXXX+ quadrant
+ // | XXXXX| 1 2
+ // | XXXXX|
+ // |XXXXX | 4 3
+ // |XXXXX |
+ // *XXXXX-----+
+
+ tet_infoline("Test that the image has been scaled and cropped to match the alpha mask" );
+ DALI_TEST_EQUALS( imageData.GetWidth(), 32, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageData.GetHeight(), 20, TEST_LOCATION );
+
+ tet_infoline( "Test that the image has been resized (the center square should now fill the image)\n");
+ tet_infoline( "Test that the first quadrant has no alpha");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 0, 0), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 5, 4), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 5, 8), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 14, 8), 0x00u, TEST_LOCATION );
+
+ tet_infoline( "Test that the second quadrant has alpha and data");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 18, 0), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 30, 1), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 30, 8), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 19, 8), 0xffu, TEST_LOCATION );
+
+ tet_infoline( "Test that the third quadrant has no alpha");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 18, 12), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 31, 12), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 31, 19), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 18, 19), 0x00u, TEST_LOCATION );
+
+ tet_infoline( "Test that the fourth quadrant has alpha and data");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 1, 12), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 7, 12), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 7, 19), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 1, 19), 0xffu, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliPixelBufferMask09(void)
+{
+ TestApplication application;
+ tet_infoline("Test scaling of large source image to larger than the alpha mask" );
+
+ unsigned int width = 32u;
+ unsigned int height = 20u;
+ Devel::PixelBuffer maskData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ AlternateQuadrants( maskData );
+
+ // +-----XXXXX+
+ // | XXXXX|
+ // | XXXXX|
+ // |XXXXX |
+ // |XXXXX |
+ // *XXXXX-----+
+
+ width = 40u;
+ height = 50u;
+ Devel::PixelBuffer imageData = Devel::PixelBuffer::New( width, height, Pixel::RGBA8888 );
+ MaskCenterSquare(imageData);
+
+ // +----------+
+ // | XXXXXX |
+ // | XXXXXX |
+ // | XXXXXX |
+ // | XXXXXX |
+ // *----------+
+
+ imageData.ApplyMask( maskData, 1.6f, true );
+
+ // +-----XXXXX+ quadrant
+ // | XXXXX| 1 2
+ // | XXXXX|
+ // |XXXXX | 4 3
+ // |XXXXX |
+ // *XXXXX-----+
+
+ tet_infoline("Test that the image has been scaled and cropped to match the alpha mask" );
+ DALI_TEST_EQUALS( imageData.GetWidth(), 32, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageData.GetHeight(), 20, TEST_LOCATION );
+
+ tet_infoline( "Test that the image has been resized (the center square should now fill the image)\n");
+ tet_infoline( "Test that the first quadrant has no alpha");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 0, 0), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 5, 4), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 5, 8), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 14, 8), 0x00u, TEST_LOCATION );
+
+ tet_infoline( "Test that the second quadrant has alpha and data");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 18, 0), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 30, 1), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 30, 8), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 19, 8), 0xffu, TEST_LOCATION );
+
+ tet_infoline( "Test that the third quadrant has no alpha");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 18, 12), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 31, 12), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 31, 19), 0x00u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 18, 19), 0x00u, TEST_LOCATION );
+
+ tet_infoline( "Test that the fourth quadrant has alpha and data");
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 1, 12), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 7, 12), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 7, 19), 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetAlphaAt(imageData, 1, 19), 0xffu, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPixelBufferGaussianBlur(void)
+{
+ TestApplication application;
+
+ Devel::PixelBuffer imageData = Devel::PixelBuffer::New( 10, 10, Pixel::RGBA8888 );
+ FillCheckerboard(imageData);
+
+ DALI_TEST_EQUALS( imageData.GetWidth(), 10, TEST_LOCATION ) ;
+ DALI_TEST_EQUALS( imageData.GetHeight(), 10, TEST_LOCATION ) ;
+
+ unsigned char* buffer = imageData.GetBuffer();
+
+ // Test that an even pixel in the odd row has full alpha value
+ DALI_TEST_EQUALS( buffer[43], 0xffu, TEST_LOCATION );
+
+ // Test that an even pixel in the even row has no alpha value
+ DALI_TEST_EQUALS( buffer[55], 0x00u, TEST_LOCATION );
+
+ imageData.ApplyGaussianBlur( 0.0f );
+
+ // Test that the pixels' alpha values are not changed because there is no blur
+ DALI_TEST_EQUALS( buffer[43], 0xffu, TEST_LOCATION );
+ DALI_TEST_EQUALS( buffer[55], 0x00u, TEST_LOCATION );
+
+ imageData.ApplyGaussianBlur( 1.0f );
+
+ // Test that the pixels' alpha values are changed after applying gaussian blur
+ DALI_TEST_EQUALS( buffer[43], 0x7Au, TEST_LOCATION );
+ DALI_TEST_EQUALS( buffer[55], 0x7Eu, TEST_LOCATION );
+
+ END_TEST;
+}