Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
ImageMorph
Last updated at 10:39 am UTC on 3 October 2020
ImageMorph is a direct subclass of Morph. An ImageMorph object has an additional instance variable image where a Form is kept (accessors #form, #image, #image:).

 InspectorBrowser openOn: ImageMorph new
InspectorBrowser_openOnColon_ImageMorph_new_Squeak5dot3.png


Read a graphic file from the disk and display it with an ImageMorph object


To get an ImageMorph object from a file evaluate
 (Form fromFileNamed: 'myGraphicsFileName') asMorph openInWorld

Note on usage

1.
ImageMorphs should be favored over SketchMorphs. For the reason of this see see FAQ: Difference between SketchMorph and ImageMorph.

2.
If you send the message asMorph to Form object you get an ImageMorph object.

Example:
To have the user select part of the screen and create a morph and find out the class of that morph evaluate
 Form fromUser asMorph class
                              ImageMorph

If you actually want to see the ImageMorph object you have to evaluate the following

 Form fromUser asMorph openInWorld

How to store and image as code in a method


See example ImageCoderMorph (create an image from code stored in a method)