How can I load an image from BYTE* array using CImage ? My workaround until now is to simply create a temporary file, but this operation is very expensive sometimes ... There are probably libraries for that, but I do not want to link to other libraries, all I need is to get image size and effectively display to screen, and CImage is all I need for that ...
p->pbData is a BYTE* array and p->dwDataLen is a DWORD that hold the array size
My code :
ATL::CAtlTemporaryFile TempFile;
TempFile.Create(NULL, GENERIC_WRITE | GENERIC_READ);
TempFile.Write(p->pbData, p->dwDataLen);
TempFile.HandsOff();
ATL::CImage m_image;
m_image.Load(TempFile.TempFileName());
TempFile.Close();
int h = m_image.GetHeight();
int w = m_image.GetWidth();
// rest of code here
m_image.Destroy();
m_image.ReleaseGDIPlus();`