为什么我会收到“抽象错误”消息?使用TStream类时? [英] Why am I getting "Abstract Error" when working with TStream class?
问题描述
当我尝试运行以下简单代码序列时,我收到 Abstract Error
错误消息:
When I try to run the following simple code sequence, I'm getting the Abstract Error
error message:
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的流
供以后处理...我在做什么错了?
I need to extract the stream of an TBitmap
for later processing... What am I doing wrong ?
推荐答案
TStream类是抽象类,并且是所有流的基础。
The TStream class is an abstract class, and the foundation of all the streams.
TStream是流对象的基类类型,该流对象可以读取或写入各种存储介质,例如磁盘文件,动态内存等。
TStream is the base class type for stream objects that can read from or write to various kinds of storage media, such as disk files, dynamic memory, and so on.
使用专门的流对象来读取,写入或复制存储在特定介质中的信息。
Use specialized stream objects to read from, write to, or copy information stored in a particular medium.
您可能要使用 TMemoryStream 或 TFi leStream ,顾名思义,将流内容存储在内存或系统文件中。
You may want to use the TMemoryStream or TFileStream, which, as the name implies, store the stream content in memory or a system file.
procedure TForm1.Button1Click(Sender: TObject);
var
ImageStream: TMemoryStream;
begin
ImageStream := TMemoryStream.Create;
try
Image1.Picture.Bitmap.SaveToStream(ImageStream);
...
finally
ImageStream.Free;
end;
end;
这篇关于为什么我会收到“抽象错误”消息?使用TStream类时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!