+
+int UtcDaliImageAtlasPackToAtlas(void)
+{
+ ToolkitTestApplication application;
+
+ std::vector<PixelData> pixelDataContainer;
+ pixelDataContainer.push_back( CreatePixelData( 20, 30 ) );
+ pixelDataContainer.push_back( CreatePixelData( 10, 10 ) );
+ pixelDataContainer.push_back( CreatePixelData( 45, 30 ) );
+ pixelDataContainer.push_back( CreatePixelData( 20, 20 ) );
+
+ Dali::Vector<Vector4> textureRects;
+ Texture texture = ImageAtlas::PackToAtlas( pixelDataContainer, textureRects );
+
+ // --------------
+ // | |
+ // | 45*30 |
+// | |
+// --------------
+// | 20 | | 20*20
+// | * |____|
+// | 30 | | 10*10
+// --------
+
+ DALI_TEST_EQUALS( texture.GetWidth(), 45, TEST_LOCATION );
+ DALI_TEST_EQUALS( texture.GetHeight(), 60, TEST_LOCATION );
+
+ Rect<int> pixelArea = TextureCoordinateToPixelArea(textureRects[0], texture.GetWidth(), texture.GetHeight());
+ DALI_TEST_EQUALS( pixelArea.x, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.y, 30, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.width, 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.height, 30, TEST_LOCATION );
+
+ pixelArea = TextureCoordinateToPixelArea(textureRects[1], texture.GetWidth(), texture.GetHeight());
+ DALI_TEST_EQUALS( pixelArea.x, 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.y, 50, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.width, 10, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.height, 10, TEST_LOCATION );
+
+ pixelArea = TextureCoordinateToPixelArea(textureRects[2], texture.GetWidth(), texture.GetHeight());
+ DALI_TEST_EQUALS( pixelArea.x, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.y, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.width, 45, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.height, 30, TEST_LOCATION );
+
+ pixelArea = TextureCoordinateToPixelArea(textureRects[3], texture.GetWidth(), texture.GetHeight());
+ DALI_TEST_EQUALS( pixelArea.x, 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.y, 30, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.width, 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.height, 20, TEST_LOCATION );
+
+ END_TEST;
+}