ImageEn, unit iexBitmaps

TIEMBitmapGetVirtualEvent


Declaration

TIEMBitmapGetVirtualEvent = procedure(Sender: TObject; idx: integer; var Width, Height: Integer; Image: TIEBitmap; Params: TIOParams) of object;


Description

Used by OnGetVirtual whenever content is needed if in virtual mode. is needed when run in , OnImageLoaded and OnImageLoaded.

For each call, only one of the following is required:
 Image: When Image <> nil, you should fill Image with the frame content
 Properties: When Params <> nil, you should fill Params with the frame properties
 Dimensions: When Image and Params = nil, you should specify the Width and Height of the frame

Parameter Description
Sender Sender object
idx The frame index
Width, Height The dimensions of the frame
Image When not nil, fill Image with the frame content
Params When not nil, fill Params with the frame properties


Demo

Demo  Demos\Multi\VirtualMultiBitmap\VirtualMultiBitmap.dpr


Example

// Create a 100-frame TIFF file, where each frame shows its index
mbmp := TIEMultiBitmap.Create();
mbmp.OnGetVirtual := GetVirtualImage;
mbmp.VirtualCount := 100;
mbmp.IsVirtual    := True;
mbmp.Write( 'D:\NumberedTIFF.tiff' );
mbmp.Free;

// Event to supply each virtual frame
procedure TMainForm.GetVirtualImage(Sender: TObject; idx: integer; var Width, Height: Integer; Image: TIEBitmap; Params: TIOParams);
const
  Image_Width  = 800;
  Image_Height = 600;
var
  proc: TImageEnProc;
begin
  // Seeking bitmap?
  if Image <> nil then
  begin
    // Create our bitmap for image idx

    // Allocate size and fill with background color
    Image.Allocate( Image_Width, Image_Height, clYellow );

    // Draw text (image number)
    proc := TImageEnProc.CreateFromBitmap( Image );
    proc.TextOut( Align_Text_Horz_Center, Align_Text_Vert_Center, IntToStr( idx ), 'Arial', 128, clRed, [fsBold]);
    proc.Free;
  end
  else
  // Seek IO Parameters?
  if Params <> nil then
  begin
    // Specify the image properties of image idx
    Params.TIFF_Compression := ioTIFF_JPEG;
    Params.TIFF_JPEGQuality := 85;
  end
  else
  // Image Dimensions
  if Params <> nil then
  begin
    // Specify the size of image idx
    Width  := Image_Width;
    Height := Image_Height;
  end;
end;


// Displaying a virtual multi-bitmap in a TImageEnMView
TIEMultiBitmap( ImageEnMView1.IEMBitmap ).OnGetVirtual := GetVirtualImage;
TIEMultiBitmap( ImageEnMView1.IEMBitmap ).VirtualCount := 10000;
TIEMultiBitmap( ImageEnMView1.IEMBitmap ).IsVirtual    := True;


See Also

 IsVirtual
 VirtualCount
 OnGetVirtual