//从服务器上把图片下载到本地并处理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;