Hi folks,
Was a bit bored, I thought I'd try and see if I could get the sdk to load bitmaps etc from a resource dll (saves having to distribute loads of seperate files), but have hit a bit of a snag. I can't get it to work!!
Basically, the code reads the bitmap from the resource using this bit of code...
HBITMAP hMiniBitmap = LoadBitmap(hMediaDll, MAKEINTRESOURCE(IDB_MINI1));
boolean readSuccess = false;
if (hMiniBitmap == NULL)
{
FreeLibrary(hMediaDll);
return;
}
else
{
// Get the size of the bitmap
BITMAP bitmap;
::GetObject(hMiniBitmap, sizeof(BITMAP),&bitmap);
int size = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8;
// Get the bitmap data from the resource
BYTE *lpBits = new BYTE[ size ];
::GetBitmapBits(hMiniBitmap, size, lpBits);
// Copy the bitmap datato a memory block
dbMakeMemblock(MEMBLOCKNUM, size);
for (int i=0; i<size; i++)
dbWriteMemblockByte(MEMBLOCKNUM, i, lpBits[i]);
// Cleanup
delete []lpBits;
readSuccess = true;
}
So far so good. I've debugged throug the loop, and the bitmap was loaded from the resource and transferred into the specified memory block ok.
The next step in my cunning plan was to create a bitmap from the memory block by doing something like this...
dbMakeBitmapFromMemblock(BITMAPNUM, MEMBLOCKNUM);
if (dbBitmapExist(BITMAPNUM) == 1)
{
// Do something
}
The trouble is that it doesn't seem to work. The call to dbBitmapExist returns 0 all the time. Any ideas what might be going wrong? Does the memblock expect the bitmap to be in some special format (i.e. not the default raw bitmap format)?
Thanks,
Iain