IImageBytes interface

The COM interface through which a stream gives GDI+ direct access to the bytes of an image in memory.

When GDI+ reads an image from a stream, it asks the stream object whether it also supports IImageBytes. A stream that does lets GDI+ lock a range of bytes in place and read them, so that the image does not have to be copied out of the stream first. A stream object that offers the interface can be passed to Image or Bitmap as the stream argument. The interface ID is returned by CodecIImageBytes (ImageCodec). It mirrors the GDI+ IImageBytes interface and derives from IUnknown.

Methods

CountBytes

Syntax: obj.CountBytes( pcb )

pcb
required A UINT that receives the total number of bytes in the stream.

LockBytes

Syntax: obj.LockBytes( cb, ulOffset, ppvBytes )

cb
required The number of bytes to lock, a UINT.
ulOffset
required The offset of the first byte to lock from the start of the stream, a ULONG.
ppvBytes
required Receives the address of the first locked byte.

Locks cb bytes, starting at ulOffset, and returns the address of the locked memory. The memory must stay valid until the matching call of UnlockBytes.

UnlockBytes

Syntax: obj.UnlockBytes( pvBytes, cb, ulOffset )

pvBytes
required The address that LockBytes returned.
cb
required The number of bytes locked, a UINT.
ulOffset
required The offset that was locked, a ULONG.

Releases the range that LockBytes locked.

Example

The interface ID is what GDI+ asks a stream for. A program that implements the interface in a class compares the requested ID with this one.

Dim wanted As GDIP_UUID = CodecIImageBytes()
Debug.Print Hex$(wanted.Data1)
Dim bytes As IImageBytes
Debug.Print bytes Is Nothing
' Output:
' 25D1823
' True

See Also