Xojo.IO.BinaryStream

From Xojo Documentation

Class (inherits from Object)

The BinaryStream class is an input/output mechanism for reading and writing arbitrary binary data. It can be used with MemoryBlocks and FolderItems.

Properties
IsClosed fa-lock-32.png LittleEndian
Length Position
Methods
Close ReadInt8 WriteInt16
EOF ReadSingle WriteInt32
Flush ReadText WriteInt64
Handle ReadUInt16 WriteInt8
Read ReadUInt32 WriteSingle
ReadBoolean ReadUInt64 WriteText
ReadCurrency ReadUInt8 WriteUInt16
ReadDouble Write WriteUInt32
ReadInt16 WriteBoolean WriteUInt64
ReadInt32 WriteCurrency WriteUInt8
ReadInt64 WriteDouble
Enumerations
LockModes
Constructors

Xojo.IO.BinaryStream.Constructor(mb As MemoryBlock)


Shared Methods
Create FromHandle Open

Notes

The Read/Write methods raise an exception when reading or writing past the end of the stream. File IO prevents thread switching.

Sample Code

Load an image that is copied to an iOS app using a Copy Files Build Step:

Dim f As FolderItem = SpecialFolder.GetResource("MyImage.JPG")

Dim b As BinaryStream
b = BinaryStream.Open(f, BinaryStream.LockModes.Read)

Dim mb As New MemoryBlock(b.Read(b.Length))

b.Close

Dim image As iOSImage
image = Image.FromData(mb)

ImageView1.Image = image

See Also

Xojo.IO.FolderItem, Xojo.Core.MemoryBlock classes