graphicssmalltalkimagevisualworks

How do I load a picture (image) into smalltalk


How do you load a picture into smalltalk? I have found several examples of how to display an image once it is a class resource, but can't find a way to import the picture into my smalltalk environment. (I use the word picture to avoid confusion with the smalltalk image)


Solution

  • To load an image as a class resource, the following code should be executed in the workspace.

    ImageReader imageFromFile: 'picture.bmp' 
        toClass: Namespace.MyClass selector: #AccessMethod
    

    where 'picture.bmp' is the image file you want to load, NameSpace.MyClass is the class you want the file to be a resource to, AccessMethod is the name of the method called to return the picture.