So I want to load Pictures from web included in emails I am using THtmViewer and TRVHTMLViewImporter.
It seems it works but after that, there is an error can not load Picture, because it wants to load picture from location "application path + http... again.procedure TF1.RichViewImportPicture(Sender: TCustomRichView;
const Location: TRVUnicodeString; Width, Height: Integer;
var Graphic: TGraphic);
var Stream: TMemoryStream;
FileStream: TFileStream;
FileName: String;
pic: TPicture;
begin
if (Pos('http://', LowerCase(Location))=1) or
(Pos('https://', LowerCase(Location))=1)
then
begin
Stream := TMemoryStream.Create;
try
// 1. downloading
IdHTTP1.Get(Location, Stream);
// 2. creating temporal file
FileName := GetTempFileName(ExtractFileExt(Location));
FileStream := TFileStream.Create(FileName, fmCreate);
try
FileStream.CopyFrom(Stream, 0);
finally
FileStream.Free;
end;
// 3. reading and deleting temporal file
pic := TPicture.Create;
try
pic.LoadFromFile(FileName);
Graphic := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));
Graphic.Assign(pic.Graphic);
finally
pic.Free;
DeleteFile(FileName);
end;
except
end;
Stream.Free;
end;
Graphic.Free;
Graphic := nil;
end;
Do I not correctly assign graphic/picture..?