Graphic Delphi

Title: How to convert a Bitmap to an Icon
function CreateIconFromBitmap(Bitmap: TBitmap; TransparentColor: TColor): TIcon;
begin
with TImageList.CreateSize(Bitmap.Width, Bitmap.Height) do
begin
try
AllocBy := 1;
AddMasked(Bitmap, TransparentColor);
Result := TIcon.Create;
try
GetIcon(0, Result);
except
Result.Free;
raise;
end;
finally
Free;
end;
end;
end;