stage.Add( mView );
//Set background image for the view
- ImageAttributes attributes;
- Image image = ResourceImage::New( BACKGROUND_IMAGE, attributes );
+ Image image = ResourceImage::New( BACKGROUND_IMAGE );
Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( image );
Vector2 stageSize(Stage::GetCurrent().GetSize());
const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x));
- ImageAttributes attr;
- attr.SetSize( 128, 64 );
- attr.SetScalingMode( ImageAttributes::ScaleToFill );
- Image img = ResourceImage::New(BRICK_IMAGE_PATH[type], attr);
+ Image img = ResourceImage::New( BRICK_IMAGE_PATH[type], Dali::ImageDimensions( 128, 64 ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
ImageActor brick = ImageActor::New(img);
brick.SetParentOrigin(ParentOrigin::TOP_LEFT);
brick.SetAnchorPoint(AnchorPoint::CENTER);
/**
* @brief Load an image, scaled-down to no more than the stage dimensions.
*
- * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at
+ * Uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at
* load time to cover the entire stage with pixels with no borders,
- * and filter mode ImageAttributes::BoxThenLinear to sample the image with
+ * and filter mode BOX_THEN_LINEAR to sample the image with
* maximum quality.
*/
ResourceImage LoadStageFillingImage( const char * const imagePath )
{
Size stageSize = Stage::GetCurrent().GetSize();
- ImageAttributes attributes;
- attributes.SetSize( stageSize.x, stageSize.y );
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- attributes.SetScalingMode( ImageAttributes::ScaleToFill );
- return ResourceImage::New( imagePath, attributes );
+ return ResourceImage::New( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
}
}// end LOCAL_STUFF
DALI_ASSERT_ALWAYS(paths);
// Add a background image to the cluster, limiting the loaded size by
- // fitting it inside a quarter of the stage area with the conservative Box
+ // fitting it inside a quarter of the stage area with the conservative BOX
// filter mode:
- Dali::ImageAttributes backgroundAttributes;
- backgroundAttributes.SetSize( Stage::GetCurrent().GetSize() * 0.5f );
- backgroundAttributes.SetFilterMode( Dali::ImageAttributes::Box );
- backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ShrinkToFit );
- Image bg = ResourceImage::New( CLUSTER_BACKGROUND_IMAGE_PATH );
+ Image bg = ResourceImage::New( CLUSTER_BACKGROUND_IMAGE_PATH, Dali::ImageDimensions( stageSize.x * 0.5f, stageSize.y * 0.5f ), Dali::FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX );
ImageActor image = ImageActor::New(bg);
image.SetRelayoutEnabled( false );
clusterActor.SetBackgroundImage(image);
actor.SetAnchorPoint( AnchorPoint::CENTER );
// Load the thumbnail at quarter of screen width or standard size if that is smaller:
- ImageAttributes attribs = ImageAttributes::New();
Size stageQuarter = Stage::GetCurrent().GetSize() * 0.25f;
- attribs.SetSize( std::min( stageQuarter.x, CLUSTER_IMAGE_THUMBNAIL_WIDTH), std::min( stageQuarter.y, CLUSTER_IMAGE_THUMBNAIL_HEIGHT ) );
- attribs.SetFilterMode( Dali::ImageAttributes::BoxThenLinear );
- attribs.SetScalingMode(Dali::ImageAttributes::ShrinkToFit );
+ const ImageDimensions requestedDims = ImageDimensions( std::min( stageQuarter.x, CLUSTER_IMAGE_THUMBNAIL_WIDTH ), std::min( stageQuarter.y, CLUSTER_IMAGE_THUMBNAIL_HEIGHT ) );
// Add a shadow image child actor
- Image shadowImage = ResourceImage::New( CLUSTER_SHADOW_IMAGE_PATH, attribs );
+ Image shadowImage = ResourceImage::New( CLUSTER_SHADOW_IMAGE_PATH, requestedDims, Dali::FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX );
ImageActor shadowActor = ImageActor::New(shadowImage);
// Shadow is not exactly located on the center of the image, so it is moved to a little
actor.Add( shadowActor );
// Add a picture image actor to actor (with equal size to the parent).
- Image image = ResourceImage::New( imagePath, attribs );
+ Image image = ResourceImage::New( imagePath, requestedDims, Dali::FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX );
ImageActor imageActor = ImageActor::New( image );
imageActor.SetParentOrigin( ParentOrigin::CENTER );
imageActor.SetAnchorPoint( AnchorPoint::CENTER );
/**
* @brief Load an image, scaled-down to no more than the stage dimensions.
*
- * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at
+ * Uses image scaling mode SCALE_TO_FILL to resize the image at
* load time to cover the entire stage with pixels with no borders,
- * and filter mode ImageAttributes::BoxThenLinear to sample the image with
+ * and filter mode BOX_THEN_LINEAR to sample the image with
* maximum quality.
*/
ResourceImage LoadStageFillingImage( const char * const imagePath )
{
Size stageSize = Stage::GetCurrent().GetSize();
- ImageAttributes attributes;
- attributes.SetSize( stageSize.x, stageSize.y );
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- attributes.SetScalingMode( ImageAttributes::ScaleToFill );
- return ResourceImage::New( imagePath, attributes );
+ return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
}
} // namespace
/**
* @brief Load an image, scaled-down to no more than the stage dimensions.
*
- * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at
+ * Uses image scaling mode SCALE_TO_FILL to resize the image at
* load time to cover the entire stage with pixels with no borders,
- * and filter mode ImageAttributes::BoxThenLinear to sample the image with
+ * and filter mode BOX_THEN_LINEAR to sample the image with
* maximum quality.
*/
ResourceImage LoadStageFillingImage( const char * const imagePath )
{
Size stageSize = Stage::GetCurrent().GetSize();
- ImageAttributes attributes;
- attributes.SetSize( stageSize.x, stageSize.y );
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- attributes.SetScalingMode( ImageAttributes::ScaleToFill );
- return ResourceImage::New( imagePath, attributes );
+ return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
}
} // namespace
* The functions CreateImage and CreateImageActor below show how to build an
* image using a scaling mode to have %Dali resize it during loading.
*
- * This demo defaults to the ScaleToFill mode of ImageAttributes which makes
+ * This demo defaults to the SCALE_TO_FILL mode of ImageAttributes which makes
* sure that every pixel in the loaded image is filled with a source colour
* from the image's central region while losing the minimum number of pixels
* from its periphery.
/** The aspect ratio of cells in the image grid. */
const float CELL_ASPECT_RATIO = 1.33333333333333333333f;
-const ImageAttributes::ScalingMode DEFAULT_SCALING_MODE = ImageAttributes::ScaleToFill;
+const Dali::FittingMode::Type DEFAULT_SCALING_MODE = Dali::FittingMode::SCALE_TO_FILL;
/** The number of times to spin an image on touching, each spin taking a second.*/
const float SPIN_DURATION = 1.0f;
* @param[in] filename The path of the image.
* @param[in] width The width of the image in pixels.
* @param[in] height The height of the image in pixels.
- * @param[in] scalingMode The mode to use when scaling the image to fit the desired dimensions.
+ * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions.
*/
-Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, ImageAttributes::ScalingMode scalingMode )
+Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode )
{
#ifdef DEBUG_PRINT_DIAGNOSTICS
- fprintf( stderr, "CreateImage(%s, %u, %u, scalingMode=%u)\n", filename.c_str(), width, height, unsigned( scalingMode ) );
+ fprintf( stderr, "CreateImage(%s, %u, %u, fittingMode=%u)\n", filename.c_str(), width, height, unsigned( fittingMode ) );
#endif
- ImageAttributes attributes;
+ Image image = ResourceImage::New( filename, ImageDimensions( width, height ), fittingMode, Dali::SamplingMode::BOX_THEN_LINEAR );
- attributes.SetSize( width, height );
- attributes.SetScalingMode( scalingMode );
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- Image image = ResourceImage::New( filename, attributes );
return image;
}
* @param[in] filename The path of the image.
* @param[in] width The width of the image in pixels.
* @param[in] height The height of the image in pixels.
- * @param[in] scalingMode The mode to use when scaling the image to fit the desired dimensions.
+ * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions.
*/
-ImageActor CreateImageActor(const std::string& filename, unsigned int width, unsigned int height, ImageAttributes::ScalingMode scalingMode )
+ImageActor CreateImageActor(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode )
{
- Image img = CreateImage( filename, width, height, scalingMode );
+ Image img = CreateImage( filename, width, height, fittingMode );
ImageActor actor = ImageActor::New( img );
actor.SetName( filename );
actor.SetParentOrigin(ParentOrigin::CENTER);
}
/** Cycle the scaling mode options. */
-ImageAttributes::ScalingMode NextMode( const ImageAttributes::ScalingMode oldMode )
+Dali::FittingMode::Type NextMode( const Dali::FittingMode::Type oldMode )
{
- ImageAttributes::ScalingMode newMode = ImageAttributes::ShrinkToFit;
+ Dali::FittingMode::Type newMode = FittingMode::SHRINK_TO_FIT;
switch ( oldMode )
{
- case ImageAttributes::ShrinkToFit:
- newMode = ImageAttributes::ScaleToFill;
+ case FittingMode::SHRINK_TO_FIT:
+ newMode = FittingMode::SCALE_TO_FILL;
break;
- case ImageAttributes::ScaleToFill:
- newMode = ImageAttributes::FitWidth;
+ case FittingMode::SCALE_TO_FILL:
+ newMode = FittingMode::FIT_WIDTH;
break;
- case ImageAttributes::FitWidth:
- newMode = ImageAttributes::FitHeight;
+ case FittingMode::FIT_WIDTH:
+ newMode = FittingMode::FIT_HEIGHT;
break;
- case ImageAttributes::FitHeight:
- newMode = ImageAttributes::ShrinkToFit;
+ case FittingMode::FIT_HEIGHT:
+ newMode = FittingMode::SHRINK_TO_FIT;
break;
}
return newMode;
: mApplication( application ),
mScrolling( false )
{
- std::cout << "ImageScalingScaleToFillController::ImageScalingScaleToFillController" << std::endl;
+ std::cout << "ImageScalingIrregularGridController::ImageScalingIrregularGridController" << std::endl;
// Connect to the Application's Init signal
mApplication.InitSignal().Connect( this, &ImageScalingIrregularGridController::Create );
*/
void Create( Application& application )
{
- std::cout << "ImageScalingScaleToFillController::Create" << std::endl;
+ std::cout << "ImageScalingIrregularGridController::Create" << std::endl;
DemoHelper::RequestThemeChange();
/**
* Build the main part of the application's view.
*/
- void PopulateContentLayer( const ImageAttributes::ScalingMode scalingMode )
+ void PopulateContentLayer( const Dali::FittingMode::Type fittingMode )
{
Stage stage = Stage::GetCurrent();
Vector2 stageSize = stage.GetSize();
float fieldHeight;
- Actor imageField = BuildImageField( stageSize.x, GRID_WIDTH, GRID_MAX_HEIGHT, scalingMode, fieldHeight );
+ Actor imageField = BuildImageField( stageSize.x, GRID_WIDTH, GRID_MAX_HEIGHT, fittingMode, fieldHeight );
mScrollView = ScrollView::New();
Actor BuildImageField( const float fieldWidth,
const unsigned gridWidth,
const unsigned maxGridHeight,
- ImageAttributes::ScalingMode scalingMode,
+ Dali::FittingMode::Type fittingMode,
float & outFieldHeight )
{
// Generate the list of image configurations to be fitted into the field:
const Vector2 imageRegionCorner = gridOrigin + cellSize * Vector2( imageSource.cellX, imageSource.cellY );
const Vector2 imagePosition = imageRegionCorner + Vector2( GRID_CELL_PADDING , GRID_CELL_PADDING ) + imageSize * 0.5f;
- ImageActor image = CreateImageActor( imageSource.configuration.path, imageSize.x, imageSize.y, scalingMode );
+ ImageActor image = CreateImageActor( imageSource.configuration.path, imageSize.x, imageSize.y, fittingMode );
image.SetPosition( Vector3( imagePosition.x, imagePosition.y, 0 ) );
image.SetSize( imageSize );
image.TouchedSignal().Connect( this, &ImageScalingIrregularGridController::OnTouchImage );
- mScalingModes[image.GetId()] = scalingMode;
+ mFittingModes[image.GetId()] = fittingMode;
mSizes[image.GetId()] = imageSize;
gridActor.Add( image );
// Change the scaling mode:
const unsigned id = actor.GetId();
- ImageAttributes::ScalingMode newMode = NextMode( mScalingModes[id] );
+ Dali::FittingMode::Type newMode = NextMode( mFittingModes[id] );
const Vector2 imageSize = mSizes[actor.GetId()];
ImageActor imageActor = ImageActor::DownCast( actor );
Image oldImage = imageActor.GetImage();
Image newImage = CreateImage( ResourceImage::DownCast(oldImage).GetUrl(), imageSize.width + 0.5f, imageSize.height + 0.5f, newMode );
imageActor.SetImage( newImage );
- mScalingModes[id] = newMode;
+ mFittingModes[id] = newMode;
}
}
return false;
{
// Cycle the scaling mode options:
const Vector2 imageSize = mSizes[gridImageActor.GetId()];
- ImageAttributes::ScalingMode newMode = NextMode( mScalingModes[gridImageActor.GetId()] );
+ Dali::FittingMode::Type newMode = NextMode( mFittingModes[gridImageActor.GetId()] );
Image oldImage = gridImageActor.GetImage();
Image newImage = CreateImage(ResourceImage::DownCast(oldImage).GetUrl(), imageSize.width, imageSize.height, newMode );
gridImageActor.SetImage( newImage );
- mScalingModes[gridImageActor.GetId()] = newMode;
+ mFittingModes[gridImageActor.GetId()] = newMode;
- SetTitle( std::string( newMode == ImageAttributes::ShrinkToFit ? "ShrinkToFit" : newMode == ImageAttributes::ScaleToFill ? "ScaleToFill" : newMode == ImageAttributes::FitWidth ? "FitWidth" : "FitHeight" ) );
+ SetTitle( std::string( newMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT" : newMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL" : newMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH" : "FIT_HEIGHT" ) );
}
}
return true;
Actor mGridActor; ///< The container for the grid of images
ScrollView mScrollView; ///< ScrollView UI Component
bool mScrolling; ///< ScrollView scrolling state (true = scrolling, false = stationary)
- std::map<unsigned, ImageAttributes::ScalingMode> mScalingModes; ///< Stores the current scaling mode of each image, keyed by image actor id.
+ std::map<unsigned, Dali::FittingMode::Type> mFittingModes; ///< Stores the current scaling mode of each image, keyed by image actor id.
std::map<unsigned, Vector2> mSizes; ///< Stores the current size of each image, keyed by image actor id.
};
/**
* @brief Load an image, scaled-down to no more than the dimensions passed in.
*
- * Uses ImageAttributes::ShrinkToFit which ensures the resulting image is
+ * Uses SHRINK_TO_FIT which ensures the resulting image is
* smaller than or equal to the specified dimensions while preserving its
* original aspect ratio.
*/
ResourceImage LoadImageFittedInBox( const char * const imagePath, uint32_t maxWidth, uint32_t maxHeight )
{
// Load the image nicely scaled-down to fit within the specified max width and height:
- ImageAttributes attributes;
- attributes.SetSize( maxWidth, maxHeight);
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- attributes.SetScalingMode( ImageAttributes::ShrinkToFit );
- return ResourceImage::New( imagePath, attributes );
+ return ResourceImage::New( imagePath, ImageDimensions( maxWidth, maxHeight ), FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX_THEN_LINEAR );
}
} // unnamed namespace
ImageActor NewWindowController::CreateBlurredMirrorImage(const char* imageName)
{
FrameBufferImage fbo;
- Image image = ResourceImage::New( imageName );
- Vector2 FBOSize = ResourceImage::GetImageSize(imageName);
+ Image image = ResourceImage::New(imageName);
+ Uint16Pair intFboSize = ResourceImage::GetImageSize(imageName);
+ Vector2 FBOSize = Vector2( intFboSize.GetWidth(), intFboSize.GetHeight() );
fbo = FrameBufferImage::New( FBOSize.width, FBOSize.height, Pixel::RGBA8888);
GaussianBlurView gbv = GaussianBlurView::New(5, 2.0f, Pixel::RGBA8888, 0.5f, 0.5f, true);
gbv.SetBackgroundColor(Color::TRANSPARENT);
FrameBufferImage NewWindowController::CreateFrameBufferForImage(const char* imageName, Image image, ShaderEffect shaderEffect)
{
Stage stage = Stage::GetCurrent();
- Vector2 FBOSize = ResourceImage::GetImageSize(imageName);
+ Uint16Pair intFboSize = ResourceImage::GetImageSize(imageName);
+ Vector2 FBOSize = Vector2(intFboSize.GetWidth(), intFboSize.GetHeight());
FrameBufferImage framebuffer = FrameBufferImage::New(FBOSize.x, FBOSize.y );
DrawPath( 200u );
//Actor
- ImageAttributes attributes;
- Image img = ResourceImage::New(ACTOR_IMAGE, attributes );
+ Image img = ResourceImage::New(ACTOR_IMAGE);
mActor = ImageActor::New( img );
mActor.SetRelayoutEnabled( false );
mActor.SetAnchorPoint( AnchorPoint::CENTER );
Toolkit::Alignment::HorizontalRight,
DemoHelper::DEFAULT_PLAY_PADDING );
- Vector2 imgSize = ResourceImage::GetImageSize(TEST_OUTER_RING_FILENAME);
+
+ const Uint16Pair intImgSize = ResourceImage::GetImageSize(TEST_OUTER_RING_FILENAME);
+ Vector2 imgSize = Vector2( intImgSize.GetWidth(), intImgSize.GetHeight() );
Vector2 stageSize = stage.GetSize();
float minStageDimension = std::min(stageSize.width, stageSize.height);
mImageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
// Create the stencil
- Vector2 imageSize = ResourceImage::GetImageSize(imageName);
- float diameter = std::max(imageSize.width, imageSize.height);
+ const Uint16Pair imageSize = ResourceImage::GetImageSize(imageName);
+ float diameter = std::max(imageSize.GetWidth(), imageSize.GetHeight());
RadialSweepView radialSweepView = RadialSweepView::New();
radialSweepView.SetDiameter( diameter );
radialSweepView.SetInitialAngle( initialAngle );
/**
* @brief Load an image, scaled-down to no more than the stage dimensions.
*
- * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at
+ * Uses image scaling mode SCALE_TO_FILL to resize the image at
* load time to cover the entire stage with pixels with no borders,
- * and filter mode ImageAttributes::BoxThenLinear to sample the image with
- * maximum quality.
+ * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality.
*/
ResourceImage LoadStageFillingImage( const char * const imagePath )
{
Size stageSize = Stage::GetCurrent().GetSize();
- ImageAttributes attributes;
- attributes.SetSize( stageSize.x, stageSize.y );
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- attributes.SetScalingMode( ImageAttributes::ScaleToFill );
- return ResourceImage::New( imagePath, attributes );
+ return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
}
} // namespace
*/
ImageActor CreateImage( const std::string& filename, unsigned int width = IMAGE_THUMBNAIL_WIDTH, unsigned int height = IMAGE_THUMBNAIL_HEIGHT )
{
- ImageAttributes attributes;
+ Image img = ResourceImage::New(filename, ImageDimensions( width, height ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
- attributes.SetSize(width, height);
- attributes.SetScalingMode(ImageAttributes::ScaleToFill);
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- Image img = ResourceImage::New(filename, attributes);
ImageActor actor = ImageActor::New(img);
actor.SetRelayoutEnabled( false );
actor.SetName( filename );
// Set background image, loading it at screen resolution:
if ( !backgroundImagePath.empty() )
{
- Dali::ImageAttributes backgroundAttributes;
- backgroundAttributes.SetSize( stage.GetSize() );
- backgroundAttributes.SetFilterMode( Dali::ImageAttributes::BoxThenLinear );
- backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ScaleToFill );
- Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, backgroundAttributes );
+ Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, Dali::ImageDimensions( stage.GetSize().x, stage.GetSize().y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( backgroundImage );
view.SetBackground( backgroundImageActor );
}