解决Delphi 中Timage控件加载大图(bmp)方法

动态加载jpg图片

procedure TForm1.Button1Click(Sender: TObject);
var
jpg:TJPEGImage;// 要use Jpeg单元
begin
jpg:=TJPEGImage.Create;
jpg.LoadFromFile('d:\2.jpg');
image1.Picture.Bitmap.Assign(jpg);    // 因为 img 控件是基于bmp的

jpg.Free;

end;

//项目中正式通用测试

procedure TFrmBusLine.FormCreate(Sender: TObject);
var
  ThreadID: DWORD;
  dsRoads: TDataSet;
  jpg : TJPEGImage;
begin
  //InitThread(Self);
  jpg := TJPEGImage.Create;
  jpg.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'buslineback.JPG');
  BusLineList := THashedStringList.Create;
  BusRoads := THashedStringList.Create;
  BackImage := TImage.Create(nil);
  BackImage.Parent := pnlBusLine;
  //BackImage.Picture.LoadFromFile();
  BackImage.Picture.Bitmap.Assign(jpg);
  BackImage.AutoSize := True;
  BackImage.Width := pnlBusLine.Width;
  BackImage.Height := pnlBusLine.Height;  

end;

posted @ 2012-07-04 10:40  Sam.山子  阅读(5264)  评论(0编辑  收藏  举报