图片显示不出来(20分)

  • 主题发起人 主题发起人 china_bill
  • 开始时间 开始时间
C

china_bill

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.loadpicClick(Sender: TObject);
var
FS:TMemoryStream;
jpg:TJpegImage;
bmp:Tbitmap;
begin
if OpenDialog1.Execute then
begin
try
jpg:=TJpegImage.create;
bmp:=Tbitmap.create;
FS:=TMemoryStream.Create;
jpg.LoadFromFile(OpenDialog1.FileName);
bmp.Assign(jpg);
bmp.SaveToStream(FS);//将图片转换成内存流
image1.Picture.Bitmap.LoadFromStream(FS);//交图片显示出来 但失败了,显示不出来
finally
jpg.free;
bmp.free;
Fs.Free;
end;
end;
end;
 
帮你顶,我也有同样的问题
 
用image1.picture.graphic.loadfromstream(FS)試試
是不是bitmap對stream支持不好?
 
To lichdr:
image1.picture.graphic.loadfromstream(FS)也显示不出来.
F1,F1,F1......
 
F1,F1,F1......
 
if OpenDialog1.Execute then
begin
try
jpg:=TJpegImage.create;
bmp:=Tbitmap.create;
FS:=TMemoryStream.Create;
jpg.LoadFromFile(OpenDialog1.FileName);
bmp.Assign(jpg);
bmp.SaveToStream(FS);//将图片转换成内存流

//----------------------------------------------------
fs.position := 0;
//----------------------------------------------------

image1.Picture.Bitmap.LoadFromStream(FS);//交图片显示出来 但失败了,显示不出来
finally
jpg.free;
bmp.free;
Fs.Free;
end;
end;
//-----------------------------------------------------------------------------
Image1.Canvas.Draw(0,0,jpg);
 
有意思,学学再说!
 
thank SSGYK
 
接受答案了.
 

Similar threads

后退
顶部