Embracing IStream as just a stream of bytes

IStream is nothing more than just a stream of bytes. Though it's usually related to other interfaces in OLE such as IStorage, it will be fair enough to treat IStream as a standalone medium. Let's see. Suppose there is a function that takes an IStream pointer as a parameter: void readInImage(IStream *). This generally means the expected byte-content of the data (in this case an image) may come from anywhere, only it should be interfaced through IStream. Now suppose your byte-content is in the following form: extern char *imgBytes.
So how to put that char* into IStream? Here we go:

For a reverse operation, i.e. writing into IStream, no need to use those GlobalAlloc/GlobalLock functions. Suppose we have the following function writeOutImage(IStream *). In the following illustration, writeOutImage puts its byte-content into IStream: