From 0dfba807f6e622c017123e71d1bff2edb400e9e9 Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 3 Jan 2018 16:09:17 +0000 Subject: [PATCH] Added method to PixelBuffer to multiply alpha into color channels Change-Id: Ia8513bf43c182f429674d9e24236033ac8cbc601 Signed-off-by: David Steele --- adaptors/common/pixel-buffer-impl.cpp | 31 ++++++++++++++++++++++ adaptors/common/pixel-buffer-impl.h | 6 +++++ .../devel-api/adaptor-framework/pixel-buffer.cpp | 5 ++++ .../devel-api/adaptor-framework/pixel-buffer.h | 6 +++++ 4 files changed, 48 insertions(+) diff --git a/adaptors/common/pixel-buffer-impl.cpp b/adaptors/common/pixel-buffer-impl.cpp index 24ea4bc..7f12bac 100644 --- a/adaptors/common/pixel-buffer-impl.cpp +++ b/adaptors/common/pixel-buffer-impl.cpp @@ -27,6 +27,7 @@ #include "alpha-mask.h" #include "gaussian-blur.h" #include +#include namespace Dali { @@ -326,6 +327,36 @@ void PixelBuffer::ApplyGaussianBlur( const float blurRadius ) } } +void PixelBuffer::MultiplyColorByAlpha() +{ + auto bytesPerPixel = Pixel::GetBytesPerPixel( mPixelFormat ); + + if( Pixel::HasAlpha(mPixelFormat) ) + { + unsigned char* pixel = mBuffer; + const unsigned int bufferSize = mWidth * mHeight; + + for( unsigned int i=0; i