 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Stefano Mancini Guest
|
Posted: Wed Nov 23, 2005 7:11 pm Post subject: CreateBitmap error |
|
|
Hi,
I've a problem using the following code:
HBITMAP hBmp = CreateBitmap (
imageData.getWidth(), // bitmap width, in pixels
imageData.getHeight(), // bitmap height, in pixels
1, // number of color planes used by device
imageData.getFormat(), // number of bits required to identify a
color
imageData.getBytes() // return a pointer to the array
containing color data
);
if (hBmp == NULL)
throw Exception("CreateBitmap error! code=" +
AnsiString(GetLastError()));
Picture->Bitmap->Handle = hBmp; //Show the bitmap
imageData is a custom object that handles the array of bytes and some
other information about the image.
After some executions of the code CreateBitmap fails.
I've found that the problem is in the method used by imageData to
allocate the memory for the image byte array, if I use "malloc or new"
the error appears but if i user GlobalAlloc and GlobalLock the program
works fine.
I've verified that the memory is always allocated/deallocated correctly
and that the bytes always rappresent a correct bitmap.
Any idea about this behaviour ?
Thanks
Stefano |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|