Question

I have a DirectX IDirect3DSurface9 object. How can I get the RGB values from the surface?

Was it helpful?

Solution

You should call IDirect3DSurface9::LockRect, take a look at this http://msdn.microsoft.com/en-us/library/windows/desktop/bb205896(v=vs.85).aspx . This function returns D3DLOCKED_RECT structure which contains a pointer to the surface data. If you know the format of the surface, you are able to read RGB values. For example: if the surface's format is D3DFMT_R8G8B8, each three consecutive bytes will be the red, green and blue components of the surface's pixels.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top