thnx
yes this is a converting from c++ code
the original code looks like this
Code:
bool CopyImageToTexture(UCHAR *pSrc, int xWidth, int yHeight, LPDIRECT3DTEXTURE8 pTex, int xPos, int yPos)
{
D3DLOCKED_RECT d3drc;
UCHAR r, g, b;
UINT *pDest;
int nRow, nPixel;
// lock the texture
if (FAILED(pTex->LockRect(0, &d3drc, NULL, 0)))
return false;
// adjust pitch from bytes to UINTs
d3drc.Pitch >>= 2;
// copy the image
for (nRow = 0; nRow < yHeight; nRow++)
{
// set destination pointer for this row
pDest = (UINT*)d3drc.pBits + (nRow + yPos) * d3drc.Pitch + xPos;
// copy the row
for (nPixel = 0; nPixel < xWidth; nPixel++)
{
// extract pixel data
r = *pSrc++;
g = *pSrc++;
b = *pSrc++;
// write color word to texture
(*pDest++) = 0xFF000000 | (r << 16) | (g << 8) | b;
}
}
// unlock texture
pTex->UnlockRect(0);
// return success
return true;
}
i don't know whats the best replacment for UCHAR *pSrc , i used array of byte
Bookmarks