This is how I do it:
Code:
  D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8:
   begin
    pb := pbyte(Cardinal(FRect.pBits) + y * Cardinal(FRect.pitch) + x * 4);
    pb^ := b;
    inc(pb);
    pb^ := g;
    inc(pb);
    pb^ := r;
    inc(pb);
    pb^ := a;
   end;
x and y is the x and the y in the texture. FRect is TD3DLockedRect.