Sign in to follow this  
ArgusMaker

surface data

Recommended Posts

ArgusMaker    102
It's me, again :D
May someone give me some explanations about how surfaces hold color data?
I thought that sing LockRect you get a pointer (pBits) to an array of DWORDS of size width*height*sizeof(DWORD).
So i wrote this function, to get the color value of one pixel in a surface
[code]DWORD SurfaceGetPixelColor(LPDIRECT3DSURFACE9 surface, int x, int y)
{
RECT rectangle;

rectangle.left = x;
rectangle.top = y;
rectangle.right = x+1;
rectangle.bottom = y+1;
surface->LockRect(&getpix_desc,&rectangle,D3DLOCK_READONLY);
DWORD color;
memcpy(&color,getpix_desc.pBits,sizeof(DWORD));
surface->surface->UnlockRect();
return(color);
}[/code]
But i get an error for memcpy

Share this post


Link to post
Share on other sites
pekarn    173
You need to make sure that the data in your surface is 32-bit. If it has any other format it will have a different size.

Share this post


Link to post
Share on other sites
pekarn    173
Could you specify what error you're getting from memcpy. Also have you checked to make sure the lock is successful?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this