Status SaveStatus = bit2.Save(pStream, &pngClsid, &encoderParameters);
if(SaveStatus != Ok)
{
// this shoud free global memory used by the stream
// according to MSDN
pStream->Release();
AfxMessageBox(_T("Failed to save to stream!"));
return -1;
}
// get the size of the stream
ULARGE_INTEGER ulnSize;
LARGE_INTEGER lnOffset;
lnOffset.QuadPart = 0;
if(pStream->Seek(lnOffset, STREAM_SEEK_END, &ulnSize) != S_OK)
{
pStream->Release();
AfxMessageBox(_T("Failed to get the size of the stream!"));
return -1;
}
// now move the pointer to the begining of the file
if(pStream->Seek(lnOffset, STREAM_SEEK_SET, NULL) != S_OK)
{
pStream->Release();
AfxMessageBox(_T("Failed to smove the file pointer to the beginning of the stream!"));
return -1;
}
// I am going to save it to the file just so we can load the jpg to a gfx program
CFile fFile;