Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to use RenderWindow.SetIcon in sfml.NET  (Read 9926 times)

0 Members and 1 Guest are viewing this topic.

Chikin_Bukit

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to use RenderWindow.SetIcon in sfml.NET
« 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.

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: How to use RenderWindow.SetIcon in sfml.NET
« Reply #1 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);
 

Chikin_Bukit

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to use RenderWindow.SetIcon in sfml.NET
« Reply #2 on: May 02, 2021, 05:48:51 pm »
Thanks for the reply, it worked!
« Last Edit: May 02, 2021, 10:15:00 pm by Chikin_Bukit »