Programmer Reference : Common Graphics : Using pixmaps : Reading bitmaps from files
Reading bitmaps from files
Bitmaps can be read from files by sending the readBitmapFile:widthReturn:heightReturn:bitmapReturn:xHotReturn:yHotReturn: message to any CgDrawable. Parameters passed to the method include the file name and ReturnParameter objects for the width, height, the actual bitmap, and the x and y hot spot location. The value of any ReturnParameter object can be accessed by sending it the value message.
| error wReturn hReturn bReturn xReturn yReturn bitmap |
error := CgWindow default
readBitmapFile: 'brick'
widthReturn: (wReturn := ReturnParameter new)
heightReturn: (hReturn := ReturnParameter new)
bitmapReturn: (bReturn := ReturnParameter new)
xHotReturn: (xReturn := ReturnParameter new)
yHotReturn: (yReturn := ReturnParameter new).
error = 0
ifTrue: [
Transcript cr; show: 'File read successful. ',
'Bitmap width: ', wReturn value printString,
', height: ', hReturn value printString,
', hotspot: ', (xReturn value @ yReturn value) printString.
bitmap := bReturn value.
bitmap freePixmap]
ifFalse: [Transcript nextPutAll: 'File read error: ',
error printString; cr].
Last modified date: 01/29/2015