SFML community forums

Help => Window => Topic started by: on January 20, 2011, 07:14:28 am

Title: SetIcon problem
Post by: on January 20, 2011, 07:14:28 am
Hello,
I am new to SFML. Here is part of my code:
Code: [Select]
   // Load and apply Icon
    sf::Image icon;
    if (!image.LoadFromFile("opendarkcore.png"))
        return EXIT_FAILURE;
    window.sf::Window::SetIcon(icon.GetWidth(), icon.GetHeight(), icon.GetPixelsPtr());
    // END of setting Icon


This is what I get:

Code: [Select]
Trying to access the pixels of an empty image
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  53 (X_CreatePixmap)
  Value in failed request:  0x0
  Serial number of failed request:  55
  Current serial number in output stream:  61


What do I do wrong? :(
Title: SetIcon problem
Post by: Laurent on January 20, 2011, 07:36:49 am
Your image is empty. Are you sure that it succeeds to load?
Title: SetIcon problem
Post by: on January 20, 2011, 09:18:25 am
But shouldn't it report then EXIT_FAILURE?
Title: SetIcon problem
Post by: on January 20, 2011, 09:26:06 am
My whole source is located at:

http://gitorious.org/opendarkcore/master

the file with a problem is main.cpp line 31... I think
Title: SetIcon problem
Post by: Laurent on January 20, 2011, 09:32:33 am
Oh, so that was not a typo in your post ;)

sf::Image icon;
if (!image.LoadFromFile("opendarkcore.png"))
    return EXIT_FAILURE;
Title: SetIcon problem
Post by: on January 20, 2011, 09:46:30 am
Now it works :) such a stupid mistake I did...