Original Post
Hi All, i have problem with copy data i 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 surface D3DLOCKED_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 blue int iGreen = (iPixel >> 5) & 0x3F; // 6 bit for green int iRed = (iPixel >> 11) & 0x1F; / 5 biet for red pDestData [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???