   problem with copy data
  Hi All,i have problem with copy datai have backbuffer format: D3DFMT_R5G6B5: 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue. following is my code:LPDIRECT3DSURFACE9 pRenderTarget = NULL;m_pDevice->GetRenderTarget(0, &pRenderTarget);m_pDevice->GetRenderTargetData(pRenderTarget, pTemp);// Lock surfaceD3DLOCKED_RECT lockedRect;pTemp->LockRect(&lockedRect, NULL, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK)    D3DSURFACE_DESC textureDesc;    pTemp->GetDesc(&textureDesc);    // reverse the buffer    int iPitch = lockedRect.Pitch;    BYTE *pData = (BYTE*)lockedRect.pBits + (iPitch * (textureDesc.Height - 1));    BYTE *pDestData = m_pMyBuffer; (init with : width * height * 4)for (int i = 0; i < textureDesc.Height; i ++)    {int iDestIndex = 0;int iSourceIndex = 0;for (int j = 0;j < textureDesc.Width;j++){int iPixel = pData[iSourceIndex++];int iHi = pData[iSourceIndex++];iHi = iHi << 8;iPixel = iPixel | iHi;int iBlue = iPixel & 0x1F; // 5 bit for blueint iGreen = (iPixel >> 5) & 0x3F; // 6 bit for greenint iRed = (iPixel >> 11) & 0x1F; / 5 biet for redpDestData [iDestIndex++] = iBlue;pDestData [iDestIndex++] = iGreen;pDestData [iDestIndex++] = iRed;pDestData [iDestIndex++] = 0xFF;   } pDestData += iPitch * 3 / 2;}pData -= iPitch;    }when i display this buffer(m_pMyBuffer) then incorrect.my code is not work ok, but i can not see anything error, pls anybody help me???   
  Are you using the debug runtimes with the debug output set to maximum? Is there any debug output? Do you check that all of the D3D calls succeed? Did you create the device with the D3DCREATE_LOCKABLE_BACKBUFFER (or whatever it is) flag?What do you mean it "doesn't look right"? Any chance of a screenshot?I'm not sure what this is supposed to do, but it doesn't look right:pDestData += iPitch * 3 / 2;   ;  Since you created your destdata with width*height*4 you can use width * 4 safely. You should not use the sources' pitch for your destination data since they are in no way related.Change the line:pDestData += iPitch * 3 / 2;to:pDestData += width * 4;or:pDestData += textureDesc.Width * 4;depending on how you want the target data arranged.   ;  thanks very much   