Skip to main content
GameDev.net gamedev.net
🔒 Locked

Loading a bitmap

Started by WymsicalWyvern Sep 11, 2000 at 12:41 AM 0 replies 500+ views
Original Post
WymsicalWyvern
WymsicalWyvern
until now, i never needed to manage my surfaces at the pixel level, i used to just call LoadImage() or something and play around with the DCs just like in DDLoadBitmap(), but now the time comes, and i have to plot pixel by pixel to the surface. Unfortunately, i can''t seem to make any sense out of the surface format, so i''m going to make my question a broad one:

Assume i have an array:
char p[50][50][3]
which holds a 50x50 bitmap with a 24bit depth. and now assume i have a DDraw surface which is 50x50 and is 24bits deep. I''ve locked it and eveyrthing, the surface data is stored in DDSURFACEDESC2 ddsd, and i have typecast pointer tothe surfacedata: char* = (char*)ddsd.lpSurface. How would i copy this bitmap onto the surface? I have read the document many times nad found it very vague, i saw something about the pitch must be multipleof a DWORD or something, and some otherweird stuff which just confuses me, also, the pitch in ddsd syasits 192, why is that? And one last slightly offtopic question: how do i create a surface specifiying the bit depth?

Thanks in advance

The WymsicalWyvern
Sentinel
Sentinel
You can create a surface with specified bit depth only if you add DDSD_PIXELFORMAT flag, when you create surface. You must then also supply the pixel format field in DDSURFACEDESC2.ddpfPixelFormat
If you "know" that the format of surface is what you think it is, than you can simply do that:
memcpy(ddsd.lpSurface,p,50*50*3);
But it might not be always be that simple.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.