Why am I getting “Abstract Error” when working with TStream class?

前端 未结 1 1131
庸人自扰
庸人自扰 2021-01-18 21:46

When I try to run the following simple code sequence, I\'m getting the Abstract Error error message:

type
  TForm1 = class(TForm)
    Image1: TI         


        
相关标签:
1条回答
  • 2021-01-18 22:06

    The TStream class is an abstract class, and the foundation of all the streams.

    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.

    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;
    
    0 讨论(0)
提交回复
热议问题