Commit e9debea00bfc580fdd45684b1714396122b8fe1b

Authored by Paul Wisbey
Committed by Gerrit Code Review
2 parents 5983f4ce 44f2524d

Merge "Stopped image-scaling examples using Deprecated SetImage( ResourceImage )…

… API" into devel/master
examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 #include <dali/dali.h> 18 #include <dali/dali.h>
19 #include <dali-toolkit/dali-toolkit.h> 19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/popup/popup.h> 20 #include <dali-toolkit/devel-api/controls/popup/popup.h>
  21 +#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
21 #include "shared/view.h" 22 #include "shared/view.h"
22 #include <iostream> 23 #include <iostream>
23 24
@@ -522,21 +523,6 @@ public: @@ -522,21 +523,6 @@ public:
522 } 523 }
523 } 524 }
524 525
525 - void OnImageLoaded( ResourceImage image )  
526 - {  
527 - DALI_ASSERT_DEBUG( image == mNextImage );  
528 - mImageView.SetImage( image );  
529 - mImageView.SetSize( Size( image.GetWidth(), image.GetHeight() ) );  
530 - mImageLoading = false;  
531 -  
532 - // We have finished loading, if a resize had occured during the load, trigger another load now.  
533 - if( mQueuedImageLoad )  
534 - {  
535 - mQueuedImageLoad = false;  
536 - LoadImage();  
537 - }  
538 - }  
539 -  
540 bool OnControlTouched( Actor actor, const TouchData& event ) 526 bool OnControlTouched( Actor actor, const TouchData& event )
541 { 527 {
542 if(event.GetPointCount() > 0) 528 if(event.GetPointCount() > 0)
@@ -687,21 +673,17 @@ private: @@ -687,21 +673,17 @@ private:
687 const char * const path = IMAGE_PATHS[ mCurrentPath ]; 673 const char * const path = IMAGE_PATHS[ mCurrentPath ];
688 Stage stage = Stage::GetCurrent(); 674 Stage stage = Stage::GetCurrent();
689 Size imageSize = stage.GetSize() * mImageStageScale; 675 Size imageSize = stage.GetSize() * mImageStageScale;
690 - const ImageDimensions imageSizeInt = ImageDimensions::FromFloatArray( &imageSize.x ); 676 + mImageView.SetSize( imageSize );
691 677
692 - ResourceImage image = ResourceImage::New( path, imageSizeInt, mFittingMode, mSamplingMode ); 678 + Property::Map map;
  679 + map[Toolkit::ImageVisual::Property::URL] = path;
  680 + map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = imageSize.x;
  681 + map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = imageSize.y;
  682 + map[Toolkit::ImageVisual::Property::FITTING_MODE] = mFittingMode;
  683 + map[Toolkit::ImageVisual::Property::SAMPLING_MODE] = mSamplingMode;
693 684
694 - // If the image was cached, the load has already occured, bypass hooking the signal.  
695 - if( image.GetLoadingState() )  
696 - {  
697 - OnImageLoaded( image );  
698 - }  
699 - else  
700 - {  
701 - image.LoadingFinishedSignal().Connect( this, &ImageScalingAndFilteringController::OnImageLoaded );  
702 - } 685 + mImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
703 686
704 - mNextImage = image;  
705 } 687 }
706 688
707 void ResizeImage() 689 void ResizeImage()
@@ -710,16 +692,7 @@ private: @@ -710,16 +692,7 @@ private:
710 Stage stage = Stage::GetCurrent(); 692 Stage stage = Stage::GetCurrent();
711 Size imageSize = stage.GetSize() * mImageStageScale; 693 Size imageSize = stage.GetSize() * mImageStageScale;
712 694
713 - // If an image is already loading, queue another load when it has finished.  
714 - // This way we get continuous updates instead of constantly re-requesting loads.  
715 - if( mImageLoading )  
716 - {  
717 - mQueuedImageLoad = true;  
718 - }  
719 - else  
720 - {  
721 - LoadImage();  
722 - } 695 + LoadImage();
723 696
724 // Border size needs to be modified to take into account the width of the frame. 697 // Border size needs to be modified to take into account the width of the frame.
725 Vector2 borderScale( ( imageSize + Vector2( BORDER_WIDTH * 2.0f, BORDER_WIDTH * 2.0f ) ) / stage.GetSize() ); 698 Vector2 borderScale( ( imageSize + Vector2( BORDER_WIDTH * 2.0f, BORDER_WIDTH * 2.0f ) ) / stage.GetSize() );
@@ -742,7 +715,6 @@ private: @@ -742,7 +715,6 @@ private:
742 Toolkit::ImageView mGrabCorner; 715 Toolkit::ImageView mGrabCorner;
743 PanGestureDetector mPanGestureDetector; 716 PanGestureDetector mPanGestureDetector;
744 Toolkit::ImageView mImageView; 717 Toolkit::ImageView mImageView;
745 - ResourceImage mNextImage; //< Currently-loading image  
746 Vector2 mImageStageScale; 718 Vector2 mImageStageScale;
747 int mCurrentPath; 719 int mCurrentPath;
748 FittingMode::Type mFittingMode; 720 FittingMode::Type mFittingMode;
examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
@@ -168,23 +168,6 @@ const char* IMAGE_PATHS[] = { @@ -168,23 +168,6 @@ const char* IMAGE_PATHS[] = {
168 const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) - 1u; 168 const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) - 1u;
169 169
170 170
171 -/**  
172 - * Creates an Image  
173 - *  
174 - * @param[in] filename The path of the image.  
175 - * @param[in] width The width of the image in pixels.  
176 - * @param[in] height The height of the image in pixels.  
177 - * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions.  
178 - */  
179 -Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode )  
180 -{  
181 -#ifdef DEBUG_PRINT_DIAGNOSTICS  
182 - fprintf( stderr, "CreateImage(%s, %u, %u, fittingMode=%u)\n", filename.c_str(), width, height, unsigned( fittingMode ) );  
183 -#endif  
184 - Image image = ResourceImage::New( filename, ImageDimensions( width, height ), fittingMode, Dali::SamplingMode::BOX_THEN_LINEAR );  
185 -  
186 - return image;  
187 -}  
188 171
189 /** 172 /**
190 * Creates an ImageView 173 * Creates an ImageView
@@ -194,15 +177,23 @@ Image CreateImage(const std::string&amp; filename, unsigned int width, unsigned int @@ -194,15 +177,23 @@ Image CreateImage(const std::string&amp; filename, unsigned int width, unsigned int
194 * @param[in] height The height of the image in pixels. 177 * @param[in] height The height of the image in pixels.
195 * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions. 178 * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions.
196 */ 179 */
197 -ImageView CreateImageView(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode ) 180 +ImageView CreateImageView(const std::string& filename, int width, int height, Dali::FittingMode::Type fittingMode )
198 { 181 {
199 - Image img = CreateImage( filename, width, height, fittingMode );  
200 - ImageView actor = ImageView::New( img );  
201 - actor.SetName( filename );  
202 - actor.SetParentOrigin(ParentOrigin::CENTER);  
203 - actor.SetAnchorPoint(AnchorPoint::CENTER);  
204 182
205 - return actor; 183 + ImageView imageView = ImageView::New();
  184 +
  185 + Property::Map map;
  186 + map[Toolkit::ImageVisual::Property::URL] = filename;
  187 + map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = width;
  188 + map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = height;
  189 + map[Toolkit::ImageVisual::Property::FITTING_MODE] = fittingMode;
  190 + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
  191 +
  192 + imageView.SetName( filename );
  193 + imageView.SetParentOrigin(ParentOrigin::CENTER);
  194 + imageView.SetAnchorPoint(AnchorPoint::CENTER);
  195 +
  196 + return imageView;
206 } 197 }
207 198
208 /** Cycle the scaling mode options. */ 199 /** Cycle the scaling mode options. */
@@ -494,13 +485,18 @@ public: @@ -494,13 +485,18 @@ public:
494 Dali::FittingMode::Type newMode = NextMode( mFittingModes[id] ); 485 Dali::FittingMode::Type newMode = NextMode( mFittingModes[id] );
495 const Vector2 imageSize = mSizes[actor.GetId()]; 486 const Vector2 imageSize = mSizes[actor.GetId()];
496 487
497 - const std::string& url = mResourceUrls[id];  
498 - Image newImage = CreateImage( url, imageSize.width + 0.5f, imageSize.height + 0.5f, newMode );  
499 ImageView imageView = ImageView::DownCast( actor ); 488 ImageView imageView = ImageView::DownCast( actor );
500 - if(imageView) 489 + if( imageView)
501 { 490 {
502 - imageView.SetImage( newImage ); 491 + Property::Map map;
  492 + map[Visual::Property::TYPE] = Visual::IMAGE;
  493 + map[ImageVisual::Property::URL] = mResourceUrls[id];
  494 + map[ImageVisual::Property::DESIRED_WIDTH] = imageSize.width + 0.5f;
  495 + map[ImageVisual::Property::DESIRED_HEIGHT] = imageSize.height + 0.5f;
  496 + map[ImageVisual::Property::FITTING_MODE] = newMode;
  497 + imageView.SetProperty( ImageView::Property::IMAGE, map );
503 } 498 }
  499 +
504 mFittingModes[id] = newMode; 500 mFittingModes[id] = newMode;
505 } 501 }
506 } 502 }
@@ -542,8 +538,16 @@ public: @@ -542,8 +538,16 @@ public:
542 538
543 const Vector2 imageSize = mSizes[ id ]; 539 const Vector2 imageSize = mSizes[ id ];
544 Dali::FittingMode::Type newMode = NextMode( mFittingModes[ id ] ); 540 Dali::FittingMode::Type newMode = NextMode( mFittingModes[ id ] );
545 - Image newImage = CreateImage( mResourceUrls[ id ], imageSize.width, imageSize.height, newMode );  
546 - gridImageView.SetImage( newImage ); 541 +
  542 + Property::Map map;
  543 + map[Visual::Property::TYPE] = Visual::IMAGE;
  544 + map[ImageVisual::Property::URL] = mResourceUrls[id];
  545 + map[ImageVisual::Property::DESIRED_WIDTH] = imageSize.width;
  546 + map[ImageVisual::Property::DESIRED_HEIGHT] = imageSize.height;
  547 + map[ImageVisual::Property::FITTING_MODE] = newMode;
  548 + gridImageView.SetProperty( ImageView::Property::IMAGE, map );
  549 +
  550 +
547 551
548 mFittingModes[ id ] = newMode; 552 mFittingModes[ id ] = newMode;
549 553