Closed Willy-Kimura closed 5 years ago
Just found the Extension method ToBitmap(int size, Color color)
.
For anyone who would wish to do this - firstly, ensure you've imported the namespace FontAwesome.Sharp
:
// You can define your store image.
Image image;
// Set your preferred FontAwesome Icon.
myIconPictureBox.IconChar = IconChar.Facebook;
// Set you store-image to the applied Icon.
image = myIconPictureBox.IconChar.ToBitmap(21, color);
An even easier way is using the IconChar
enum. Here you can write a method that returns a FontAwesome Icon like this:
public Image GetFAIcon(IconChar icon, int size, Color color)
{
IconChar iconChar = icon;
return iconChar.ToBitmap(size, color);
}
And here's an example using the method:
pictureBox.Image = GetFAIcon(IconChar.Facebook, pictureBox.Height, Color.Blue)
Exactly. Using IconHelper
you can even create (WPF) images for custom fonts, e.g. Material Design. We could probably add another helper method to FormsIconHelper
. Would you make use of it?
Great add. I'd very much appreciate a helper class for such use-cases!
A WinForms example using the helper class and other associated methods can likewise assist very much.
Ok, we are going for it! :+1:
Doing some last checks before pushing the updated package. Hang tight.
Is there a way one can get the currently set FontAwesome Image/Icon? As of currently, there seems to be no way.
Seems the base Image doesn't return the applied FontAwesome Icon since it's serialization is hidden.