本文介绍了为什么我会收到“抽象错误”消息?使用TStream类时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试运行以下简单代码序列时,我收到 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 ?
推荐答案
是抽象类,并且是所有流的基础。
The TStream class is an abstract class, and the foundation of all the streams.
使用专门的流对象来读取,写入或复制存储在特定介质中的信息。
Use specialized stream objects to read from, write to, or copy information stored in a particular medium.
您可能要使用或,顾名思义,将流内容存储在内存或系统文件中。
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类时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!