views:

58

answers:

2

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)

+2  A: 

One possibility for Squeak/Pharo would be:

HandMorph attach: (SketchMorph fromStream:
    'http://code.google.com/p/pharo/logo'
        asUrl retrieveContents contentStream).
danlei
A: 

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.

amccormack