ImageEn, unit imageenio

TImageEnIO.SaveToText

TImageEnIO.SaveToText


Declaration

procedure SaveToText(const FileName: WideString; ImageFormat: TIOFileType = ioUnknown; TextFormat: TIETextFormat = ietfASCIIArt); overload;
procedure SaveToText(Stream: TStream; ImageFormat: TIOFileType = ioUnknown; TextFormat: TIETextFormat = ietfASCIIArt); overload;


Description

Saves the current image in the specified text format.
Parameter Description
FileName Output file name
Stream Output stream
ImageFormat Desired file format. If ioUnknown, then the current image format is used
TextFormat Output text format (See TIETextFormat)

Note: To abort while saving set Aborting to true

See Also: LoadFromText


Examples

ImageEnView1.IO.LoadFromFile('C:\input.jpg');
ImageEnView1.Proc.Resample(128, -1);
ImageEnView1.IO.SaveToText('D:\output.txt', ioUnknown, ietfASCIIArt);

// Convert an image to a base 64 string
function IEBitmapToBase64(Bitmap: TIEBitmap; SaveFormat: TIOFileType): AnsiString;
var
  io: TImageEnIO;
  ms: TMemoryStream;
begin
  ms := TMemoryStream.Create();
  io := TImageEnIO.Create( nil );
  try
    io.AttachedIEBitmap := Bitmap;
    io.SaveToText( ms, SaveFormat, ietfBase64 );
    SetString( Result , PAnsiChar( ms.Memory ), ms.Size );
  finally
    io.AttachedIEBitmap := nil;
    FreeAndNil( io );
    FreeAndNil( ms );
  end;
end;