delphi – 为什么在使用TStream类时会出现“抽象错误”?
发布时间:2020-12-15 09:18:27 所属栏目:大数据 来源:网络整理
导读:当我尝试运行以下简单的代码序列时,我收到了Abstract Error错误消息: type TForm1 = class(TForm) Image1: TImage; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;pro
当我尝试运行以下简单的代码序列时,我收到了Abstract Error错误消息:
type TForm1 = class(TForm) Image1: TImage; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; procedure TForm1.Button1Click(Sender: TObject); var ImageStream: TStream; begin ImageStream := TStream.Create; Image1.Picture.Bitmap.SaveToStream(ImageStream); ... end; 我需要提取TBitmap的流以供以后处理……我做错了什么? 解决方法
TStream class是一个抽象类,是所有流的基础.
您可能希望使用TMemoryStream或TFileStream,顾名思义,它将流内容存储在内存或系统文件中. procedure TForm1.Button1Click(Sender: TObject); var ImageStream: TMemoryStream; begin ImageStream := TMemoryStream.Create; try Image1.Picture.Bitmap.SaveToStream(ImageStream); ... finally ImageStream.Free; end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |