Advertisement

Memory buffer to Surface?

Started by November 19, 2000 10:23 AM
9 comments, last by vbisme 24 years, 2 months ago
Hi,

You can actually change a surface''s characteristics by giving it a new SURFACEDESC.

What you do is :
1. fill in all nessescary field in the surfacedesc, set the lpSurface member to the address of
your memorybuffer.

coede ex)

===================================================

// create a 320*200 16bpp buffer
unsigned short *buffer = new unsigned short[64000];

// load a picture into the buffer
LoadMyFileFormatPicture("hoppsan.jpg",buffer);

// this assumes you have a temporary surfaca already set-up.
// now create a new surfaceDesc
// and make it use your buffer as surface data area

DDSURFACEDESC2 surfaceDesc;
memset(surfaceDesc)
surfaceDesc.dwSize = sizeof(surfaceDesc);
surfaceDesc.dwWidth = WIDTH;
surfaceDesc.dwHeight= HEIGHT;
surfaceDesc.lpSurface = myBuffer;


// then, you activate you new surfacedesc by calling
// the method :

myDD7TempSurface->SetSurfaceDesc(&surfaceDesc,0);

===================================================

Now you can blit your buffer back and forth onto other Direct Draw surfaces by just using Blt.

Hope this help, otherwise respond and I will try to explain further.

/Tooon



This topic is closed to new replies.

Advertisement