// INTERNAL INCLUDES
#include "pixel-manipulation.h"
#include "alpha-mask.h"
+#include "gaussian-blur.h"
#include <platform-abstractions/portable/image-operations.h>
+#include <platform-abstractions/portable/pixel-manipulation.h>
namespace Dali
{
unsigned int width,
unsigned int height,
Dali::Pixel::Format pixelFormat )
-: mBuffer( buffer ),
+: mMetadata(),
+ mBuffer( buffer ),
mBufferSize( bufferSize ),
mWidth( width ),
mHeight( height ),
}
+void PixelBuffer::SetMetadata( const Property::Map& map )
+{
+ mMetadata.reset(new Property::Map(map));
+}
+
+bool PixelBuffer::GetMetadata(Property::Map& outMetadata) const
+{
+ if( !mMetadata )
+ {
+ return false;
+ }
+ outMetadata = *mMetadata;
+ return true;
+}
+
+void PixelBuffer::SetMetadata(std::unique_ptr<Property::Map> metadata)
+{
+ mMetadata = std::move(metadata);
+}
+
void PixelBuffer::Resize( ImageDimensions outDimensions )
{
if( mWidth != outDimensions.GetWidth() || mHeight != outDimensions.GetHeight() )
return outBuffer;
}
+void PixelBuffer::ApplyGaussianBlur( const float blurRadius )
+{
+ // This method only works for pixel buffer in RGBA format.
+ if( mWidth > 0 && mHeight > 0 && mPixelFormat == Pixel::RGBA8888 )
+ {
+ if ( blurRadius > Math::MACHINE_EPSILON_1 )
+ {
+ PerformGaussianBlurRGBA( *this, blurRadius );
+ }
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Trying to apply gaussian blur to an empty pixel buffer or a pixel buffer not in RGBA format" );
+ }
+}
+
+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<bufferSize; ++i )
+ {
+ unsigned int alpha = ReadChannel( pixel, mPixelFormat, Adaptor::ALPHA );
+ {
+ auto red = ReadChannel( pixel, mPixelFormat, Adaptor::RED);
+ auto green = ReadChannel( pixel, mPixelFormat, Adaptor::GREEN);
+ auto blue = ReadChannel( pixel, mPixelFormat, Adaptor::BLUE);
+ auto luminance = ReadChannel( pixel, mPixelFormat, Adaptor::LUMINANCE);
+ WriteChannel( pixel, mPixelFormat, Adaptor::RED, red*alpha / 255 );
+ WriteChannel( pixel, mPixelFormat, Adaptor::GREEN, green*alpha/255 );
+ WriteChannel( pixel, mPixelFormat, Adaptor::BLUE, blue*alpha/255 );
+ WriteChannel( pixel, mPixelFormat, Adaptor::LUMINANCE, luminance*alpha/255 );
+ }
+ pixel += bytesPerPixel;
+ }
+ }
+}
+
+
+
+
}// namespace Adaptor
}// namespace Internal
}// namespace Dali