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

Author Topic: Question: How to setup icon for SFML window  (Read 9208 times)

0 Members and 1 Guest are viewing this topic.

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Question: How to setup icon for SFML window
« 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();

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Question: How to setup icon for SFML window
« Reply #1 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?
Laurent Gomila - SFML developer

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Question: How to setup icon for SFML window
« Reply #2 on: March 17, 2009, 10:51:57 pm »
This is what my status bar looks like


This is the icon i am trying to load

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Question: How to setup icon for SFML window
« Reply #3 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 :)
Laurent Gomila - SFML developer

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Question: How to setup icon for SFML window
« Reply #4 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.

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Question: How to setup icon for SFML window
« Reply #5 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Question: How to setup icon for SFML window
« Reply #6 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

?
Laurent Gomila - SFML developer

rpgmaker

  • Newbie
  • *
  • Posts: 38
    • View Profile
Question: How to setup icon for SFML window
« Reply #7 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Question: How to setup icon for SFML window
« Reply #8 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.
Laurent Gomila - SFML developer