@@ -6,10 +6,9 @@ class ImageDemo final : public DemoBase,
66public:
77 /* * */
88 ImageDemo (SharedObjects& sharedObjs) :
9- DemoBase (sharedObjs, NEEDS_TRANS (" Image Formats" ))
9+ DemoBase (sharedObjs, NEEDS_TRANS (" Image Formats" )),
10+ imageFormatManager (sharedObjs.imageFormatManager)
1011 {
11- imageFormatManager.registerBasicFormats ();
12-
1312 SafePointer sp (this );
1413
1514 open.onClick = [this , sp]()
@@ -25,7 +24,7 @@ class ImageDemo final : public DemoBase,
2524
2625 fileChooser = std::make_unique<FileChooser> (TRANS (" Find an image to load." ),
2726 File::getSpecialLocation (File::userPicturesDirectory),
28- imageFormatManager. getWildcardForAllFormats ());
27+ imageFormatManager-> getWildcardForAllFormats ());
2928
3029 fileChooser->launchAsync (FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles,
3130 [sp] (const FileChooser& chooser)
@@ -64,15 +63,15 @@ class ImageDemo final : public DemoBase,
6463 */
6564 void setImage (const File& file)
6665 {
67- setImage (imageFormatManager. loadFrom (file));
66+ setImage (imageFormatManager-> loadFrom (file));
6867 }
6968
7069 /* * Changes the currently displayed with one from the given URL.
7170 If the given image fails to load, the underlying image component will be cleared.
7271 */
7372 void setImage (const URL& url)
7473 {
75- setImage (imageFormatManager. loadFrom (url));
74+ setImage (imageFormatManager-> loadFrom (url));
7675 }
7776
7877 // ==============================================================================
@@ -105,7 +104,7 @@ class ImageDemo final : public DemoBase,
105104 {
106105 for (const auto & path : files)
107106 if (const File file (path); file.existsAsFile ())
108- if (imageFormatManager. findFormatForFile (File (path)) != nullptr )
107+ if (imageFormatManager-> findFormatForFile (File (path)) != nullptr )
109108 return true ;
110109
111110 return false ;
@@ -117,7 +116,7 @@ class ImageDemo final : public DemoBase,
117116 for (const auto & path : files)
118117 {
119118 const File file (path);
120- if (file.existsAsFile () && imageFormatManager. findFormatForFile (file) != nullptr )
119+ if (file.existsAsFile () && imageFormatManager-> findFormatForFile (file) != nullptr )
121120 {
122121 setImage (file);
123122 return ;
@@ -129,7 +128,7 @@ class ImageDemo final : public DemoBase,
129128 void textDropped (const String& text, int , int ) override
130129 {
131130 if (isPossiblyBase64 (text))
132- setImage (imageFormatManager. fromBase64 (text));
131+ setImage (imageFormatManager-> fromBase64 (text));
133132 }
134133
135134 void updateWithNewTranslations () override
@@ -140,7 +139,7 @@ class ImageDemo final : public DemoBase,
140139
141140private:
142141 // ==============================================================================
143- ImageFormatManager imageFormatManager;
142+ std::shared_ptr< ImageFormatManager> imageFormatManager;
144143 HighQualityImageComponent imageComponent;
145144 TextButton open;
146145 std::unique_ptr<FileChooser> fileChooser;
0 commit comments