动态加载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;
|
请发表评论