Programmer Reference : Common Graphics : Image and icon file formats : Loading images and icons from ByteArrays
Loading images and icons from ByteArrays
To load images or icons from ByteArrays, use the loadFromByteObjects:- offsetsIntoByteObjects: method.
The following code illustrates how to load a PCX format image from an array of ByteArrays. It assumes that the imageStorage method answers the array of ByteArrays created in the previous example.
| format headerSize byteArrays offsets image |
format := CgPCXFileFormat new.
headerSize := 32.
byteArrays := self imageStorage.
offsets := Array new: byteArrays size.
offsets atAllPut: headerSize.
image := format
loadFromByteObjects: byteArrays
offsetsIntoByteObjects: offsets.
image isNil
ifTrue: [self error: format currentErrorString]
Icons are loaded from ByteArrays in a similar fashion. As with loadFromFile:, the loadFromByteObjects:offsetsIntoByteObjects: method for icon file formats answers an array of CgIcons.
Last modified date: 01/29/2015