DWORD to surfaces

Started by
5 comments, last by GameDev.net 24 years, 4 months ago
I guess that's the only way.
But why the hell did you save the bitmap into a DWORD array anyway? Couldn't you just have used the usual GDI32 bitmap load functions???
Advertisement
I'd say use memcopy instead of plotting pixel by pixel in some huge for/while loop.
Do a Lock on the surface, memcpy, and Unlock.

------------------

-Kentamanos

-Kentamanos
Remember to memcpy line by line and increment your destination pointer by the pitch of the surface... otherwise you may run into weird problems on some video cards.

Good luck

Starfall

yeah, unless you've got different pixel formats here... in which case you should use putpixel, i think it does the conversions.. why don't you just load it into a win bitmap and use BitBlt?
I've saved a bitmap to a giant DWORD array and want to convert it to a surface. How should I approach this? By put-pixeling each pixel to the surface?
if the pixel format of your DWORD array is the same as the format of the surface you can use the SetSurfaceDesc function of the DirectDrawSurface with a DDSURFACEDESC where the lpSurface ptr is set to the start of your array and the dwFlags member is set to DDSD_LPSURFACE. The DDSurface will use the array as surface memory, but won't delete the array.
I think you can even create a Surface with a set DDSURFACEDESC.lpSurface member, to create the surface you want.

So refer to the DirectDraw reference.

-> Aidan

This topic is closed to new replies.

Advertisement