I have CDib Class here which loads DIBs (device independant bitmaps) It has a member funtion ::Load(const char *pszFilename) which takes a filename and loads the DIB from it.
I'm trying to modify the class to include a function ::LoadIndirect(const char *pszData) to load bitmaps based on character data sent.
The load function uses the following expression:
cf.Read( &BFH, sizeof( BITMAPFILEHEADER );
Where cf is of type CFile and BFH is BITMAPFILEHEADER.
How is it doing this, or shall I say, how can I do this with a chunk of data instead of a file?
It opens the file, and reads data in to the address of BFH. Alright. So I tried:
But I get the following error: DIB.cpp(188) : error C2440: '=' : cannot convert from 'unsigned char *' to 'struct tagBITMAPFILEHEADER *'Code:BITMAPFILEHEADER BFH; unsigned char *pBFHTemp = new unsigned char[sizeof(BITMAPFILEHEADER)]; for (int i = 0; i < sizeof(BITMAPFILEHEADER); i++) { pBFHTemp += pszData[i]; } &BFH = pBFHTemp; delete[] pBFHTemp;
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
All I want to do is take data, and place it at the address of BFH, how can I do this?



LinkBack URL
About LinkBacks


