ImageEn, unit iexBitmaps

TIEBitmap.RenderToCanvas

TIEBitmap.RenderToCanvas


Declaration


procedure RenderToCanvas(DestCanvas: TCanvas; xDst, yDst, dxDst, dyDst: integer; Filter: TResampleFilter; Gamma: double = 0; BackgroundColor: TColor = clWhite; MaintainAR: Boolean = False); overload;
procedure RenderToCanvas(DestCanvas: TCanvas; DestRect: TRect; Filter: TResampleFilter; Gamma: double = 0; BackgroundColor: TColor = clWhite; MaintainAR: Boolean = False); overload;


Description


Draws the bitmap to the DestCanvas at the rectangle specified by xDst, yDst, dxDst, dyDst.
Filter specifies the filter if the image needs to be resampled.
Gamma is the gamma correction.
BackgroundColor specifies the background color when pixels aren't opaque.
MaintainAR adjusts the passed destination values to ensure the image is not skewed (maintains its original aspect ratio).

Note: RenderToCanvas does not support the alpha channel. Use RenderToCanvasWithAlpha if the source bitmap has an alpha channel that should be respected when drawing


Example


// Col 1 of a TStringGrid displays a thumbnail drawn from a TImageEnMView
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Longint;
  Rect: TRect; State: TGridDrawState);
var
  aIEBitmap: IEBitmap;
  aCanvas: TCanvas;
  idx: Integer;
begin
  // Col 1 contains thumbnail. Row 0 is fixed header row
  if (ACol <> 1) or (ARow = 0) then
    Exit;

  idx := ARow;
  aCanvas := (Sender as TStringGrid).Canvas;

  // Clear current cell rect
  aCanvas.FillRect( Rect );

  // Get our image
  // Note: don't need to create or free the TIEBitmap
  aIEBitmap := ImageEnMView1.GetIEBitmap( idx );

  // Adjust our rect to maintain the image aspect ratio
  Rect := GetImageRectWithinArea( Rect, aIEBitmap.Width, aIEBitmap.Height );

  // Draw the image
  aIEBitmap := RenderToCanvas( aCanvas, Rect.Left, Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top, rfFastLinear, 0 );

  // Release our image
  ImageEnMView1.ReleaseBitmap( idx, False );
end;


See Also


- DrawToCanvas
- RenderToCanvasWithAlpha