You did not include texture.bmp but your code works here if you change it like this:
Code:
procedure DxTexture.CopyImageToTexture(pSrc :Pbyte; xWidth, yHeight, xPos, yPos :integer);
var
d3drc : D3DLOCKED_RECT;
pDest : PBYTE;
nPixel: integer;
r,g,b : BYTE;
nRow : integer;
begin
_tex.LockRect(0, d3drc, NIL, 0);
for nRow := 0 to yHeight -1 do
begin
pDest := pbyte(Cardinal(d3drc.pBits) + (nrow+ypos) * d3drc.pitch + xpos*4);
for nPixel := 0 to xWidth-1 do
begin
r := pSrc^; inc(pSrc);
g := pSrc^; inc(pSrc);
b := pSrc^; inc(pSrc);
pDest^ := r; inc(pDest);
pDest^ := g; inc(pDest);
pDest^ := b; inc(pDest);
pDest^ := 0; inc(pDest);
end;
end;
_tex.UnlockRect(0);
end;
Bookmarks