title: DirectX set color of single pixel
body: <p>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</p>
  
  <pre><code>unsigned int readPixel(LPDIRECT3DTEXTURE9 pTexture, UINT x, UINT y)
  {
      D3DLOCKED_RECT rect;
      ZeroMemory(&amp;rect, sizeof(D3DLOCKED_RECT));
      pTexture-&gt;LockRect(0, &amp;rect, NULL, D3DLOCK_READONLY);
      unsigned char *bits = (unsigned char *)rect.pBits;
      unsigned int pixel = (unsigned int)&amp;bits[rect.Pitch * y + 4 * x];
      pTexture-&gt;UnlockRect(0);
      return pixel;
  }
  </code></pre>
  
  <p>So my questions are:  </p>
  
  <pre><code>- How to write the pixels back to the texture?  
  - How to get the ARGB values from this unsigned int? 
  </code></pre>
  
  <p>((BYTE)x >> 8/16/24) didnt work for me (the returned value from the function was 688)</p>