Sriwantha Attanayake
Sriwantha Attanayake

Reputation: 7888

How to get IDirect3DSurface9

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

Upvotes: 0

Views: 1559

Answers (1)

miloszmaki
miloszmaki

Reputation: 1645

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.

Upvotes: 1

Related Questions