Toolkit::ImageView DaliTableView::NewStencilImage()
{
Toolkit::ImageView stencil = ImageView::New( TILE_BACKGROUND_ALPHA );
-
stencil.SetParentOrigin( ParentOrigin::CENTER );
stencil.SetAnchorPoint( AnchorPoint::CENTER );
stencil.SetDrawMode( DrawMode::STENCIL );
Dali::Property::Map effect = Toolkit::CreateDistanceFieldEffect();
dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, effect );
dfActor.SetColor( BUBBLE_COLOR[ i%NUMBER_OF_BUBBLE_COLOR ] );
+
layer.Add( dfActor );
}
ImageView DaliTableView::CreateLogo( std::string imagePath )
{
- Image image = ResourceImage::New( imagePath );
- ImageView logo = ImageView::New( image );
+ ImageView logo = ImageView::New( imagePath );
logo.SetAnchorPoint( AnchorPoint::CENTER );
logo.SetParentOrigin( ParentOrigin::CENTER );
mBrickCount = 0;
+ if( mBrickImageMap.Empty() )
+ {
+ Vector2 stageSize(Stage::GetCurrent().GetSize());
+ const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x));
+
+ mBrickImageMap["desiredWidth"] = static_cast<int>( brickSize.width );
+ mBrickImageMap["desiredHeight"] = static_cast<int>( brickSize.height );
+ mBrickImageMap["fittingMode"] = "SCALE_TO_FILL";
+ mBrickImageMap["samplingMode"] = "BOX_THEN_LINEAR";
+ }
+
switch(level%TOTAL_LEVELS)
{
case 0:
*/
Actor CreateBrick( const Vector2& position, int type )
{
- Vector2 stageSize(Stage::GetCurrent().GetSize());
- const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x));
-
- Image img = ResourceImage::New( BRICK_IMAGE_PATH[type], Dali::ImageDimensions( 128, 64 ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
- ImageView brick = ImageView::New(img);
+ mBrickImageMap["url"] = BRICK_IMAGE_PATH[type];
+ ImageView brick = ImageView::New();
+ brick.SetProperty( ImageView::Property::IMAGE, mBrickImageMap );
brick.SetParentOrigin(ParentOrigin::TOP_LEFT);
brick.SetAnchorPoint(AnchorPoint::CENTER);
- brick.SetSize( brickSize );
brick.SetPosition( Vector3( position ) );
// Add a constraint on the brick between it and the ball generating a collision-property
Animation mWobbleAnimation; ///< Paddle's animation when hit (wobbles)
Property::Index mWobbleProperty; ///< The wobble property (generated from animation)
Actor mLevelContainer; ///< The level container (contains bricks)
+ Property::Map mBrickImageMap; ///< The property map used to load the brick
// actor - dragging functionality
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/bubble-effect/bubble-emitter.h>
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
const Vector2 DEFAULT_BUBBLE_SIZE( 10.f, 30.f );
const unsigned int DEFAULT_NUMBER_OF_BUBBLES( 1000 );
-/**
- * @brief Load an image, scaled-down to no more than the stage dimensions.
- *
- * 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 BOX_THEN_LINEAR to sample the image with
- * maximum quality.
- */
-ResourceImage LoadStageFillingImage( const char * const imagePath )
-{
- Size stageSize = Stage::GetCurrent().GetSize();
- return ResourceImage::New( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
-}
-
}// end LOCAL_STUFF
// This example shows the usage of BubbleEmitter which displays lots of moving bubbles on the stage.
// Create and initialize the BubbleEmitter object
mBubbleEmitter = Toolkit::BubbleEmitter::New( stageSize,
- ResourceImage::New( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ),
+ DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ),
DEFAULT_NUMBER_OF_BUBBLES,
DEFAULT_BUBBLE_SIZE);
- mBackgroundImage = LoadStageFillingImage( BACKGROUND_IMAGES[mCurrentBackgroundImageId] );
+ mBackgroundImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mCurrentBackgroundImageId] );
mBubbleEmitter.SetBackground( mBackgroundImage, mHSVDelta );
// Get the root actor of all bubbles, and add it to stage.
{
if(button == mChangeBackgroundButton)
{
- mBackgroundImage = LoadStageFillingImage( BACKGROUND_IMAGES[ ++mCurrentBackgroundImageId % NUM_BACKGROUND_IMAGES ] );
+ mBackgroundImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[ ++mCurrentBackgroundImageId % NUM_BACKGROUND_IMAGES ] );
mBubbleEmitter.SetBackground( mBackgroundImage, mHSVDelta );
}
else if( button == mChangeBubbleShapeButton )
{
- mBubbleEmitter.SetShapeImage( ResourceImage::New( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) );
+ mBubbleEmitter.SetShapeImage( DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) );
}
return true;
}
// Radio 1
{
- Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_1 ) );
+ Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_1 );
image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( "1" );
{
radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
- Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_2 ) );
+ Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_2 );
image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( "2" );
{
radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
- Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_3 ) );
+ Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_3 );
image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( "3" );
radioGroup2Background.AddChild( mUpdateButton, Toolkit::TableView::CellPosition( 1, 0 ) );
// ImageView to display selected image
- mBigImage1 = ResourceImage::New( BIG_IMAGE_1 );
- mBigImage2 = ResourceImage::New( BIG_IMAGE_2 );
- mBigImage3 = ResourceImage::New( BIG_IMAGE_3 );
-
- mImage = Toolkit::ImageView::New( mBigImage1 );
+ mImage = Toolkit::ImageView::New( BIG_IMAGE_1 );
mImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
radioGroup2Background.AddChild( mImage, Toolkit::TableView::CellPosition( 0, 1, 2, 1 ) );
textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
- Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( ENABLED_IMAGE ) );
+ Toolkit::ImageView image = Toolkit::ImageView::New( ENABLED_IMAGE );
image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
image.SetPadding( Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) );
tableView.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
{
if( mRadioButtonImage1.IsSelected() )
{
- mImage.SetImage( mBigImage1 );
+ mImage.SetImage( BIG_IMAGE_1 );
}
else if( mRadioButtonImage2.IsSelected() )
{
- mImage.SetImage( mBigImage2 );
+ mImage.SetImage( BIG_IMAGE_2 );
}
else if( mRadioButtonImage3.IsSelected() )
{
- mImage.SetImage( mBigImage3 );
+ mImage.SetImage( BIG_IMAGE_3 );
}
return true;
}
Animation mAnimation;
float mLastPoint;
- Image mBigImage1;
- Image mBigImage2;
- Image mBigImage3;
Toolkit::ImageView mImage;
};
// INTERNAL INCLUDES
#include "shared/view.h"
+#include "shared/utility.h"
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
// The duration of the current image staying on screen when slideshow is on
const int VIEWINGTIME = 2000; // 2 seconds
-/**
- * @brief Load an image, scaled-down to no more than the stage dimensions.
- *
- * 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 BOX_THEN_LINEAR to sample the image with
- * maximum quality.
- */
-ResourceImage LoadStageFillingImage( const char * const imagePath )
-{
- Size stageSize = Stage::GetCurrent().GetSize();
- return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
-}
-
} // namespace
class CubeTransitionApp : public ConnectionTracker
*/
void GoToNextImage();
/**
- * Callback function of image resource loading succeed
- * Start the transition
- * @param[in] image The image content of the imageActor for transition
- */
- void OnImageLoaded(ResourceImage image);
- /**
* Main key event handler
*/
void OnKeyEvent(const KeyEvent& event);
Vector2 mViewSize;
- ResourceImage mCurrentImage;
- ResourceImage mNextImage;
+ Image mCurrentImage;
+ Image mNextImage;
unsigned int mIndex;
bool mIsImageLoading;
mViewSize = Stage::GetCurrent().GetSize();
// show the first image
- mCurrentImage = LoadStageFillingImage( IMAGES[mIndex] );
+ mCurrentImage = DemoHelper::LoadStageFillingImage( IMAGES[mIndex] );
//use small cubes
mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New( NUM_ROWS_WAVE, NUM_COLUMNS_WAVE );
void CubeTransitionApp::GoToNextImage()
{
- mNextImage = LoadStageFillingImage( IMAGES[ mIndex ] );
+ mNextImage = DemoHelper::LoadStageFillingImage( IMAGES[ mIndex ] );
mCurrentEffect.SetTargetImage( mNextImage );
- if( mNextImage.GetLoadingState() == ResourceLoadingSucceeded )
- {
- mIsImageLoading = false;
- OnImageLoaded( mNextImage );
- }
- else
- {
- mIsImageLoading = true;
- mNextImage.LoadingFinishedSignal().Connect( this, &CubeTransitionApp::OnImageLoaded );
- }
-}
-
-void CubeTransitionApp::OnImageLoaded(ResourceImage image)
-{
- mIsImageLoading = false;
- mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement );
- mCurrentImage = mNextImage;
+ mIsImageLoading = false;
+ mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement );
+ mCurrentImage = mNextImage;
}
bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button )
const float INITIAL_DEPTH = 10.0f;
/**
- * @brief Load an image, scaled-down to no more than the stage dimensions.
+ * @brief Create an image view with an image which would be scaled-down to no more than the stage dimensions.
*
* 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 BOX_THEN_LINEAR 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 )
+Toolkit::ImageView CreateStageFillingImageView( const char * const imagePath )
{
Size stageSize = Stage::GetCurrent().GetSize();
- return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
+ Toolkit::ImageView imageView = Toolkit::ImageView::New();
+ Property::Map map;
+ map["rendererType"] = "image";
+ map["url"] = imagePath;
+ map["desiredWidth"] = stageSize.x;
+ map["desiredHeight"] = stageSize.y;
+ map["fittingMode"] = "SCALE_TO_FILL";
+ map["samplingMode"] = "BOX_THEN_LINEAR";
+ map["synchronousLoading"] = true;
+ imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
+
+ return imageView;
}
} // namespace
bool mTimerReady;
unsigned int mCentralLineIndex;
- Image mIconPlay;
- Image mIconPlaySelected;
- Image mIconStop;
- Image mIconStopSelected;
Toolkit::PushButton mPlayStopButton;
-
- Image mIconHighP;
- Image mIconHighPSelected;
- Image mIconMediumP;
- Image mIconMediumPSelected;
Toolkit::PushButton mEffectChangeButton;
};
mContent = DemoHelper::CreateView( application, mView,mToolBar, "", TOOLBAR_IMAGE, "" );
// Add an effect-changing button on the right of the tool bar.
- mIconHighP = ResourceImage::New( EFFECT_HIGHP_IMAGE );
- mIconHighPSelected = ResourceImage::New( EFFECT_HIGHP_IMAGE_SELECTED );
- mIconMediumP = ResourceImage::New( EFFECT_MEDIUMP_IMAGE );
- mIconMediumPSelected = ResourceImage::New( EFFECT_MEDIUMP_IMAGE_SELECTED );
mEffectChangeButton = Toolkit::PushButton::New();
- mEffectChangeButton.SetButtonImage( mIconHighP );
- mEffectChangeButton.SetSelectedImage( mIconHighPSelected );
+ mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE );
+ mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE_SELECTED );
mEffectChangeButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked );
mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
// Add an slide-show button on the right of the title
- mIconPlay = ResourceImage::New( PLAY_ICON );
- mIconPlaySelected = ResourceImage::New( PLAY_ICON_SELECTED );
- mIconStop = ResourceImage::New( STOP_ICON );
- mIconStopSelected = ResourceImage::New( STOP_ICON_SELECTED );
mPlayStopButton = Toolkit::PushButton::New();
- mPlayStopButton.SetButtonImage( mIconPlay );
- mPlayStopButton.SetSelectedImage( mIconPlaySelected );
+ mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, PLAY_ICON );
+ mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, PLAY_ICON_SELECTED );
mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked );
mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
mContent.Add( mParent );
// show the first image
- mCurrentImage = Toolkit::ImageView::New( LoadStageFillingImage( IMAGES[mIndex] ) );
+ mCurrentImage = CreateStageFillingImageView( IMAGES[mIndex] );
mCurrentImage.SetParentOrigin( ParentOrigin::CENTER );
mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
mPanGestureDetector.Attach( mCurrentImage );
mDissolveEffect = Dali::Toolkit::CreateDissolveEffect( mUseHighPrecision );
- mEmptyEffect.Insert( "shader", Property::Value() );
+ Property::Map emptyShaderMap;
+ mEmptyEffect.Insert( "shader", emptyShaderMap );
}
// signal handler, called when the pan gesture is detected
mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES;
}
- Image image = LoadStageFillingImage( IMAGES[ mIndex ] );
- mNextImage = Toolkit::ImageView::New( image );
+ mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] );
mNextImage.SetParentOrigin( ParentOrigin::CENTER );
mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
if(mUseHighPrecision)
{
mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_HIGHP) );
- mEffectChangeButton.SetButtonImage( mIconHighP );
- mEffectChangeButton.SetSelectedImage( mIconHighPSelected );
+ mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE );
+ mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE_SELECTED );
}
else
{
mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_MEDIUMP) );
- mEffectChangeButton.SetButtonImage( mIconMediumP );
- mEffectChangeButton.SetSelectedImage( mIconMediumPSelected );
+ mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_MEDIUMP_IMAGE );
+ mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_MEDIUMP_IMAGE_SELECTED );
}
return true;
mSlideshow = !mSlideshow;
if( mSlideshow )
{
- mPlayStopButton.SetButtonImage( mIconStop );
- mPlayStopButton.SetSelectedImage( mIconStopSelected );
+ mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, STOP_ICON );
+ mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, STOP_ICON_SELECTED );
mPanGestureDetector.Detach( mParent );
mViewTimer.Start();
mTimerReady = false;
}
else
{
- mPlayStopButton.SetButtonImage( mIconPlay );
- mPlayStopButton.SetSelectedImage( mIconPlaySelected );
+ mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, PLAY_ICON );
+ mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, PLAY_ICON_SELECTED );
mTimerReady = true;
mPanGestureDetector.Attach( mParent );
}
void DissolveEffectApp::OnTransitionCompleted( Animation& source )
{
- mNextImage.SetProperty( Toolkit::ImageView::Property::IMAGE, mEmptyEffect );
+ if(mUseHighPrecision)
+ {
+ mNextImage.SetProperty( Toolkit::ImageView::Property::IMAGE, mEmptyEffect );
+ }
mParent.Remove( mCurrentImage );
mPanGestureDetector.Detach( mCurrentImage );
mCurrentImage = mNextImage;
if(mSlideshow)
{
mIndex = (mIndex + 1)%NUM_IMAGES;
- Image image = LoadStageFillingImage( IMAGES[ mIndex ] );
- mNextImage = Toolkit::ImageView::New( image );
+ mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] );
mNextImage.SetParentOrigin( ParentOrigin::CENTER );
mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
// Back and next image buttons in corners of stage:
unsigned int playWidth = std::min( stage.GetSize().x * (1 / 5.0f), 58.0f );
- Image playImage = ResourceImage::New( DALI_ICON_PLAY, ImageDimensions( playWidth, playWidth ), FittingMode::SHRINK_TO_FIT, SamplingMode::BOX_THEN_LINEAR );
- Toolkit::ImageView imagePrevious = Toolkit::ImageView::New( playImage );
+ Toolkit::ImageView imagePrevious = Toolkit::ImageView::New( DALI_ICON_PLAY, ImageDimensions( playWidth, playWidth ) );
// Last image button:
imagePrevious.SetAnchorPoint( AnchorPoint::TOP_LEFT );
imagePrevious.TouchSignal().Connect( this, &ImageScalingAndFilteringController::OnControlTouched );
// Next image button:
- Toolkit::ImageView imageNext = Toolkit::ImageView::New( playImage );
+ Toolkit::ImageView imageNext = Toolkit::ImageView::New( DALI_ICON_PLAY, ImageDimensions( playWidth, playWidth ) );
imageNext.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
imageNext.SetY( playWidth * 0.5f );
imageNext.SetX( stage.GetSize().x - playWidth * 0.5f );
using namespace Dali;
+namespace
+{
+const char* const IMAGE_PATH ( DEMO_IMAGE_DIR "gallery-large-20.jpg" );
+}
+
class ImageViewAlphaBlendApp : public ConnectionTracker
{
public:
Vector4 green1 = Vector4( 0.f, 0.25f, 0.f, 0.25f );
BufferImage redGreen0 = CreateBufferImage( Color::RED, green0 );
BufferImage redGreen1 = CreateBufferImage( Color::RED, green1 );
- ResourceImage testImage = ResourceImage::New( DEMO_IMAGE_DIR "gallery-large-20.jpg" );
float imageSize = 512.f;
- Toolkit::ImageView imageView0 = Toolkit::ImageView::New( testImage );
+ Toolkit::ImageView imageView0 = Toolkit::ImageView::New( IMAGE_PATH );
imageView0.SetSize(imageSize, imageSize);
imageView0.SetParentOrigin( ParentOrigin::CENTER );
imageView0.SetY( -imageSize*0.5f );
imageView1.SetSize(imageSize, imageSize);
imageView0.Add(imageView1);
- Toolkit::ImageView imageView2 = Toolkit::ImageView::New( testImage);
+ Toolkit::ImageView imageView2 = Toolkit::ImageView::New( IMAGE_PATH );
imageView2.SetSize(imageSize, imageSize);
imageView2.SetParentOrigin( ParentOrigin::CENTER );
imageView2.SetY( imageSize*0.5f );
// INTERNAL INCLUDES
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
for( unsigned i=0; i<NUMBER_OF_SAMPLES; ++i)
{
- Image image = ResourceImage::New( IMAGES[i] );
+ Texture texture = DemoHelper::LoadTexture( IMAGES[i] );
TextureSet textureSet = TextureSet::New();
- textureSet.SetImage( 0u, image );
+ textureSet.SetTexture( 0u, texture );
if( i==0 ) { firstTextureSet = textureSet; }
Renderer renderer = Renderer::New( mGeometry, mShader );
#include <dali-toolkit/dali-toolkit.h>
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
using namespace Dali::Toolkit;
stage.SetBackgroundColor(Color::BLACK);
//Set background image for the view
- mBackImage = ResourceImage::New( BACKGROUND_IMAGE );
+ mBackImage = DemoHelper::LoadImage( BACKGROUND_IMAGE );
srand((unsigned)time(0));
#include <cstdio>
#include <string>
+#include "shared/utility.h"
using namespace Dali;
using namespace Dali::Toolkit;
stage.SetBackgroundColor(Color::BLACK);
//Set background image for the view
- mBackImage = ResourceImage::New( BACKGROUND_IMAGE );
+ mBackImage = DemoHelper::LoadImage( BACKGROUND_IMAGE );
mGravity = Vector2(GRAVITY_X,GRAVITY_Y);
mGravityVar = Vector2(0,0);
Vector2 screenSize = stage.GetSize();
//Add background
- Image imageBackground = ResourceImage::New( BACKGROUND_IMAGE );
- Toolkit::ImageView backView = Toolkit::ImageView::New(imageBackground);
+ Toolkit::ImageView backView = Toolkit::ImageView::New(BACKGROUND_IMAGE);
backView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
stage.Add(backView);
const float ORIENTATION_DURATION = 0.5f; ///< Time to rotate to new orientation.
/**
- * @brief Load an image, scaled-down to no more than the dimensions passed in.
+ * @brief Set an image to image view, scaled-down to no more than the dimensions passed in.
*
* Uses SHRINK_TO_FIT which ensures the resulting image is
- * smaller than or equal to the specified dimensions while preserving its
- * original aspect ratio.
+ * 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 )
+void SetImageFittedInBox( ImageView& imageView, Property::Map& shaderEffect, const char * const imagePath, int maxWidth, int maxHeight )
{
+ Property::Map map;
+ map["rendererType"] = "image";
+ map["url"] = imagePath;
// Load the image nicely scaled-down to fit within the specified max width and height:
- return ResourceImage::New( imagePath, ImageDimensions( maxWidth, maxHeight ), FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX_THEN_LINEAR );
+ map["desiredWidth"] = maxWidth;
+ map["desiredHeight"] = maxHeight;
+ map["fittingMode"] = "SHRINK_TO_FIT";
+ map["samplingMode"] = "BOX_THEN_LINEAR";
+ map.Merge( shaderEffect );
+
+ imageView.SetProperty( ImageView::Property::IMAGE, map );
}
} // unnamed namespace
mMotionBlurActorSize = Size( std::min( stageSize.x * 0.3f, MOTION_BLUR_ACTOR_WIDTH ), std::min( stageSize.y * 0.3f, MOTION_BLUR_ACTOR_HEIGHT ) );
mMotionBlurActorSize = Size( std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ), std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ) );
- Image image = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGE1, mMotionBlurActorSize.x, mMotionBlurActorSize.y );
- mMotionBlurImageView = ImageView::New(image);
+ mMotionBlurEffect = CreateMotionBlurEffect();
+ mMotionBlurImageView = ImageView::New();
+ SetImageFittedInBox( mMotionBlurImageView, mMotionBlurEffect, MOTION_BLUR_ACTOR_IMAGE1, mMotionBlurActorSize.x, mMotionBlurActorSize.y );
mMotionBlurImageView.SetParentOrigin( ParentOrigin::CENTER );
mMotionBlurImageView.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
// set actor shader to the blur one
Toolkit::SetMotionBlurProperties( mMotionBlurImageView, MOTION_BLUR_NUM_SAMPLES );
- mMotionBlurImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect );
#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
{
mCurrentImage = 0;
}
+ SetImageFittedInBox( mMotionBlurImageView, mMotionBlurEffect, MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y );
- Image blurImage = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y );
-
- mMotionBlurImageView.SetImage(blurImage);
#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
mMotionBlurImageView2.SetImage(blurImage);
mMotionBlurImageView3.SetImage(blurImage);
//
// Motion stretched actor
//
-
- mMotionStretchImageView = ImageView::New( MOTION_STRETCH_ACTOR_IMAGE1 );
+ mMotionStretchEffect = Toolkit::CreateMotionStretchEffect();
+ mMotionStretchEffect["url"] = MOTION_STRETCH_ACTOR_IMAGE1;
+ mMotionStretchImageView = ImageView::New();
+ mMotionStretchImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionStretchEffect );
mMotionStretchImageView.SetParentOrigin( ParentOrigin::CENTER );
mMotionStretchImageView.SetAnchorPoint( AnchorPoint::CENTER );
mMotionStretchImageView.SetSize( MOTION_STRETCH_ACTOR_WIDTH, MOTION_STRETCH_ACTOR_HEIGHT );
mContentLayer.Add( mMotionStretchImageView );
// Create shader used for doing motion stretch
- mMotionStretchEffect = Toolkit::CreateMotionStretchEffect();
Toolkit::SetMotionStretchProperties( mMotionStretchImageView );
- mMotionStretchImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionStretchEffect );
}
//////////////////////////////////////////////////////////////
mCurrentImage = 0;
}
- Image stretchImage = ResourceImage::New( MOTION_STRETCH_ACTOR_IMAGES[mCurrentImage] );
- mMotionStretchImageView.SetImage(stretchImage);
+ mMotionStretchEffect["url"] = MOTION_STRETCH_ACTOR_IMAGES[mCurrentImage];
+ mMotionStretchImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionStretchEffect );
}
// INTERNAL INCLUDES
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
using namespace Dali::Toolkit;
"Context recovery" );
Size stageSize = stage.GetSize();
- Image backgroundImage = ResourceImage::New( BACKGROUND_IMAGE, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
- ImageView backgroundActor = ImageView::New( backgroundImage );
+ ImageView backgroundActor = ImageView::New( BACKGROUND_IMAGE, Dali::ImageDimensions( stageSize.x, stageSize.y ) );
backgroundActor.SetParentOrigin( ParentOrigin::CENTER );
mContentLayer.Add(backgroundActor);
logoLayoutActor.SetScale(0.5f);
backgroundActor.Add(logoLayoutActor);
- Image image = ResourceImage::New(LOGO_IMAGE);
- ImageView imageView = ImageView::New(image);
+ ImageView imageView = ImageView::New( LOGO_IMAGE );
imageView.SetName("daliLogo");
imageView.SetParentOrigin(ParentOrigin::CENTER);
imageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
logoLayoutActor.Add(imageView);
ImageView mirrorImageView = CreateBlurredMirrorImage(LOGO_IMAGE);
- mirrorImageView.SetParentOrigin(ParentOrigin::CENTER);
- mirrorImageView.SetAnchorPoint(AnchorPoint::TOP_CENTER);
+ mirrorImageView.SetParentOrigin(ParentOrigin::TOP_CENTER);
+ mirrorImageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
logoLayoutActor.Add(mirrorImageView);
AddBubbles( backgroundActor, stage.GetSize());
void NewWindowController::AddBubbles( Actor& parentActor, const Vector2& stageSize)
{
mEmitter = Toolkit::BubbleEmitter::New( stageSize,
- ResourceImage::New( DEMO_IMAGE_DIR "bubble-ball.png" ),
+ DemoHelper::LoadImage( DEMO_IMAGE_DIR "bubble-ball.png" ),
200, Vector2( 5.0f, 5.0f ) );
- Image background = ResourceImage::New(BACKGROUND_IMAGE);
+ Image background = DemoHelper::LoadImage(BACKGROUND_IMAGE);
mEmitter.SetBackground( background, Vector3(0.5f, 0.f,0.5f) );
mEmitter.SetBubbleDensity( 9.f );
Actor bubbleRoot = mEmitter.GetRootActor();
colorMeshActor.SetName("ColorMeshActor");
// Create a textured mesh
- Image effectImage = ResourceImage::New(EFFECT_IMAGE);
+ Texture effectTexture = DemoHelper::LoadTexture(EFFECT_IMAGE);
Shader shaderTextureMesh = Shader::New( VERTEX_TEXTURE_MESH, FRAGMENT_TEXTURE_MESH );
TextureSet textureSet = TextureSet::New();
- textureSet.SetImage( 0u, effectImage );
+ textureSet.SetTexture( 0u, effectTexture );
Renderer textureMeshRenderer = Renderer::New( meshGeometry, shaderTextureMesh );
textureMeshRenderer.SetTextures( textureSet );
Property::Map map;
map[ "shader" ] = customShader;
- Image baseImage = ResourceImage::New(BASE_IMAGE);
- ImageView blendActor = ImageView::New( baseImage );
+ ImageView blendActor = ImageView::New( BASE_IMAGE );
blendActor.SetProperty( ImageView::Property::IMAGE, map );
blendActor.RegisterProperty( "alpha", 0.5f );
ImageView NewWindowController::CreateBlurredMirrorImage(const char* imageName)
{
- Image image = ResourceImage::New(imageName);
+ Image image = DemoHelper::LoadImage(imageName);
- Uint16Pair intFboSize = ResourceImage::GetImageSize(imageName);
- Vector2 FBOSize = Vector2( intFboSize.GetWidth(), intFboSize.GetHeight() );
+ Vector2 FBOSize = Vector2( image.GetWidth(), image.GetHeight() );
FrameBufferImage fbo = FrameBufferImage::New( FBOSize.width, FBOSize.height, Pixel::RGBA8888);
GaussianBlurView gbv = GaussianBlurView::New(5, 2.0f, Pixel::RGBA8888, 0.5f, 0.5f, true);
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/image-atlas/image-atlas.h>
+#include <dali/devel-api/images/atlas.h>
#include <assert.h>
#include <cstdlib>
#include <iostream>
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
using namespace Dali::Toolkit;
// set a ratio to modify the current page number when the rotation is changed
const float PAGE_NUMBER_CORRESPONDING_RATIO(1.25f);
-const char* BOOK_COVER_PORTRAIT = ( DEMO_IMAGE_DIR "book-portrait-cover.jpg" );
-const char* BOOK_COVER_LANDSCAPE = ( DEMO_IMAGE_DIR "book-landscape-cover.jpg" );
-const char* BOOK_COVER_BACK_LANDSCAPE = ( DEMO_IMAGE_DIR "book-landscape-cover-back.jpg" );
+const char* BOOK_COVER_PORTRAIT( DEMO_IMAGE_DIR "book-portrait-cover.jpg" );
+const char* BOOK_COVER_LANDSCAPE( DEMO_IMAGE_DIR "book-landscape-cover.jpg" );
+const char* BOOK_COVER_BACK_LANDSCAPE( DEMO_IMAGE_DIR "book-landscape-cover-back.jpg" );
const char* PAGE_IMAGES_PORTRAIT[] =
{
};
const unsigned int NUMBER_OF_LANDSCAPE_IMAGE( sizeof(PAGE_IMAGES_LANDSCAPE) / sizeof(PAGE_IMAGES_LANDSCAPE[0]) );
+Atlas LoadImages( const char*imagePath1, const char* imagePath2 )
+{
+ PixelData pixelData1 = DemoHelper::LoadPixelData( imagePath1, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT );
+ PixelData pixelData2 = DemoHelper::LoadPixelData( imagePath2, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT );
+
+ unsigned int width = pixelData1.GetWidth()+pixelData2.GetWidth();
+ unsigned int height = pixelData1.GetHeight() > pixelData2.GetHeight() ? pixelData1.GetHeight() : pixelData2.GetHeight();
+
+ Atlas image = Atlas::New( width, height );
+ image.Upload( pixelData1, 0u, 0u );
+ image.Upload( pixelData2, pixelData1.GetWidth(), 0u );
+
+ return image;
+}
+
}// end LOCAL STUFF
class PortraitPageFactory : public PageFactory
*/
virtual Image NewPage( unsigned int pageId )
{
- Image page;
+ Atlas page;
if( pageId == 0 )
{
- page = ResourceImage::New( BOOK_COVER_PORTRAIT );
+ page = DemoHelper::LoadImage( BOOK_COVER_PORTRAIT );
}
else
{
- page = ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] );
+ page = DemoHelper::LoadImage( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] );
}
return page;
*/
virtual Image NewPage( unsigned int pageId )
{
- if( mImageSize.GetWidth() == 0u || mImageSize.GetHeight() == 0u )
- {
- mImageSize = ResourceImage::GetImageSize(BOOK_COVER_LANDSCAPE);
- }
- ImageAtlas atlas = ImageAtlas::New( mImageSize.GetWidth()*2u, mImageSize.GetHeight(), Pixel::RGB888 );
- Vector4 textureRect;
+ Atlas page;
if( pageId == 0 )
{
- atlas.Upload( textureRect, BOOK_COVER_LANDSCAPE, mImageSize );
- atlas.Upload( textureRect, BOOK_COVER_BACK_LANDSCAPE, mImageSize );
+ page = LoadImages( BOOK_COVER_LANDSCAPE, BOOK_COVER_BACK_LANDSCAPE );
}
else
{
unsigned int imageId = (pageId-1)*2;
- atlas.Upload( textureRect, PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ], mImageSize );
- atlas.Upload( textureRect, PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ], mImageSize );
+ page = LoadImages( PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ], PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] );
}
- return atlas.GetAtlas();
+ return page;
}
-
- ImageDimensions mImageSize;
};
/**
#include <dali/integration-api/debug.h>
#include <iostream>
+#include "shared/utility.h"
+
using namespace Dali;
using namespace Dali::Toolkit;
Shader shader = Shader::New( VERTEX_SHADER_TEXTURE, FRAGMENT_SHADER_TEXTURE );
const char* imagePath = !gNinePatch ? IMAGE_PATH[index] : NINEPATCH_IMAGE_PATH[index];
- Image image = ResourceImage::New( imagePath );
+ Texture texture = DemoHelper::LoadTexture( imagePath );
TextureSet textureSet = TextureSet::New();
- textureSet.SetImage( 0u, image );
+ textureSet.SetTexture( 0u, texture );
renderers[index] = Renderer::New( QuadMesh(), shader );
renderers[index].SetTextures( textureSet );
renderers[index].SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
// INTERNAL INCLUDES
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
// Hide the indicator bar
application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
- Image image0 = ResourceImage::New( MATERIAL_SAMPLE );
- Image image1 = ResourceImage::New( MATERIAL_SAMPLE2 );
+ Texture texture0 = DemoHelper::LoadTexture( MATERIAL_SAMPLE );
+ Texture texture1 = DemoHelper::LoadTexture( MATERIAL_SAMPLE2 );
Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
TextureSet textureSet = TextureSet::New();
- textureSet.SetImage( 0u, image0 );
- textureSet.SetImage( 1u, image1 );
+ textureSet.SetTexture( 0u, texture0 );
+ textureSet.SetTexture( 1u, texture1 );
Geometry geometry = CreateGeometry();
bool mContextual; ///< True if currently using the contextual popup mode.
bool mAnimationFade; ///< True if currently using the fade animation.
- ResourceImage mContextButtonDisabledImage; ///< The disabled context button icon.
- ResourceImage mContextButtonEnabledImage; ///< The enabled context button icon.
- ResourceImage mAnimationButtonZoomImage; ///< The zoom animation button icon.
- ResourceImage mAnimationButtonFadeImage; ///< The fade animation button icon.
-
Toolkit::Popup mPopup; ///< The current example popup.
Toolkit::ItemView mItemView; ///< ItemView to hold test images
mRadialSweepView3.SetInitialActorAngle(Degree(-110));
mRadialSweepView3.SetFinalActorAngle(Degree(0));
- Image dial = ResourceImage::New( TEST_DIAL_FILENAME );
- mDialView = ImageView::New( dial );
+ mDialView = ImageView::New( TEST_DIAL_FILENAME );
mDialView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
mDialView.SetParentOrigin( ParentOrigin::CENTER );
mDialView.SetScale(scale);
Degree finalAngle)
{
// Create the image
- Image image = ResourceImage::New(imageName);
- mImageView = ImageView::New(image);
+ mImageView = ImageView::New(imageName);
mImageView.SetParentOrigin(ParentOrigin::CENTER);
mImageView.SetAnchorPoint(AnchorPoint::CENTER);
mImageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
// INTERNAL INCLUDES
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
};
/**
- * @brief Load an image, scaled-down to no more than the stage dimensions.
- *
- * 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 BOX_THEN_LINEAR to sample the image with maximum quality.
- */
-ResourceImage LoadStageFillingImage( const char * const imagePath )
-{
- Size stageSize = Stage::GetCurrent().GetSize();
- return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
-}
-
-/**
* structure of the vertex in the mesh
*/
struct Vertex
mShaderFlat = Shader::New( VERTEX_SHADER_FLAT, FRAGMENT_SHADER_FLAT );
mGeometry = CreateGeometry( MESH_FILES[mCurrentMeshId] );
- Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] );
+ Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] );
mTextureSet = TextureSet::New();
- mTextureSet.SetImage( 0u, texture );
+ mTextureSet.SetTexture( 0u, texture );
mRenderer = Renderer::New( mGeometry, mShaderFlat );
mRenderer.SetTextures( mTextureSet );
bool OnChangeTexture( Toolkit::Button button )
{
mCurrentTextureId = ( mCurrentTextureId + 1 ) % NUM_TEXTURE_IMAGES;
- Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] );
- mTextureSet.SetImage( 0u, texture );
+ Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] );
+ mTextureSet.SetTexture( 0u, texture );
return true;
}
* @param[in] width the width of the image in texels
* @param[in] height the height of the image in texels.
*/
- ImageView CreateImage( const std::string& filename, unsigned int width = IMAGE_THUMBNAIL_WIDTH, unsigned int height = IMAGE_THUMBNAIL_HEIGHT )
+ ImageView CreateImage( const std::string& filename, int width = IMAGE_THUMBNAIL_WIDTH, int height = IMAGE_THUMBNAIL_HEIGHT )
{
- Image img = ResourceImage::New(filename, ImageDimensions( width, height ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
+ ImageView actor = ImageView::New();
+ Property::Map map;
+ map["rendererType"] = "image";
+ map["url"] = filename;
+ map["desiredWidth"] = width;
+ map["desiredHeight"] = height;
+ map["fittingMode"] = "SCALE_TO_FILL";
+ map["samplingMode"] = "BOX_THEN_LINEAR";
+ actor.SetProperty( ImageView::Property::IMAGE, map );
- ImageView actor = ImageView::New(img);
actor.SetName( filename );
actor.SetParentOrigin(ParentOrigin::CENTER);
actor.SetAnchorPoint(AnchorPoint::CENTER);
#include <dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h>
#include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
DEMO_IMAGE_DIR "background-magnifier.jpg",
};
const unsigned int NUM_BACKGROUND_IMAGES( sizeof( BACKGROUND_IMAGES ) / sizeof( BACKGROUND_IMAGES[0] ) );
-}
-/**
- * @brief Load an image, scaled-down to no more than the stage dimensions.
- *
- * 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 BOX_THEN_LINEAR to sample the image with
- * maximum quality.
- */
-ResourceImage LoadStageFillingImage( const char * const imagePath )
-{
- Size stageSize = Stage::GetCurrent().GetSize();
- return ResourceImage::New( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
}
class BlurExample : public ConnectionTracker
mSuperBlurView.SetParentOrigin( ParentOrigin::CENTER );
mSuperBlurView.SetAnchorPoint( AnchorPoint::CENTER );
mSuperBlurView.BlurFinishedSignal().Connect(this, &BlurExample::OnBlurFinished);
- mCurrentImage = LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] );
+ mCurrentImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] );
mSuperBlurView.SetImage( mCurrentImage );
mBackground.Add( mSuperBlurView );
mIsBlurring = true;
}
mImageIndex = (mImageIndex+1u)%NUM_BACKGROUND_IMAGES;
- mCurrentImage = LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] );
+ mCurrentImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] );
if( mSuperBlurView.OnStage() )
{
button.SetSelectedImage( FOLDER_OPEN_ICON_IMAGE );
button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
- ResourceImage imageClosed = ResourceImage::New( FOLDER_ICON_IMAGE );
- button.SetSize( imageClosed.GetWidth(), imageClosed.GetHeight() );
+ ImageDimensions imageSize = ResourceImage::GetImageSize( FOLDER_ICON_IMAGE );
+ button.SetSize( imageSize.GetWidth(), imageSize.GetHeight() );
return button;
}
stage.Add( mContainer );
// Resize the center layout when the corner is grabbed
- mGrabCorner = Control::New();
+ mGrabCorner = ImageView::New( BACKGROUND_IMAGE );
mGrabCorner.SetName( "GrabCorner" );
mGrabCorner.SetAnchorPoint( AnchorPoint::TOP_CENTER );
mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT );
- mGrabCorner.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) );
mGrabCorner.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
mContainer.Add( mGrabCorner );
// INTERNAL INCLUDES
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
// Hide the indicator bar
application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
- mImage = ResourceImage::New( MATERIAL_SAMPLE );
- Image image = ResourceImage::New( MATERIAL_SAMPLE2 );
+ Texture texture1 = DemoHelper::LoadTexture( MATERIAL_SAMPLE );
+ Texture texture2 = DemoHelper::LoadTexture( MATERIAL_SAMPLE2 );
mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
mTextureSet1 = TextureSet::New();
- mTextureSet1.SetImage( 0u, mImage );
+ mTextureSet1.SetTexture( 0u, texture1 );
mTextureSet2 = TextureSet::New();
- mTextureSet2.SetImage( 0u, image );
+ mTextureSet2.SetTexture( 0u, texture2 );
mGeometry = CreateGeometry();
Application& mApplication; ///< Application instance
Vector3 mStageSize; ///< The size of the stage
- Image mImage;
Shader mShader;
TextureSet mTextureSet1;
TextureSet mTextureSet2;
--- /dev/null
+#ifndef __DALI_DEMO_UTILITY_H__
+#define __DALI_DEMO_UTILITY_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/dali.h>
+#include <dali/devel-api/images/atlas.h>
+#include <dali/devel-api/rendering/texture.h>
+#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+
+namespace DemoHelper
+{
+
+Dali::PixelData LoadPixelData( const char* imagePath,
+ Dali::ImageDimensions size,
+ Dali::FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode )
+{
+ Dali::BitmapLoader loader = Dali::BitmapLoader::New( imagePath, size, fittingMode, samplingMode );
+ loader.Load();
+ return loader.GetPixelData();
+}
+
+
+Dali::Atlas LoadImage( const char* imagePath,
+ Dali::ImageDimensions size = Dali::ImageDimensions(),
+ Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT,
+ Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT )
+{
+ Dali::PixelData pixelData = LoadPixelData(imagePath, size, fittingMode, samplingMode);
+ Dali::Atlas image =Dali:: Atlas::New( pixelData.GetWidth(), pixelData.GetHeight(), pixelData.GetPixelFormat() );
+ image.Upload( pixelData, 0u, 0u );
+
+ return image;
+}
+
+Dali::Texture LoadTexture( const char* imagePath,
+ Dali::ImageDimensions size = Dali::ImageDimensions(),
+ Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT,
+ Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT )
+{
+ Dali::PixelData pixelData = LoadPixelData(imagePath, size, fittingMode, samplingMode);
+ Dali::Texture texture = Dali::Texture::New( Dali::TextureType::TEXTURE_2D,
+ pixelData.GetPixelFormat(),
+ pixelData.GetWidth(),
+ pixelData.GetHeight() );
+ texture.Upload( pixelData );
+
+ return texture;
+}
+
+/**
+ * @brief Load an bitmap resource.
+ *
+ * If it is required to scaled-down to no more than the stage dimensions,
+ * 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 BOX_THEN_LINEAR to sample the image with
+ * maximum quality.
+ */
+
+Dali::Atlas LoadStageFillingImage( const char* imagePath )
+{
+ Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
+ return LoadImage( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
+}
+
+Dali::Texture LoadStageFillingTexture( const char* imagePath )
+{
+ Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
+ return LoadTexture( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
+}
+
+} // DemoHelper
+
+#endif // __DALI_DEMO_HELPER_VIEW_H__
toolBarLayer.RaiseToTop();
// Tool bar
- Dali::Image image = Dali::ResourceImage::New( toolbarImagePath );
toolBar = Dali::Toolkit::ToolBar::New();
toolBar.SetName( "TOOLBAR" );
- toolBar.SetBackgroundImage( image );
+ Dali::Property::Map background;
+ background["url"] = toolbarImagePath;
+ toolBar.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, background );
toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
toolBar.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS );
// Set background image, loading it at screen resolution:
if ( !backgroundImagePath.empty() )
{
- 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 );
- view.SetBackgroundImage( backgroundImage );
+ Dali::Property::Map map;
+ map["rendererType"] = "image";
+ map["url"] = backgroundImagePath;
+ map["desiredWidth"] = stage.GetSize().x;
+ map["desiredHeight"] = stage.GetSize().y;
+ map["fittingMode"] = "SCALE_TO_FILL";
+ map["samplingMode"] = "BOX_THEN_LINEAR";
+ map["synchronousLoading"] = true;
+ view.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
}
// FIXME