I read in another thread, that I can read a single pixel with Texture.Lock / Unlock, but I need to write the pixels back to the texture after reading them, this is my code so far
unsigned int readPixel(LPDIRECT3DTEXTURE9 pTexture, UINT x, UINT y)
{
D3DLOCKED_RECT rect;
ZeroMemory(&rect, sizeof(D3DLOCKED_RECT));
pTexture->LockRect(0, &rect, NULL, D3DLOCK_READONLY);
unsigned char *bits = (unsigned char *)rect.pBits;
unsigned int pixel = (unsigned int)&bits[rect.Pitch * y + 4 * x];
pTexture->UnlockRect(0);
return pixel;
}
So my questions are:
- How to write the pixels back to the texture?
- How to get the ARGB values from this unsigned int?
((BYTE)x >> 8/16/24) didnt work for me (the returned value from the function was 688)