From 305381e3144be6d5e9ba8b31c308ba0bff39dad7 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Thu, 12 Nov 2020 16:19:38 +0900 Subject: [PATCH] Fix pixel format bug in pixel manipulation LUMINANCE should be first in LUMINANCE_ALPHA_CHANNELS format. Change-Id: Ia9bef6173f24a54d7fc8140381affa5a342e3e1e --- automated-tests/images/circle1-LA88.png | Bin 0 -> 994 bytes .../utc-Dali-Internal-PixelBuffer.cpp | 42 +++++++++++++++++++++ .../internal/imaging/common/pixel-manipulation.cpp | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 automated-tests/images/circle1-LA88.png diff --git a/automated-tests/images/circle1-LA88.png b/automated-tests/images/circle1-LA88.png new file mode 100644 index 0000000000000000000000000000000000000000..a958733001c8de6168bc5f79cb35ce7f5a566195 GIT binary patch literal 994 zcmV<810DQ{P)Z29|!^QUcUeU19M44K~#9! z?VHU@R8bg*pE1_CbC&e8Z*o?#xUJ<^Mwz5mDvyloa8ZMsAXe_CXSIS2R)5iI+)i$ zUmA0?a*$-d;q$q~ghTYDG00ig`vsrH6@I#aUyM;Mu+ICgf0XYA;1{EheO}^k=cPgT z#b}|>8~iFJE#NB@BkZvapUNFe@Cy;;GHdMNXV7jHe<7ZbX6upp-UEDv;uYEE@eAqp z2w$P-B5W2v%x4er6^c$W&Eco;)?<8yqKy<&2JZTRuTWe!gJ16xzCuy$9>0uf9}P@W z)&kY zKh03gNc?UZPiKVSLprCOXCR${#I@(CM%ltIXBjvo2p=|bz-bB93R`!ob5=ry^e5;Y zekjUjhV(N~DGVQysB}_76#^G8EA&e!i7`=KctPWYiRxuwhd_MDp-i`gb_(4J*rjWr zT&RI^T>~XT4HWAd*ecY(HeCZ@p$5Xb1~P>j$kcrgL=A8KnUadt+@Y91l&X+k3C#<| zkLvb;X`u$DbPbFPH88GgAR^R2MAtyCPy@ZX26}`V=+QOsQK*3~T?3t~$v`OPXTt)= zLlN?HGoa`Y*!~?(CiTw*8fev@)I%PFHh0Wdpg9T{)z82P?ZVo>EjE7qrN#Tg4BT@t zKm{O`{@A_V7Y$LwZ)X{p<(i=Oza0-h(GE=peL@zvCfUYByf5P~;{M>KkoLbCA3w1& zjGl{IX$-j8>Z%i9;IO+%beqrkEpF?t$l4Jeh970GnWw-FpA0mbdW@y` z(i0w<98P9>c4E=OfwKjL`Q#z~I~xnkIlS=*|2Z4%ywcNo>H&U}>Ec +#include using namespace Dali; using namespace Dali::Internal::Adaptor; + +namespace +{ + +// resolution: 96*96, pixel format: LA88 +const char* TEST_IMAGE_LA88 = TEST_IMAGE_DIR "/circle1-LA88.png"; + +} // namespace + void utc_dali_internal_pixel_data_startup() { test_return_value = TET_UNDEF; @@ -167,6 +177,38 @@ int UtcDaliPixelManipulation02(void) END_TEST; } +int UtcDaliPixelManipulationLA88(void) +{ + tet_infoline("Testing Dali::Internal::AdaptorManipulation Read/WriteChannel - LA88 format"); + + Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile(TEST_IMAGE_LA88); + DALI_TEST_CHECK(pixelBuffer); + + unsigned int width = pixelBuffer.GetWidth(); + unsigned int height = pixelBuffer.GetHeight(); + DALI_TEST_EQUALS(width, 96u, TEST_LOCATION); + DALI_TEST_EQUALS(height, 96u, TEST_LOCATION); + DALI_TEST_EQUALS(pixelBuffer.GetPixelFormat(), Pixel::LA88, TEST_LOCATION); + + unsigned char* pixel = pixelBuffer.GetBuffer(); + unsigned int value; + + value = Dali::Internal::Adaptor::ReadChannel(&pixel[0], Dali::Pixel::LA88, Dali::Internal::Adaptor::LUMINANCE); + DALI_TEST_EQUALS(value, 0x0, TEST_LOCATION); + value = Dali::Internal::Adaptor::ReadChannel(&pixel[0], Dali::Pixel::LA88, Dali::Internal::Adaptor::ALPHA); + DALI_TEST_EQUALS(value, 0x0, TEST_LOCATION); + + // Get center pixel + unsigned int stride = width * Pixel::GetBytesPerPixel(Dali::Pixel::LA88); + unsigned int center = height / 2 * stride + width / 2 * Pixel::GetBytesPerPixel(Dali::Pixel::LA88); + value = Dali::Internal::Adaptor::ReadChannel(&pixel[center], Dali::Pixel::LA88, Dali::Internal::Adaptor::LUMINANCE); + DALI_TEST_EQUALS(value, 0x0, TEST_LOCATION); + value = Dali::Internal::Adaptor::ReadChannel(&pixel[center], Dali::Pixel::LA88, Dali::Internal::Adaptor::ALPHA); + DALI_TEST_EQUALS(value, 0xFF, TEST_LOCATION); + + END_TEST; +} + int UtcDaliPixelManipulation03N(void) { tet_infoline("Testing Dali::Internal::AdaptorManipulation Read/WriteChannel"); diff --git a/dali/internal/imaging/common/pixel-manipulation.cpp b/dali/internal/imaging/common/pixel-manipulation.cpp index fa5094a..fff8604 100644 --- a/dali/internal/imaging/common/pixel-manipulation.cpp +++ b/dali/internal/imaging/common/pixel-manipulation.cpp @@ -33,7 +33,7 @@ namespace constexpr Channel ALPHA_CHANNEL_ONLY[] = {ALPHA}; constexpr Channel LUMINANCE_CHANNEL_ONLY[] = {LUMINANCE}; -constexpr Channel LUMINANCE_ALPHA_CHANNELS[] = {ALPHA, LUMINANCE}; +constexpr Channel LUMINANCE_ALPHA_CHANNELS[] = {LUMINANCE, ALPHA}; constexpr Channel RGB_CHANNELS[] = {RED, GREEN, BLUE}; constexpr Channel BGR_CHANNELS[] = {BLUE, GREEN, RED}; constexpr Channel RGBA_CHANNELS[] = {RED, GREEN, BLUE, ALPHA}; -- 2.7.4