标签:procedure 下载服务器 图片下载 网上 数据流
//从服务器上把图片下载到本地并处理
procedure TForm3.ImgShow(filename:string);
var
imageStream:TMemoryStream;
jpg:TJpegImage;
imgFile:string;
Bmp1,Bmp2 :TBitmap;
w1,h1:Integer;
begin
try
//从网上将图片下传到本地,在下载时写入数据流
imgFile:=‘http://192.168.X.X/Images/‘+filename;
imagestream := TMemoryStream.Create();
jpg:=TJpegImage.Create;
idhtp1.Get(imgFile,imagestream);
imagestream.Position:=0;
jpg.LoadFromStream(imagestream);
//将图片缩放成900*450
Bmp1 :=TBitmap.Create;
Bmp2 :=TBitmap.Create;
Bmp1.Assign (jpg);
w1:=Bmp1.Width;
h1:=Bmp1.Height;
Bmp2.Width :=w1*900 div w1;
Bmp2.Height :=h1*450 div h1;
SetStretchBltMode(Bmp2.Canvas.Handle,HalfTone);
StretchBlt(Bmp2.Canvas.Handle,0,0,900,450,
Bmp1.Canvas.Handle,0,0,w1,h1,SRCCOPY);
//保存图片
jpg.Assign(bmp2);
jpg.SaveToFile (strfilePath+‘\‘+filename);
finally
jpg.Free ;
Bmp1.Free;
Bmp2.Free;
end;
end;
本文出自 “畅想天空” 博客,请务必保留此出处http://kinwar.blog.51cto.com/3723399/1617594
标签:procedure 下载服务器 图片下载 网上 数据流
原文地址:http://kinwar.blog.51cto.com/3723399/1617594