function SaveBitmaps(AWebBrowser: TWebBrowser; APath: String; AStrings: TStrings = nil): Integer;
var
AHTMLDocument2: IHTMLDocument2;
i: Integer;
AHTMLImgElement: IHTMLImgElement;
AHTMLElementRender: IHTMLElementRender;
ABitmap: TBitmap;
j: Integer;
begin
APath:=IncludeTrailingPathDelimiter(APath);
AHTMLDocument2:=AWebBrowser.Document as IHTMLDocument2;
Result:=AHTMLDocument2.images.length;
j:=0;
for i:=0 to Result-1 do
begin
AHTMLImgElement:=AHTMLDocument2.images.item(i, '') as IHTMLImgElement;
if (AHTMLImgElement.width>0) and (AHTMLImgElement.height>0) then
begin
AHTMLElementRender:=AHTMLImgElement as IHTMLElementRender;
ABitmap:=TBitmap.Create;
try
ABitmap.Width:=AHTMLImgElement.width;
ABitmap.Height:=AHTMLImgElement.height;
AHTMLElementRender.DrawToDC(ABitmap.Canvas.Handle);
ABitmap.SaveToFile(APath+Format('%.8d.bmp', [j]));
if AStrings<>nil then AStrings.Add(AHTMLImgElement.src);
Inc(j);
finally
ABitmap.Free;
end;
end;
end;
Result:=j;
end;