Code to save jpeg in disk:
fwrite( dataPosition, 1, BufferSize, hFileImage );
That code work good.
But something is wrong when I try read data to stream:
HGLOBAL hGlobal = GlobalAlloc(GMEM_FIXED, BufferSize);
CComPtr<IStream> spStream;
HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &spStream);
ULONG pcbWritten;//don't understand what it is
spStream->Write(dataPosition, BufferSize, &pcbWritten);
pImage = new Image(spStream, FALSE);
After that it seems that stream (and pImage) is empty. I am not sure what I am doing wrong?
After you wrote to the stream, you perhaps should
IStream::Seekthe stream to its beginning so that followingImageconstructor could read the data, and not immediately reach end of stream instead.