hi all


got access violation prob when trying to fill the texture , exactly when computing the next scanline .

Code:
procedure CopyImageToTexture(pSrc : array of byte; xWidth, yHeight,var _texture :IDirect3DTexture9);
var
  d3drc : D3DLOCKED_RECT;
  pDest : PDWORD;
  nPixel: integer;
  r,g,b : BYTE;
  nRow : integer;
  
begin


  _texture.LockRect(0, d3drc, NIL, 0);

  d3drc.Pitch := d3drc.Pitch shr 2;

  for nRow := 0 to yHeight -1 do
  begin
    // set destination pointer for this row

    pDest := DWORD(d3drc.pBits) + nRow * d3drc.Pitch ; // problem here

    // copy the row

    for nPixel := 0 to xWidth-1 do
    begin
      // extract pixel data

      r := pSrc[nPixel];
      g := pSrc[nPixel+1];
      b := pSrc[nPixel+2];

      // write color word to texture

      inc(pDest^, $FF000000 or (r shl 16) or (g shl 8) or b);

    end;
  end;

  _tex.UnlockRect(0);

any solution would be great

thanks