/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
-BufferImage CreateBufferImage(int32_t width, int32_t height, const Vector4& color)
-{
- BufferImage image = BufferImage::New(width, height, Pixel::RGBA8888);
-
- PixelBuffer* pixbuf = image.GetBuffer();
-
- // Using a 4x4 image gives a better blend with the GL implementation
- // than a 3x3 image
- for(size_t i=0; i<16; i++)
- {
- pixbuf[i*4+0] = color.r*255;
- pixbuf[i*4+1] = color.g*255;
- pixbuf[i*4+2] = color.b*255;
- pixbuf[i*4+3] = color.a*255;
- }
-
- return image;
-}
-
-BufferImage CreateBufferImage()
-{
- return CreateBufferImage(4, 4, Color::WHITE);
-}
-
void PrepareResourceImage( TestApplication& application, uint32_t imageWidth, uint32_t imageHeight, Pixel::Format pixelFormat )
{
TestPlatformAbstraction& platform = application.GetPlatform();
#define DALI_TEST_SUITE_UTILS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
};
-
-// Helper to Create buffer image
-BufferImage CreateBufferImage();
-BufferImage CreateBufferImage(int32_t width, int32_t height, const Vector4& color);
-
-
// Prepare a resource image to be loaded. Should be called before creating the ResourceImage
void PrepareResourceImage( TestApplication& application, uint32_t imageWidth, uint32_t imageHeight, Pixel::Format pixelFormat );
}
}
-/// Helper method to create BufferImage using property
-BufferImage NewBufferImage( const Property::Value& map )
-{
- BufferImage image = BufferImage::DownCast( NewImage( map ) );
- return image;
-}
-
//////////////////////////////////////////////////////////////////////////////
// Helpers for string to enum comparisons for Actor to Property::Map
//////////////////////////////////////////////////////////////////////////////
END_TEST;
}
-int UtcDaliScriptingNewImageNegative01(void)
-{
- // Invalid filename
- Property::Map map;
- map[ "filename" ] = Vector3::ZERO;
- // will give us an empty image handle
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative06(void)
-{
- TestApplication application; // Image needs application
- // Invalid width and height
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "width" ] = "Invalid";
- map[ "height" ] = 100;
- // will give us a valid image
- PrepareResourceImage( application, 0u, 100u, Pixel::RGBA8888 );
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetWidth(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( resImage.GetHeight(), 100u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative07(void)
-{
- TestApplication application; // Image needs application
- // Invalid height
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "width" ] = 10;
- map[ "height" ] = "Invalid";
- // will give us a valid image
- PrepareResourceImage( application, 10u, 0u, Pixel::RGBA8888 );
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetWidth(), 10u, TEST_LOCATION );
- DALI_TEST_EQUALS( resImage.GetHeight(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative08(void)
-{
- TestApplication application; // Image needs application
- // Invalid fitting-mode
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "fittingMode" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative09(void)
-{
- TestApplication application; // Image needs application
- // Invalid value
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "fittingMode" ] = "INVALID";
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative10(void)
-{
- TestApplication application; // Image needs application
- // Invalid scaling-mode
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "samplingMode" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative12(void)
-{
- TestApplication application; // Image needs application
- // Invalid orientation-correction
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "orientation" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative13(void)
-{
- TestApplication application; // Image needs application
- // Invalid type
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "type" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative14(void)
-{
- // Invalid value
- Property::Map map;
- map[ "type" ] = "INVALID";
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative15(void)
-{
- // Invalid pixel-format
- Property::Map map;
- map[ "pixelFormat" ] = Vector3::ZERO;
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative16(void)
-{
- // Invalid value
- Property::Map map;
- map[ "pixelFormat" ] = "INVALID";
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage01P(void)
-{
- TestApplication application; // Image needs application
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // Filename only
- ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
- DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage04P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // float width and height
- map[ "width" ] = (float) 10.0f;
- map[ "height" ] = (float) 20.0f;
- PrepareResourceImage( application, 10u, 20u, Pixel::RGBA8888 );
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage05P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // width and height
- map[ "width"] = 50;
- map[ "height" ] = 70;
- PrepareResourceImage( application, 50u, 70u, Pixel::RGBA8888 );
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage06P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type FrameBufferImage
- map[ "type" ] = "FrameBufferImage";
- // width and height
- map[ "width"] = 50;
- map[ "height" ] = 70;
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage07P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type BufferImage
- map[ "type" ] = "BufferImage";
- // width and height
- map[ "width"] = 50;
- map[ "height" ] = 70;
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- DALI_TEST_CHECK( BufferImage::DownCast( image ) );
- DALI_TEST_EQUALS( (BufferImage::DownCast( image )).GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage08P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "type" ] = "BufferImage";
- // width and height
- map[ "width"] = 66;
- map[ "height" ] = 99;
- // pixel-format
- map[ "pixelFormat" ] = "";
- const StringEnum values[] =
- {
- { "A8", Pixel::A8 },
- { "L8", Pixel::L8 },
- { "LA88", Pixel::LA88 },
- { "RGB565", Pixel::RGB565 },
- { "BGR565", Pixel::BGR565 },
- { "RGBA4444", Pixel::RGBA4444 },
- { "BGRA4444", Pixel::BGRA4444 },
- { "RGBA5551", Pixel::RGBA5551 },
- { "BGRA5551", Pixel::BGRA5551 },
- { "RGB888", Pixel::RGB888 },
- { "RGB8888", Pixel::RGB8888 },
- { "BGR8888", Pixel::BGR8888 },
- { "RGBA8888", Pixel::RGBA8888 },
- { "BGRA8888", Pixel::BGRA8888 },
- // BufferImage does not support compressed formats
- };
- TestEnumStrings< Pixel::Format, BufferImage >( map, "pixelFormat", values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
-
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage09P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type Image
- map[ "type" ] = "ResourceImage";
- map[ "filename" ] = "TEST_FILE";
-
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
- DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
- DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage10P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type FrameBufferImage, empty size gives us stage size
- map[ "type" ] = "FrameBufferImage";
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- END_TEST;
-}
-
int UtcDaliScriptingNewActorNegative(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliScriptingCreatePropertyMapImage(void)
-{
- TestApplication application;
-
- // Empty
- {
- Image image;
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( map.Empty() );
- }
-
- // Default
- {
- Image image = ResourceImage::New( "MY_PATH" );
-
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
- DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( NULL == map.Find( "width" ) );
- DALI_TEST_CHECK( NULL == map.Find( "height" ) );
- }
-
- // Change values
- {
- PrepareResourceImage( application, 300, 400, Pixel::RGBA8888 );
- ResourceImage image = ResourceImage::New( "MY_PATH", ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
-
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
- DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "width" ) );
- DALI_TEST_EQUALS( map.Find( "width" )->Get< int >(), 300, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "height" ) );
- DALI_TEST_EQUALS( map.Find( "height" )->Get< int >(), 400, TEST_LOCATION );
- }
-
- // FrameBufferImage
- {
- Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
- }
- END_TEST;
-}
-
int UtcDaliScriptingGetEnumerationTemplates(void)
{
const Scripting::StringEnum myTable[] =
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// INTERNAL INCLUDES
#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/property-array.h>
-#include <dali/internal/common/image-attributes.h>
#include <dali/internal/event/common/property-helper.h>
-#include <dali/internal/event/images/resource-image-impl.h>
-#include <dali/internal/event/images/frame-buffer-image-impl.h>
-#include <dali/internal/event/images/buffer-image-impl.h>
namespace Dali
{
namespace Scripting
{
-namespace
-{
-
-const StringEnum PIXEL_FORMAT_TABLE[] =
-{
- { "A8", Pixel::A8 },
- { "L8", Pixel::L8 },
- { "LA88", Pixel::LA88 },
- { "RGB565", Pixel::RGB565 },
- { "BGR565", Pixel::BGR565 },
- { "RGBA4444", Pixel::RGBA4444 },
- { "BGRA4444", Pixel::BGRA4444 },
- { "RGBA5551", Pixel::RGBA5551 },
- { "BGRA5551", Pixel::BGRA5551 },
- { "RGB888", Pixel::RGB888 },
- { "RGB8888", Pixel::RGB8888 },
- { "BGR8888", Pixel::BGR8888 },
- { "RGBA8888", Pixel::RGBA8888 },
- { "BGRA8888", Pixel::BGRA8888 },
- { "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
- { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
- { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
- { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
- { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
- { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
- { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
- { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
- { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
- { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },
-};
-const uint32_t PIXEL_FORMAT_TABLE_COUNT = static_cast<uint32_t>( sizeof( PIXEL_FORMAT_TABLE ) / sizeof( PIXEL_FORMAT_TABLE[0] ) );
-
-const StringEnum IMAGE_FITTING_MODE_TABLE[] =
-{
- { "SHRINK_TO_FIT", FittingMode::SHRINK_TO_FIT },
- { "SCALE_TO_FILL", FittingMode::SCALE_TO_FILL },
- { "FIT_WIDTH", FittingMode::FIT_WIDTH },
- { "FIT_HEIGHT", FittingMode::FIT_HEIGHT },
-};
-const uint32_t IMAGE_FITTING_MODE_TABLE_COUNT = static_cast<uint32_t>( sizeof( IMAGE_FITTING_MODE_TABLE ) / sizeof( IMAGE_FITTING_MODE_TABLE[0] ) );
-
-const StringEnum IMAGE_SAMPLING_MODE_TABLE[] =
-{
- { "BOX", SamplingMode::BOX },
- { "NEAREST", SamplingMode::NEAREST },
- { "LINEAR", SamplingMode::LINEAR },
- { "BOX_THEN_NEAREST", SamplingMode::BOX_THEN_NEAREST },
- { "BOX_THEN_LINEAR", SamplingMode::BOX_THEN_LINEAR },
- { "NO_FILTER", SamplingMode::NO_FILTER },
- { "DONT_CARE", SamplingMode::DONT_CARE },
-};
-const uint32_t IMAGE_SAMPLING_MODE_TABLE_COUNT = static_cast<uint32_t>( sizeof( IMAGE_SAMPLING_MODE_TABLE ) / sizeof( IMAGE_SAMPLING_MODE_TABLE[0] ) );
-
-const char* ImageTypeName[] = { "ResourceImage", "FrameBufferImage", "BufferImage" };
-enum ImageType { RESOURCE_IMAGE, FRAME_BUFFER_IMAGE, BUFFER_IMAGE };
-const uint32_t imageTypeCount = static_cast<uint32_t>( sizeof( ImageTypeName ) / sizeof( const char* ) );
-
-} // unnamed namespace
-
bool EnumStringToInteger( const char * const value, const StringEnum* const enumTable, uint32_t tableCount, int& integerEnum )
{
int ret = 0;
return index;
}
-
-Image NewImage( const Property::Value& property )
-{
- Image ret;
-
- std::string filename;
- Internal::ImageAttributes attributes = Internal::ImageAttributes::New();
-
- const Property::Map* map = property.GetMap();
- ImageType imageType = RESOURCE_IMAGE; // default to resource image
- if( map )
- {
- // first check the type as it determines, which other parameters are needed
- const Property::Value* value = map->Find( "type" );
- if( value )
- {
- std::string type;
- value->Get( type );
- for( uint32_t i = 0; i < imageTypeCount; ++i )
- {
- if( 0 == type.compare( ImageTypeName[ i ] ) )
- {
- imageType = static_cast<ImageType>( i );
- break;
- }
- }
- }
-
- // filename is only needed for resource images
- if( RESOURCE_IMAGE == imageType )
- {
- const Property::Value* value = map->Find( "filename" );
- if( value )
- {
- value->Get( filename );
- }
- // if empty file, no need to go further
- if( filename.size() == 0 )
- {
- DALI_LOG_ERROR( "No filename\n" );
- return Image();
- }
- }
-
- // Width and height can be set individually. Dali derives the unspecified
- // dimension from the aspect ratio of the raw image.
- int32_t width = 0, height = 0;
-
- value = map->Find( "width" );
- if( value )
- {
- // handle floats and integer the same for json script
- if( value->GetType() == Property::FLOAT )
- {
- width = static_cast<uint32_t>( value->Get<float>() );
- }
- else
- {
- value->Get( width );
- }
- }
- value = map->Find( "height" );
- if( value )
- {
- if( value->GetType() == Property::FLOAT )
- {
- height = static_cast<int32_t>( value->Get<float>() );
- }
- else
- {
- value->Get( height );
- }
- }
- attributes.SetSize( width, height );
-
- Pixel::Format pixelFormat = Pixel::RGBA8888;
- value = map->Find( "pixelFormat" );
- if( value )
- {
- std::string format;
- value->Get( format );
- GetEnumeration< Pixel::Format >( format.c_str(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT, pixelFormat );
- }
-
- value = map->Find( "fittingMode" );
- if( value )
- {
- std::string fitting;
- value->Get( fitting );
- FittingMode::Type mode;
- if( GetEnumeration< FittingMode::Type >( fitting.c_str(), IMAGE_FITTING_MODE_TABLE, IMAGE_FITTING_MODE_TABLE_COUNT, mode ) )
- {
- attributes.SetScalingMode( mode );
- }
- }
-
- value = map->Find( "samplingMode" );
- if( value )
- {
- std::string sampling;
- value->Get( sampling );
- SamplingMode::Type mode;
- if( GetEnumeration< SamplingMode::Type >( sampling.c_str(), IMAGE_SAMPLING_MODE_TABLE, IMAGE_SAMPLING_MODE_TABLE_COUNT, mode ) )
- {
- attributes.SetFilterMode( mode );
- }
- }
-
- value = map->Find( "orientation" );
- if( value )
- {
- bool b = value->Get<bool>();
- attributes.SetOrientationCorrection( b );
- }
-
- switch( imageType )
- {
- case RESOURCE_IMAGE :
- {
- ret = ResourceImage::New( filename, ImageDimensions( static_cast<uint32_t>( attributes.GetSize().x ), static_cast<uint32_t>( attributes.GetSize().y ) ),
- attributes.GetScalingMode(), attributes.GetFilterMode(), attributes.GetOrientationCorrection() );
- break;
- }
- case BUFFER_IMAGE :
- {
- ret = BufferImage::New( attributes.GetWidth(),
- attributes.GetHeight(),
- pixelFormat );
- break;
- }
- case FRAME_BUFFER_IMAGE :
- {
- ret = FrameBufferImage::New( attributes.GetWidth(),
- attributes.GetHeight(),
- pixelFormat );
- break;
- }
- }
- }
-
- return ret;
-
-} // Image NewImage( Property::Value map )
-
-
Actor NewActor( const Property::Map& map )
{
BaseHandle handle;
}
}
-void CreatePropertyMap( Image image, Property::Map& map )
-{
- map.Clear();
-
- if ( image )
- {
- std::string imageType( "ResourceImage" );
-
- // Get Type - cannot use TypeRegistry as Image is not an Object and thus, not registered
- BufferImage bufferImage = BufferImage::DownCast( image );
- if ( bufferImage )
- {
- imageType = "BufferImage";
- map[ "pixelFormat" ] = GetEnumerationName< Pixel::Format >( bufferImage.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
- }
- else if ( FrameBufferImage::DownCast( image ) )
- {
- imageType = "FrameBufferImage";
- }
-
- map[ "type" ] = imageType;
-
- ResourceImage resourceImage = ResourceImage::DownCast( image );
- if( resourceImage )
- {
- map[ "filename" ] = resourceImage.GetUrl();
- }
-
- int32_t width( image.GetWidth() );
- int32_t height( image.GetHeight() );
-
- if ( width && height )
- {
- map[ "width" ] = width;
- map[ "height" ] = height;
- }
- }
-}
-
void NewAnimation( const Property::Map& map, Dali::AnimationData& outputAnimationData )
{
// Note: Builder cannot currently pass generic Property::Maps "{" that are nested, so currently we can only have one AnimateTo per animation.
#define DALI_SCRIPTING_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/public-api/actors/actor-enumerations.h>
#include <dali/public-api/actors/draw-mode.h>
#include <dali/devel-api/animation/animation-data.h>
-#include <dali/public-api/images/image.h>
#include <dali/public-api/object/property-array.h>
#include <dali/public-api/object/property-map.h>
#include <dali/public-api/object/property-value.h>
}
/**
- * @brief Creates object with data from the property value map.
- *
- * @param[in] property The property value map with the following valid fields:
- * @code
- * "filename": type std::string
- * "loadPolicy" type std::string (enum)
- * "releasePolicy" type std::string (enum)
- * "width" type float
- * "height" type float
- * "pixelFormat" type std::string (enum)
- * "fittingMode" type std::string (enum)
- * "samplingMode" type std::string (enum)
- * "orientation" type bool
- * "type" type std::string (FrameBufferImage|BufferImage|ResourceImage(default))
- * @endcode
- * Some fields are optional and some only pertain to a specific type.
- *
- * @return A pointer to a newly created object.
- */
-DALI_CORE_API Image NewImage( const Property::Value& property );
-
-/**
* @brief Creates an actor with the date from the property value map.
*
* @param[in] map The property value map with the properties (and hierarchy) of the actor required
DALI_CORE_API void CreatePropertyMap( Actor actor, Property::Map& map );
/**
- * @brief Creates a Property::Map from the image provided.
- *
- * @param[in] image The image from which a Property::Map should be created
- * @param[out] map This map is cleared and a property map of the image is filled in
- */
-DALI_CORE_API void CreatePropertyMap( Image image, Property::Map& map );
-
-/**
* @brief Creates description data required to create an Animation object from a property map.
*
* @param[in] map The property value map containing the animation description