alw:TMemorystream; abc:file of byte; xx:byte; i:integer; myjpg:Timage; begin myjpg:=Timage.Create(Form1); alw:=TMemorystream.Create; i:=1; opendialog1.Execute; Assignfile(abc,opendialog1.Files[0]); reset(abc); while not eof(abc) do begin read(abc,xx); alw.Seek(i-1,soFromBeginning); alw.Write(xx,1); seek(abc,i); i:=i+1; end; alw.Seek(0,soFromEnd); image1.Picture.Bitmap.LoadFromStream(alw); //如果图片不是bmp,是其它类型的话,是不是用 image1.Picture.Graphic.LoadFromFile(alw);??这是我的代码,乱乱的.我一直都不知道memorystream.seek怎么用.
TImage 的 LoadFromStream
TMemoryStream能不能一个字节一个字节的累积数据,完了之后再用Timage.loadfromstream
abc:file of byte;
xx:byte;
i:integer;
myjpg:Timage;
begin
myjpg:=Timage.Create(Form1);
alw:=TMemorystream.Create;
i:=1;
opendialog1.Execute;
Assignfile(abc,opendialog1.Files[0]);
reset(abc);
while not eof(abc) do begin
read(abc,xx);
alw.Seek(i-1,soFromBeginning);
alw.Write(xx,1);
seek(abc,i);
i:=i+1;
end;
alw.Seek(0,soFromEnd);
image1.Picture.Bitmap.LoadFromStream(alw);
//如果图片不是bmp,是其它类型的话,是不是用
image1.Picture.Graphic.LoadFromFile(alw);??这是我的代码,乱乱的.我一直都不知道memorystream.seek怎么用.
alw.LoadFromFile(opendialog1.FileName);