//從服務器上把圖片下載到本地並處理
procedure TForm3.ImgShow(filename:string);
var
p_w_picpathStream:TMemoryStream;
jpg:TJpegImage;
imgFile:string;
Bmp1,Bmp2 :TBitmap;
w1,h1:Integer;
begin
try
//從網上將圖片下傳到本地,在下載時寫入數據流
imgFile:='http://192.168.X.X/Images/'+filename;
p_w_picpathstream := TMemoryStream.Create();
jpg:=TJpegImage.Create;
idhtp1.Get(imgFile,p_w_picpathstream);
p_w_picpathstream.Position:=0;
jpg.LoadFromStream(p_w_picpathstream);
//將圖片縮放成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;服務器