你如何加载图片到Smalltalk的?我已经找到了如何当它是一类资源显示图像的几个例子,但无法找到一个方法来导入的图片到我的Smalltalk的环境。 (我用的字图象,以避免与Smalltalk的图像混乱)
要加载的图像作为一类的资源,下面的代码应在工作区来执行。
ImageReader imageFromFile: 'picture.bmp'
toClass: Namespace.MyClass selector: #AccessMethod
其中“PICTURE.BMP”是要加载的图像文件,NameSpace.MyClass是你想要的文件是一个资源类,AccessMethod被称为返回图片的方法的名称。
佳乐一种可能性是:
HandMorph attach: (SketchMorph fromStream:
'https://squeak.org/img/features/morphic.png'
asUrl retrieveContents contentStream).
(这用来为菲罗工作也一样,但似乎已被删除。)
这菲罗7.0为我工作:
ImageReadWriter formFromStream: './assets/player.png' asFileReference binaryReadStream
此后,它可以与asMorph
转化。
(ZnEasy getPng: 'http://pharo.org/web/files/pharo.png')
asMorph openInWindow