title: create texture from memory directx
body: <p>I have a pointer to loacation in memory which contains my pixel information.
  I want to display this on screen using textures or any other form.Is it possible to create texture from memory in directx 9?
  Thanks</p>
  
  <p>Here is the code sample</p>
  
  <pre><code>D3DLOCKED_RECT r;
  HRESULT hr;
  DWORD c0=D3DCOLOR_ARGB(255,0,0,0), c1=D3DCOLOR_ARGB(255,255,255,255);
  DWORD *pData, 
  Image[64]={c0,c0,c0,c1,c0,c0,c0,c0,
     c0,c0,c0,c1,c0,c0,c0,c0,
     c0,c0,c0,c1,c0,c0,c0,c0,
         c1,c1,c1,c1,c1,c1,c1,c0,
         c0,c0,c0,c1,c0,c0,c0,c0,
     c0,c0,c0,c1,c0,c0,c0,c0,
     c0,c0,c0,c1,c0,c0,c0,c0,
     c0,c0,c0,c0,c0,c0,c0,c0};
  if (m_pDevice-&gt;CreateTexture(8,8,1,D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,   &amp;m_pPointTexture,NULL)!=D3D_OK)
      return false;
  if (m_pPointTexture-&gt;LockRect(0,&amp;r,NULL, D3DLOCK_DISCARD |D3DLOCK_NOOVERWRITE)!=D3D_OK)
      return false;
  for (int y=0; y&lt;8; y++)
  {
   pData=(DWORD*)((BYTE*)r.pBits + r.Pitch);
   for (int x=0; x&lt;8; x++)
   pData[x]=Image[y*8+x];
  }
  m_pDevice-&gt;SetTexture(0,m_pPointTexture);
  </code></pre>
  
  <p>Then in i render it by drawing rectangle primitive
  Here before setTexture if i save my texture to a BMP file by  D3DXSaveTextureToFile() and then create texture using D3DXCreateTextureFromFile(). Then i get expected output</p>