Here it is:

procedure BitmapToAGF;
var
LRect: TD3DLocked_Rect;
Res, i: Integer;
DestP: Pointer;
begin
b.PixelFormat := pf32bit; // convert bitmap format to 32-bit

a.Finalize;
Res := a.Initialize(TexWidth, TexHeight, PtCount, PtWidth, PtHeight, D3DFMT_A4R4G4B4);
if (Res <> errNone) then Exit;

Res := a.Lock(0, LRect);
if (Res <> errNone) then Exit;

for i := 0 to a.TextureHeight - 1 do
begin
DestP := Pointer(Integer(LRect.Bits) + (LRect.Pitch * i));
try
pdrawLineConv(b.Scanline[i], DestP, a.TextureWidth, D3DFMT_A8R8G8B8, D3DFMT_A4R4G4B4);
except
end;
end;

Res := a.Unlock(0);
if (Res <> errNone) then Exit;

a.TransparentColor := Color;
end;