Simple function to convert an Icon to a Bitmap.

procedure IconToBitmapEx(Icon: TIcon; var Bitmap: TBitmap;

  Size: Integer = 16);


  (* Simple function to convert an icon into a

    bitmap and specify the end size *)

  Assert(Assigned(Icon), 'No Icon specified!');

  if not Assigned(Bitmap) then

    Bitmap := TBitmap.Create;

  Bitmap.width := Icon.Width;

  Bitmap.height := Icon.Height;

  Bitmap.Canvas.Draw(0, 0, Icon);

  if Size <> Bitmap.Width then

    Bitmap.canvas.StretchDraw(Rect(0, 0, Size, Size), Bitmap);

  Bitmap.width := Size;

  Bitmap.height := Size;



Share this article!

Follow us!

Find more helpful articles: