2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <adaptor-environment-variable.h>
19 #include <dali-test-img-utils.h>
20 #include <dali-test-suite-utils.h>
22 #include <dali/dali.h>
23 #include <dali/devel-api/adaptor-framework/image-loading.h>
30 // resolution: 34*34, pixel format: RGBA8888
31 const char* IMAGE_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
32 // resolution: 128*128, pixel format: RGB888
33 const char* IMAGE_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
35 // resolution: 2000*2560, pixel format: RGB888
36 const char* IMAGE_LARGE_EXIF3_RGB = TEST_RESOURCE_DIR "/f-large-exif-3.jpg";
38 // resolution: 173*120, jpg color space: TJCS_CMYK, pixel format: RGB888
39 const char* IMAGE_TJCS_CMYK = TEST_RESOURCE_DIR "/jpg_ycck_173x120.jpg";
41 // resolution: 128*128, pixel format: RGB888, YUV411
42 const char* IMAGE_128_YUV_411 = TEST_RESOURCE_DIR "/gallery-small-1-yuv411.jpg";
43 // resolution: 128*128, pixel format: RGB888, YUV420
44 const char* IMAGE_128_YUV_420 = TEST_RESOURCE_DIR "/gallery-small-1-yuv420.jpg";
45 // resolution: 128*128, pixel format: RGB888, YUV422
46 const char* IMAGE_128_YUV_422 = TEST_RESOURCE_DIR "/gallery-small-1-yuv422.jpg";
47 // resolution: 128*128, pixel format: RGB888, YUV440
48 const char* IMAGE_128_YUV_440 = TEST_RESOURCE_DIR "/gallery-small-1-yuv440.jpg";
49 // resolution: 128*128, pixel format: RGB888, YUV444
50 const char* IMAGE_128_YUV_444 = TEST_RESOURCE_DIR "/gallery-small-1-yuv444.jpg";
52 // resolution: 55*64, pixel format: RGB888
53 const char* IMAGE_WIDTH_ODD_EXIF1_RGB = TEST_RESOURCE_DIR "/f-odd-exif-1.jpg";
54 // resolution: 55*64, pixel format: RGB888
55 const char* IMAGE_WIDTH_ODD_EXIF2_RGB = TEST_RESOURCE_DIR "/f-odd-exif-2.jpg";
56 // resolution: 55*64, pixel format: RGB888
57 const char* IMAGE_WIDTH_ODD_EXIF3_RGB = TEST_RESOURCE_DIR "/f-odd-exif-3.jpg";
58 // resolution: 55*64, pixel format: RGB888
59 const char* IMAGE_WIDTH_ODD_EXIF4_RGB = TEST_RESOURCE_DIR "/f-odd-exif-4.jpg";
60 // resolution: 55*64, pixel format: RGB888
61 const char* IMAGE_WIDTH_ODD_EXIF5_RGB = TEST_RESOURCE_DIR "/f-odd-exif-5.jpg";
62 // resolution: 55*64, pixel format: RGB888
63 const char* IMAGE_WIDTH_ODD_EXIF6_RGB = TEST_RESOURCE_DIR "/f-odd-exif-6.jpg";
64 // resolution: 55*64, pixel format: RGB888
65 const char* IMAGE_WIDTH_ODD_EXIF7_RGB = TEST_RESOURCE_DIR "/f-odd-exif-7.jpg";
66 // resolution: 55*64, pixel format: RGB888
67 const char* IMAGE_WIDTH_ODD_EXIF8_RGB = TEST_RESOURCE_DIR "/f-odd-exif-8.jpg";
69 // resolution: 50*64, pixel format: RGB888
70 const char* IMAGE_WIDTH_EVEN_EXIF1_RGB = TEST_RESOURCE_DIR "/f-even-exif-1.jpg";
71 // resolution: 50*64, pixel format: RGB888
72 const char* IMAGE_WIDTH_EVEN_EXIF2_RGB = TEST_RESOURCE_DIR "/f-even-exif-2.jpg";
73 // resolution: 50*64, pixel format: RGB888
74 const char* IMAGE_WIDTH_EVEN_EXIF3_RGB = TEST_RESOURCE_DIR "/f-even-exif-3.jpg";
75 // resolution: 50*64, pixel format: RGB888
76 const char* IMAGE_WIDTH_EVEN_EXIF4_RGB = TEST_RESOURCE_DIR "/f-even-exif-4.jpg";
77 // resolution: 50*64, pixel format: RGB888
78 const char* IMAGE_WIDTH_EVEN_EXIF5_RGB = TEST_RESOURCE_DIR "/f-even-exif-5.jpg";
79 // resolution: 50*64, pixel format: RGB888
80 const char* IMAGE_WIDTH_EVEN_EXIF6_RGB = TEST_RESOURCE_DIR "/f-even-exif-6.jpg";
81 // resolution: 50*64, pixel format: RGB888
82 const char* IMAGE_WIDTH_EVEN_EXIF7_RGB = TEST_RESOURCE_DIR "/f-even-exif-7.jpg";
83 // resolution: 50*64, pixel format: RGB888
84 const char* IMAGE_WIDTH_EVEN_EXIF8_RGB = TEST_RESOURCE_DIR "/f-even-exif-8.jpg";
86 // this is image is not exist, for negative test
87 const char* IMAGENONEXIST = "non-exist.jpg";
89 Dali::Vector<uint8_t> FileToMemory(const char* filename)
91 Dali::Vector<uint8_t> buffer;
93 fp = fopen(filename, "rb");
96 fseek(fp, 0, SEEK_END);
97 size_t size = ftell(fp);
99 fseek(fp, 0, SEEK_SET);
100 fread(buffer.Begin(), size, sizeof(uint8_t), fp);
107 void utc_dali_load_image_startup(void)
109 test_return_value = TET_UNDEF;
112 void utc_dali_load_image_cleanup(void)
114 test_return_value = TET_PASS;
117 int UtcDaliLoadImageP(void)
119 Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile(IMAGE_34_RGBA);
120 DALI_TEST_CHECK(pixelBuffer);
121 DALI_TEST_EQUALS(pixelBuffer.GetWidth(), 34u, TEST_LOCATION);
122 DALI_TEST_EQUALS(pixelBuffer.GetHeight(), 34u, TEST_LOCATION);
123 DALI_TEST_EQUALS(pixelBuffer.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
125 Devel::PixelBuffer pixelBuffer2 = Dali::LoadImageFromFile(IMAGE_128_RGB);
126 DALI_TEST_CHECK(pixelBuffer2);
127 DALI_TEST_EQUALS(pixelBuffer2.GetWidth(), 128u, TEST_LOCATION);
128 DALI_TEST_EQUALS(pixelBuffer2.GetHeight(), 128u, TEST_LOCATION);
129 DALI_TEST_EQUALS(pixelBuffer2.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
131 Devel::PixelBuffer pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_LARGE_EXIF3_RGB);
132 DALI_TEST_CHECK(pixelBufferJpeg);
133 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 2000u, TEST_LOCATION);
134 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 2560u, TEST_LOCATION);
135 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
137 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_TJCS_CMYK);
138 DALI_TEST_CHECK(pixelBufferJpeg);
139 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 173u, TEST_LOCATION);
140 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 120u, TEST_LOCATION);
141 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
143 Devel::PixelBuffer BufferJpeg1 = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF1_RGB);
144 DALI_TEST_CHECK(BufferJpeg1);
145 DALI_TEST_EQUALS(BufferJpeg1.GetWidth(), 55u, TEST_LOCATION);
146 DALI_TEST_EQUALS(BufferJpeg1.GetHeight(), 64u, TEST_LOCATION);
147 DALI_TEST_EQUALS(BufferJpeg1.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
149 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF2_RGB);
150 DALI_TEST_CHECK(pixelBufferJpeg);
151 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
152 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
153 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
154 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
156 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF3_RGB);
157 DALI_TEST_CHECK(pixelBufferJpeg);
158 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
159 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
160 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
161 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
163 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF4_RGB);
164 DALI_TEST_CHECK(pixelBufferJpeg);
165 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
166 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
167 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
168 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
170 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF5_RGB);
171 DALI_TEST_CHECK(pixelBufferJpeg);
172 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
173 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
174 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
175 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
177 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF6_RGB);
178 DALI_TEST_CHECK(pixelBufferJpeg);
179 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
180 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
181 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
182 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
184 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF7_RGB);
185 DALI_TEST_CHECK(pixelBufferJpeg);
186 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
187 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
188 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
189 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
191 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_ODD_EXIF8_RGB);
192 DALI_TEST_CHECK(pixelBufferJpeg);
193 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
194 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
195 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
196 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
198 BufferJpeg1 = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF1_RGB);
199 DALI_TEST_CHECK(BufferJpeg1);
200 DALI_TEST_EQUALS(BufferJpeg1.GetWidth(), 50u, TEST_LOCATION);
201 DALI_TEST_EQUALS(BufferJpeg1.GetHeight(), 64u, TEST_LOCATION);
202 DALI_TEST_EQUALS(BufferJpeg1.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
204 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF2_RGB);
205 DALI_TEST_CHECK(pixelBufferJpeg);
206 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
207 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
208 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
209 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
211 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF3_RGB);
212 DALI_TEST_CHECK(pixelBufferJpeg);
213 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
214 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
215 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
216 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
218 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF4_RGB);
219 DALI_TEST_CHECK(pixelBufferJpeg);
220 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
221 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
222 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
223 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
225 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF5_RGB);
226 DALI_TEST_CHECK(pixelBufferJpeg);
227 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
228 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
229 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
230 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
232 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF6_RGB);
233 DALI_TEST_CHECK(pixelBufferJpeg);
234 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
235 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
236 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
237 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
239 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF7_RGB);
240 DALI_TEST_CHECK(pixelBufferJpeg);
241 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
242 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
243 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
244 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
246 pixelBufferJpeg = Dali::LoadImageFromFile(IMAGE_WIDTH_EVEN_EXIF8_RGB);
247 DALI_TEST_CHECK(pixelBufferJpeg);
248 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
249 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
250 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
251 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
256 int UtcDaliLoadImageN(void)
258 Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile(IMAGENONEXIST);
259 DALI_TEST_CHECK(!pixelBuffer);
264 int UtcDaliLoadImageFromBufferP(void)
266 Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_34_RGBA));
267 DALI_TEST_CHECK(pixelBuffer);
268 DALI_TEST_EQUALS(pixelBuffer.GetWidth(), 34u, TEST_LOCATION);
269 DALI_TEST_EQUALS(pixelBuffer.GetHeight(), 34u, TEST_LOCATION);
270 DALI_TEST_EQUALS(pixelBuffer.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
272 Devel::PixelBuffer pixelBuffer2 = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_128_RGB));
273 DALI_TEST_CHECK(pixelBuffer2);
274 DALI_TEST_EQUALS(pixelBuffer2.GetWidth(), 128u, TEST_LOCATION);
275 DALI_TEST_EQUALS(pixelBuffer2.GetHeight(), 128u, TEST_LOCATION);
276 DALI_TEST_EQUALS(pixelBuffer2.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
278 Devel::PixelBuffer pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_LARGE_EXIF3_RGB));
279 DALI_TEST_CHECK(pixelBufferJpeg);
280 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 2000u, TEST_LOCATION);
281 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 2560u, TEST_LOCATION);
282 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
284 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_TJCS_CMYK));
285 DALI_TEST_CHECK(pixelBufferJpeg);
286 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 173u, TEST_LOCATION);
287 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 120u, TEST_LOCATION);
288 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
290 Devel::PixelBuffer BufferJpeg1 = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF1_RGB));
291 DALI_TEST_CHECK(BufferJpeg1);
292 DALI_TEST_EQUALS(BufferJpeg1.GetWidth(), 55u, TEST_LOCATION);
293 DALI_TEST_EQUALS(BufferJpeg1.GetHeight(), 64u, TEST_LOCATION);
294 DALI_TEST_EQUALS(BufferJpeg1.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
296 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF2_RGB));
297 DALI_TEST_CHECK(pixelBufferJpeg);
298 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
299 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
300 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
301 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
303 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF3_RGB));
304 DALI_TEST_CHECK(pixelBufferJpeg);
305 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
306 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
307 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
308 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
310 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF4_RGB));
311 DALI_TEST_CHECK(pixelBufferJpeg);
312 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
313 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
314 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
315 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
317 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF5_RGB));
318 DALI_TEST_CHECK(pixelBufferJpeg);
319 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
320 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
321 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
322 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
324 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF6_RGB));
325 DALI_TEST_CHECK(pixelBufferJpeg);
326 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
327 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
328 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
329 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
331 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF7_RGB));
332 DALI_TEST_CHECK(pixelBufferJpeg);
333 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
334 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
335 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
336 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
338 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_ODD_EXIF8_RGB));
339 DALI_TEST_CHECK(pixelBufferJpeg);
340 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 55u, TEST_LOCATION);
341 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
342 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
343 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
345 BufferJpeg1 = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF1_RGB));
346 DALI_TEST_CHECK(BufferJpeg1);
347 DALI_TEST_EQUALS(BufferJpeg1.GetWidth(), 50u, TEST_LOCATION);
348 DALI_TEST_EQUALS(BufferJpeg1.GetHeight(), 64u, TEST_LOCATION);
349 DALI_TEST_EQUALS(BufferJpeg1.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
351 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF2_RGB));
352 DALI_TEST_CHECK(pixelBufferJpeg);
353 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
354 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
355 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
356 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
358 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF3_RGB));
359 DALI_TEST_CHECK(pixelBufferJpeg);
360 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
361 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
362 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
363 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
365 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF4_RGB));
366 DALI_TEST_CHECK(pixelBufferJpeg);
367 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
368 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
369 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
370 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
372 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF5_RGB));
373 DALI_TEST_CHECK(pixelBufferJpeg);
374 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
375 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
376 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
377 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
379 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF6_RGB));
380 DALI_TEST_CHECK(pixelBufferJpeg);
381 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
382 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
383 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
384 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
386 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF7_RGB));
387 DALI_TEST_CHECK(pixelBufferJpeg);
388 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
389 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
390 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
391 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
393 pixelBufferJpeg = Dali::LoadImageFromBuffer(FileToMemory(IMAGE_WIDTH_EVEN_EXIF8_RGB));
394 DALI_TEST_CHECK(pixelBufferJpeg);
395 DALI_TEST_EQUALS(pixelBufferJpeg.GetWidth(), 50u, TEST_LOCATION);
396 DALI_TEST_EQUALS(pixelBufferJpeg.GetHeight(), 64u, TEST_LOCATION);
397 DALI_TEST_EQUALS(pixelBufferJpeg.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
398 DALI_IMAGE_TEST_EQUALS(BufferJpeg1, pixelBufferJpeg, 8, TEST_LOCATION);
403 int UtcDaliLoadImageFromBufferN(void)
405 Devel::PixelBuffer pixelBufferEmpty = Dali::LoadImageFromBuffer(Dali::Vector<uint8_t>());
406 DALI_TEST_CHECK(!pixelBufferEmpty);
408 Dali::Vector<uint8_t> strange;
409 strange.PushBack(0x11);
410 strange.PushBack(0x22);
411 strange.PushBack(0x33);
412 Devel::PixelBuffer pixelBufferStrange = Dali::LoadImageFromBuffer(strange);
413 DALI_TEST_CHECK(!pixelBufferStrange);
418 int UtcDaliDownloadImageP(void)
420 std::string url("file://");
421 url.append(IMAGE_34_RGBA);
423 std::string url2("file://");
424 url2.append(IMAGE_128_RGB);
426 Devel::PixelBuffer pixelBuffer = Dali::DownloadImageSynchronously(url);
427 DALI_TEST_CHECK(pixelBuffer);
428 DALI_TEST_EQUALS(pixelBuffer.GetWidth(), 34u, TEST_LOCATION);
429 DALI_TEST_EQUALS(pixelBuffer.GetHeight(), 34u, TEST_LOCATION);
430 DALI_TEST_EQUALS(pixelBuffer.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
432 Devel::PixelBuffer pixelBuffer2 = Dali::DownloadImageSynchronously(url2);
433 DALI_TEST_CHECK(pixelBuffer2);
434 DALI_TEST_EQUALS(pixelBuffer2.GetWidth(), 128u, TEST_LOCATION);
435 DALI_TEST_EQUALS(pixelBuffer2.GetHeight(), 128u, TEST_LOCATION);
436 DALI_TEST_EQUALS(pixelBuffer2.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
441 int UtcDaliDownloadImageN(void)
443 Devel::PixelBuffer pixelBuffer = Dali::DownloadImageSynchronously(IMAGENONEXIST);
444 DALI_TEST_CHECK(!pixelBuffer);
449 int UtcDaliLoadImagePlanesFromFileP(void)
451 EnvironmentVariable::SetTestEnvironmentVariable("DALI_ENABLE_DECODE_JPEG_TO_YUV_444", "1");
452 EnvironmentVariable::SetTestEnvironmentVariable("DALI_ENABLE_DECODE_JPEG_TO_YUV_422", "1");
453 EnvironmentVariable::SetTestEnvironmentVariable("DALI_ENABLE_DECODE_JPEG_TO_YUV_420", "1");
454 EnvironmentVariable::SetTestEnvironmentVariable("DALI_ENABLE_DECODE_JPEG_TO_YUV_440", "1");
455 EnvironmentVariable::SetTestEnvironmentVariable("DALI_ENABLE_DECODE_JPEG_TO_YUV_411", "1");
457 std::vector<Devel::PixelBuffer> pixelBuffers;
460 Dali::LoadImagePlanesFromFile(IMAGE_128_YUV_411, pixelBuffers);
461 DALI_TEST_EQUALS(pixelBuffers.size(), 3, TEST_LOCATION);
462 DALI_TEST_EQUALS(pixelBuffers[0].GetWidth(), 128u, TEST_LOCATION);
463 DALI_TEST_EQUALS(pixelBuffers[0].GetHeight(), 128u, TEST_LOCATION);
464 DALI_TEST_EQUALS(pixelBuffers[0].GetPixelFormat(), Pixel::L8, TEST_LOCATION);
465 DALI_TEST_EQUALS(pixelBuffers[1].GetWidth(), 32u, TEST_LOCATION);
466 DALI_TEST_EQUALS(pixelBuffers[1].GetHeight(), 128u, TEST_LOCATION);
467 DALI_TEST_EQUALS(pixelBuffers[1].GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
468 DALI_TEST_EQUALS(pixelBuffers[2].GetWidth(), 32u, TEST_LOCATION);
469 DALI_TEST_EQUALS(pixelBuffers[2].GetHeight(), 128u, TEST_LOCATION);
470 DALI_TEST_EQUALS(pixelBuffers[2].GetPixelFormat(), Pixel::CHROMINANCE_V, TEST_LOCATION);
472 pixelBuffers.clear();
475 Dali::LoadImagePlanesFromFile(IMAGE_128_YUV_420, pixelBuffers);
476 DALI_TEST_EQUALS(pixelBuffers.size(), 3, TEST_LOCATION);
477 DALI_TEST_EQUALS(pixelBuffers[0].GetWidth(), 128u, TEST_LOCATION);
478 DALI_TEST_EQUALS(pixelBuffers[0].GetHeight(), 128u, TEST_LOCATION);
479 DALI_TEST_EQUALS(pixelBuffers[0].GetPixelFormat(), Pixel::L8, TEST_LOCATION);
480 DALI_TEST_EQUALS(pixelBuffers[1].GetWidth(), 64u, TEST_LOCATION);
481 DALI_TEST_EQUALS(pixelBuffers[1].GetHeight(), 64u, TEST_LOCATION);
482 DALI_TEST_EQUALS(pixelBuffers[1].GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
483 DALI_TEST_EQUALS(pixelBuffers[2].GetWidth(), 64u, TEST_LOCATION);
484 DALI_TEST_EQUALS(pixelBuffers[2].GetHeight(), 64u, TEST_LOCATION);
485 DALI_TEST_EQUALS(pixelBuffers[2].GetPixelFormat(), Pixel::CHROMINANCE_V, TEST_LOCATION);
487 pixelBuffers.clear();
490 Dali::LoadImagePlanesFromFile(IMAGE_128_YUV_422, pixelBuffers);
491 DALI_TEST_EQUALS(pixelBuffers.size(), 3, TEST_LOCATION);
492 DALI_TEST_EQUALS(pixelBuffers[0].GetWidth(), 128u, TEST_LOCATION);
493 DALI_TEST_EQUALS(pixelBuffers[0].GetHeight(), 128u, TEST_LOCATION);
494 DALI_TEST_EQUALS(pixelBuffers[0].GetPixelFormat(), Pixel::L8, TEST_LOCATION);
495 DALI_TEST_EQUALS(pixelBuffers[1].GetWidth(), 64u, TEST_LOCATION);
496 DALI_TEST_EQUALS(pixelBuffers[1].GetHeight(), 128u, TEST_LOCATION);
497 DALI_TEST_EQUALS(pixelBuffers[1].GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
498 DALI_TEST_EQUALS(pixelBuffers[2].GetWidth(), 64u, TEST_LOCATION);
499 DALI_TEST_EQUALS(pixelBuffers[2].GetHeight(), 128u, TEST_LOCATION);
500 DALI_TEST_EQUALS(pixelBuffers[2].GetPixelFormat(), Pixel::CHROMINANCE_V, TEST_LOCATION);
502 pixelBuffers.clear();
505 Dali::LoadImagePlanesFromFile(IMAGE_128_YUV_440, pixelBuffers);
506 DALI_TEST_EQUALS(pixelBuffers.size(), 3, TEST_LOCATION);
507 DALI_TEST_EQUALS(pixelBuffers[0].GetWidth(), 128u, TEST_LOCATION);
508 DALI_TEST_EQUALS(pixelBuffers[0].GetHeight(), 128u, TEST_LOCATION);
509 DALI_TEST_EQUALS(pixelBuffers[0].GetPixelFormat(), Pixel::L8, TEST_LOCATION);
510 DALI_TEST_EQUALS(pixelBuffers[1].GetWidth(), 128u, TEST_LOCATION);
511 DALI_TEST_EQUALS(pixelBuffers[1].GetHeight(), 64u, TEST_LOCATION);
512 DALI_TEST_EQUALS(pixelBuffers[1].GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
513 DALI_TEST_EQUALS(pixelBuffers[2].GetWidth(), 128u, TEST_LOCATION);
514 DALI_TEST_EQUALS(pixelBuffers[2].GetHeight(), 64u, TEST_LOCATION);
515 DALI_TEST_EQUALS(pixelBuffers[2].GetPixelFormat(), Pixel::CHROMINANCE_V, TEST_LOCATION);
517 pixelBuffers.clear();
520 Dali::LoadImagePlanesFromFile(IMAGE_128_YUV_444, pixelBuffers);
521 DALI_TEST_EQUALS(pixelBuffers.size(), 3, TEST_LOCATION);
522 DALI_TEST_EQUALS(pixelBuffers[0].GetWidth(), 128u, TEST_LOCATION);
523 DALI_TEST_EQUALS(pixelBuffers[0].GetHeight(), 128u, TEST_LOCATION);
524 DALI_TEST_EQUALS(pixelBuffers[0].GetPixelFormat(), Pixel::L8, TEST_LOCATION);
525 DALI_TEST_EQUALS(pixelBuffers[1].GetWidth(), 128u, TEST_LOCATION);
526 DALI_TEST_EQUALS(pixelBuffers[1].GetHeight(), 128u, TEST_LOCATION);
527 DALI_TEST_EQUALS(pixelBuffers[1].GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
528 DALI_TEST_EQUALS(pixelBuffers[2].GetWidth(), 128u, TEST_LOCATION);
529 DALI_TEST_EQUALS(pixelBuffers[2].GetHeight(), 128u, TEST_LOCATION);
530 DALI_TEST_EQUALS(pixelBuffers[2].GetPixelFormat(), Pixel::CHROMINANCE_V, TEST_LOCATION);
532 pixelBuffers.clear();
534 // Test not supported image format: png
535 Dali::LoadImagePlanesFromFile(IMAGE_34_RGBA, pixelBuffers);
536 DALI_TEST_EQUALS(pixelBuffers.size(), 1, TEST_LOCATION);
537 DALI_TEST_EQUALS(pixelBuffers[0].GetWidth(), 34u, TEST_LOCATION);
538 DALI_TEST_EQUALS(pixelBuffers[0].GetHeight(), 34u, TEST_LOCATION);
539 DALI_TEST_EQUALS(pixelBuffers[0].GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
541 pixelBuffers.clear();
546 int UtcDaliLoadImagePlanesFromFileN(void)
548 std::vector<Devel::PixelBuffer> pixelBuffers;
550 Dali::LoadImagePlanesFromFile(IMAGENONEXIST, pixelBuffers);
551 DALI_TEST_CHECK(pixelBuffers.empty());