SFML community forums

Bindings - other languages => DotNet => Topic started by: Chikin_Bukit on May 02, 2021, 04:19:50 am

Title: How to use RenderWindow.SetIcon in sfml.NET
Post by: Chikin_Bukit on May 02, 2021, 04:19:50 am
Help, I have spent so long now scouring google to figure this out and all I can find is stuff that only works for the c++ version of sfml, so if anyone can help me figure it out, that would be great.
Title: Re: How to use RenderWindow.SetIcon in sfml.NET
Post by: kojack on May 02, 2021, 05:57:05 am
SetIcon takes a width, a height and a byte array. Looking at the C++ header (where there's comments on how it works), the data it takes is RGBA pixels.
The Image class can load image files and provides a byte array of the pixels in RGBA. So you can make an icon like this:
Image image = new Image("icon.png");
window.SetIcon(image.Size.X, image.Size.Y, image.Pixels);
 
Title: Re: How to use RenderWindow.SetIcon in sfml.NET
Post by: Chikin_Bukit on May 02, 2021, 05:48:51 pm
Thanks for the reply, it worked!