ImageEn, unit imageenio

TImageEnIO.CreateFromBitmap

TImageEnIO.CreateFromBitmap


Declaration

constructor CreateFromBitmap(Bitmap: TIEBitmap);
constructor CreateFromBitmap(Bitmap: TBitmap);


Description

Creates a new instance of TImageEnIO, assigning the property AttachedIEBitmap or AttachedBitmap.

The following code is the same:

io := TImageEnIO.CreateFromBitmap(bmp);


And:

io := TImageEnIO.Create(nil);
io.AttachedIEBitmap := bmp;



Example

with TImageEnIO.CreateFromBitmap(myBitmap) do
begin
  DoPrintPreviewDialog( iedtDialog, '' )
  Free;
end;

// Print all frames of a multi-page TIFF
procedure PrintAllPages(const Filename: string);
Var
  bmp: TIEBitmap;
  io: TImageEnIO;
  i: Integer;
Begin
  bmp := TIEBitmap.Create();
  io  := TImageEnIO.CreateFromBitmap(bmp);
  try
    io.LoadFromFile( Filename  );

    Printer.Title := 'TIFF Pages';
    Printer.BeginDoc();
    for i := 0 to io.Params.ImageCount - 1 do
    begin
      io.Params.ImageIndex := i;
      if i > 0 then
        io.LoadFromFile( Filename );
      io.PrintImage();
    end;
    Printer.EndDoc();

  finally
    io.Free;
    bmp.Free;
  end;
End;

// If an area of the image is selected, print the selection, otherwise print the whole image
procedure TForm1.PrintImageClick(Sender: TObject);
var
  bmp: TIEBitmap;
  IO: TImageEnIO;
begin
  if ImageEnView1.Selected = False then
    ImageEnView1.IO.DoPrintPreviewDialog( iedtDialog, '' )
  else
  begin
    bmp := TIEBitmap.Create;
    IO := TImageEnIO.CreateFromBitmap( bmp );
    try
      ImageEnView1.CopySelectionToBitmap( bmp );
      IO.DoPrintPreviewDialog( iedtDialog, '' );
    finally
      IO.Free;
      bmp.Free;
    end;
  end;
end;