SFML community forums

Bindings - other languages => DotNet => Topic started by: rpgmaker on March 17, 2009, 03:00:19 am

Title: Question: How to setup icon for SFML window
Post by: rpgmaker on March 17, 2009, 03:00:19 am
As the question stated, how do i do it. When ever i try to setup the icon, it always comes out wierd. Below is my code that i use

Code: [Select]

System.Drawing.Icon icon = new System.Drawing.Icon("Game.ico");
                MemoryStream ms = new MemoryStream();
                icon.Save(ms);
                byte[] data = ms.ToArray();
                Render.SetIcon((uint)icon.Width, (uint)icon.Height, data);
                icon.Dispose();
                ms.Close();
Title: Question: How to setup icon for SFML window
Post by: Laurent on March 17, 2009, 07:51:19 am
What output do you get? Do you have a screenshot?

Are you sure that Icon.Save only outputs pixels, and no header or metadata?
Title: Question: How to setup icon for SFML window
Post by: rpgmaker on March 17, 2009, 10:51:57 pm
This is what my status bar looks like
(http://img23.imageshack.us/img23/5190/statusbar.png)

This is the icon i am trying to load
(http://img23.imageshack.us/img23/2594/gameicon.png)
Title: Question: How to setup icon for SFML window
Post by: Laurent on March 17, 2009, 11:04:30 pm
What about the last question:
Quote
Are you sure that Icon.Save only outputs pixels, and no header or metadata?

I couldn't find accurate information about that in the MSDN. If you don't know, maybe you can just check if data.Length == Width * Height * 4.
Also make sure that the output format is 32 bits ARGB, and that the components are not swapped.

In other words, we have to know what icon.Save actually does :)
Title: Question: How to setup icon for SFML window
Post by: rpgmaker on March 18, 2009, 12:51:35 am
I will check that and get back. I tried the icon in sdl window and it works fine.
Title: Question: How to setup icon for SFML window
Post by: rpgmaker on March 18, 2009, 01:01:55 am
I checked it and the icon is 32 bits. Is there any other option to load the icon to the title bar?

This is a link to the icon file, if you want to check it out.

http://www.iomegatrix.net/download/Game.ico
Title: Question: How to setup icon for SFML window
Post by: Laurent on March 18, 2009, 07:42:09 am
What about that
Quote
maybe you can just check if data.Length == Width * Height * 4

and that
Quote
ARGB

?
Title: Question: How to setup icon for SFML window
Post by: rpgmaker on March 18, 2009, 01:43:59 pm
When i check the length of the btye array it is 6518. And the width * height * 4 is 4096. Basically meaning that it was not equal. The icon have Format32bppArgb according to C#, so it ARGB.
Title: Question: How to setup icon for SFML window
Post by: Laurent on March 18, 2009, 01:55:21 pm
So it seems the output includes something else in addition to the array of pixels. I still couldn't find useful information about this, so maybe you should post on a .Net forum, as the problem is no longer related to SFML.

Sorry I couldn't help you more.