BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CreateBitmap error

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI)
View previous topic :: View next topic  
Author Message
Stefano Mancini
Guest





PostPosted: Wed Nov 23, 2005 2:11 pm    Post subject: CreateBitmap error Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.