ImageEn, unit ieMView

TImageEnMView.OnImageDraw2

TImageEnMView.OnImageDraw2

Declaration

property OnImageDraw2: TIEImageDraw2Event;

Description

Occurs whenever an image is painted.

Note:
◼OnImageDraw and OnImageDraw2 are identical, except that OnImageDraw2 includes a ThumbRect parameter to return the rectangle of the thumbnail image (which may be different for each thumbnail depending on the image aspect ratio)
◼You can use ThumbWidth and ThumbHeight to get the area of the thumbnail box

Demo

Demo  Demos\Multi\CustomThumbs2\CustomThumbs2.dpr

Examples

// Display the image index and sizes on bottom of the thumbnail
// Ensure you have set the BottomGap property
procedure TForm1.ImageEnMView1ImageDraw2(Sender: TObject; Index: Integer; Left, Top: Integer; Canvas: TCanvas);
begin
  Canvas.Font.Height := 15;
  Canvas.Font.Color := clWhite;
  Canvas.TextOut(Left, Top + ImageEnMView1.ThumbHeight - ImageEnMView1.BottomGap + 2, IntToStr(Index));
  Canvas.TextOut(Left, Top, IntToStr(ImageEnMView1.ImageWidth[Index]) + 'x' + IntToStr(ImageEnMView1.ImageHeight[Index]));
end;

// Output the image size in the bottom left of the thumbnail (with a semi transparent background)
procedure TMainForm.ImageEnMView1ImageDraw2(Sender: TObject; Index, Left, Top: Integer; ImageRect: TRect; Canvas: TCanvas);
const
  Right_Margin  = 2;
  Bottom_Margin = 2;
  Text_Margin   = 2;
var
  x1, y1, x2, y2: Integer;
  iec: TIECanvas;
  ss: string;
  sz: TSize;
begin
  ss := Format( '%d x %d', [ ImageEnMView1.ImageWidth[Index],  ImageEnMView1.ImageHeight[Index] ]);

  // Create our TIECanvas from the regular TCanvas
  iec := TIECanvas.Create( Canvas );
  try
    iec.Font.Size  := 8;
    iec.Font.Color := clWhite;
    iec.Font.Style := [fsBold];

    sz := iec.TextExtent( ss );

    x1 := ImageRect.Right - sz.cx - Right_Margin;
    y1 := ImageRect.Bottom - sz.cy - Bottom_Margin;
    x2 := ImageRect.Right - Right_Margin;
    y2 := ImageRect.Bottom - Bottom_Margin;

    iec.Brush.Color := clBlack;
    iec.Brush.Style := bsSolid;
    iec.Brush.Transparency := 196;
    iec.Pen.Style := psClear;
    iec.Rectangle( x1 - Text_Margin, y1, x2 + Text_Margin, y2 );
    iec.DrawText( ss, x1, y1 );
  finally
    iec.Free();
  end;
end;

See Also

◼OnImageDraw