Hi
I am trying to convert an IStream to HBITMAP using the GDI+ Bitmap class. The IStream object is being populated by using data from a web service. I am reading the data in parts and appending it to an object to be used later with the Bitmap class.
Here is the relevant part of the code
char data1[] = "";
int offset = 0;
LPTSTR pszString = NULL;
LPSTREAM lpStream = NULL;
CreateStreamOnHGlobal(NULL, TRUE, &lpStream);
StreamStringCopy ((LPSTREAM)lpStream, (LPCTSTR)"");
while(of->pread(&data1,1023,offset) > 0){
LPCTSTR tempStr = data1;
StreamStringCat ((LPSTREAM)lpStream, tempStr);
offset = offset + strlen(data1);
}
Bitmap bm(lpStream,FALSE);
bm.GetHBITMAP(Color.Black, &ret);
StreamStringCat appends the string to the LPSTREAM object so I can get a single LPSTREAM object.
The loop runs fine only the first time. When the while loop is entered again, the &data1 gives an Access violation exception.
Can someone please tell me how I should resolve this issue. Thanks.