How to load image from an URL
Images can be loaded directly from an URL using the code snippet. Create a sample DALI application and use below code snippet.
class ResourceImageController : public ConnectionTracker
{
public:
ResourceImageController( Application& application ) : mApplication( application )
{
mApplication.InitSignal().Connect( this, &ResourceImageController::Create );
}
void Create( Application& application )
{
ResourceImage image = ResourceImage::New( "https://www.tizen.org/sites/default/files/admins/tizen-branding-lockup-on-light.png" );
/* signal to get notified when the image has loaded */
image.LoadingFinishedSignal().Connect( this, &ResourceImageController::OnLoadFinished );
/* set image into an ImageView */
ImageView imageView = ImageView::New( image );
imageView.SetSize( 400, 200 );
imageView.SetParentOrigin( ParentOrigin::CENTER );
Stage::GetCurrent().Add( imageView );
}
void OnLoadFinished( ResourceImage image )
{
LoadingState state = image.GetLoadingState();
if( state == ResourceLoadingSucceeded )
std::cout << "Loading " << image.GetUrl() << " is succeeded" << std::endl;
else if( state == ResourceLoadingFailed )
std::cout << "Loading " << image.GetUrl() << " is failed" << std::endl;
}
private:
Application& mApplication;
};
/* start the app from main function */
Application application = Application::New( &argc, &argv );
ResourceImageController test1 (application);
application.MainLoop();