This site is no longer active and is available for archival purposes only. Registration and login is disabled.

CreateSurface(BYTE *buffer, DWORD size) function fails ??


CreateSurface(BYTE *buffer, DWORD size) function fails ??

Postby capesdev » Apr 2, 2002 @ 2:26am

Has anyone tried using the CreateSurface(BYTE *buffer, DWORD size) method to load a bitmap from a bitmap image file in memory ?? When I try, the call crashes without yielding an error code.

for example:

CGapiSurface *s = new CGapiSurface();
s->CreateSurface(buffer, size);

where buffer is a BYTE[] of length 'size' that was pre-filled with a .bmp file that was loaded into buffer[]. I simply used CFile::Read() to load a 'test.bmp' into memory.

Am I doing something wrong or does this method require a different image of a .bmp ?

If I put the same .bmp file in the resource fork and use the other CreateSurface() call and it works fine.

Any help is greatly appreciated.

Thanks.
Jeff
capesdev
 


Postby Johan » Apr 2, 2002 @ 9:27am

User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby capesdev » Apr 2, 2002 @ 4:08pm

Johan,
I looked into it and it's definately not a NULL pointer being passed. To test it out, I read in a bitmap file from disk into a buffer using CFile::Read(). For testing, I then wrote out that buffer's contents to a file ("test.bmp") using CFile::Write(). If I call sur1->CreateSurface("test.bmp") it works fine. If I call sur2->CreateSurface(buffer, size) it crashes out.

The whole reason I'm doing this is because I want to be able to load images stored as jpegs into GapiDraw surfaces.. the only way I know is to load the jpeg onto a CBitmap object and then ultimately call CreateSurface() with the bits stored in the CBitmap object. I figured I'd try it with a raw .bmp first and that's where I found this issue.

Thanks.
Jeff
capesdev
 


Postby Johan » Apr 2, 2002 @ 4:13pm

Ok! :)

I'll correct it this weekend.

/Johan
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

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 post attachments in this forum

cron