Page 1 of 1

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

PostPosted: Apr 2, 2002 @ 2:26am
by capesdev
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

PostPosted: Apr 2, 2002 @ 9:27am
by Johan

PostPosted: Apr 2, 2002 @ 4:08pm
by capesdev
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

PostPosted: Apr 2, 2002 @ 4:13pm
by Johan
Ok! :)

I'll correct it this weekend.

/Johan