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

Author Topic: sf::Image::loadFromFile test case  (Read 6573 times)

0 Members and 1 Guest are viewing this topic.

DFPercush

  • Newbie
  • *
  • Posts: 5
    • View Profile
sf::Image::loadFromFile test case
« on: July 05, 2012, 05:28:59 am »
Hi all. I have a certain png file I'm using to test my app:

https://dl.dropbox.com/u/10392115/sfImageTest_4hjki73cd.png

, and loadFromFile simply will not load it (returns false).  My app works with another png image though. The failed image will load in windows photo gallery, IrfanView, and Firefox, so the file is valid. I'd like to get a few people to please try to load this particular image (as a sf::Image, not texture) and give me some feedback on whether it works for you. I'm pretty sure it's not an error in my code but I'll post it anyway. Using SFML-2.0-rc binaries, but downloading latest snapshot right now. My system is Windows Vista 32 bit edition, but running on a AMD Turion 64 dual core laptop (That's just the way the oem set it up :-/) with integrated graphics ATI Radeon X 1200 chipset, OpenGL 2.0 with software shader emulation. The compiler is MS Visual Studio 2010, but like I said I'm just using the RC binaries for now.   When I get back home to my other PC next week I'll post an update.

#include <SFML/Graphics.hpp>
//...
int xmain(int argc, char** argv)
{
        if (argc != 3) return 1;

        sf::Image img;
        string src, dest;
        src = argv[1];
        dest = argv[2];

        if (!img.loadFromFile(src)) return 2;
        if (!img.saveToFile(dest)) return 3;
        else return 0;
}
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image::loadFromFile test case
« Reply #1 on: July 05, 2012, 08:21:43 am »
What is the error message?
Laurent Gomila - SFML developer

DFPercush

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: sf::Image::loadFromFile test case
« Reply #2 on: July 06, 2012, 03:32:55 am »
Unless I'm missing something, there is no message. The function just returns false. Is there a getError function I should be calling or anything like that?

P.S. I verified that the maximum texture size on my hardware is 2048x2048, and the image is 1554x1200. I thought the size might be a problem but it seems within the limits.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image::loadFromFile test case
« Reply #3 on: July 06, 2012, 08:18:11 am »
Quote
Unless I'm missing something, there is no message. The function just returns false. Is there a getError function I should be calling or anything like that?
SFML messages are printed to sf::err(), which uses the same output as std::cerr by default, which is the console.
Laurent Gomila - SFML developer

Celtic Minstrel

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: sf::Image::loadFromFile test case
« Reply #4 on: July 06, 2012, 09:07:41 am »
While I realize you can get the error message (or suppress it!) by temporarily rebinding sf::err() to (for example) a std::ostream[buf?], it might be good to have a nice way of getting an error code that's simple for a program to interpret. Even just beginning all error messages with "Error xyzpqr:" would help.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image::loadFromFile test case
« Reply #5 on: July 06, 2012, 09:20:34 am »
Error handling will most likely be redesigned in the future (SFML 3).
Laurent Gomila - SFML developer

DFPercush

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: sf::Image::loadFromFile test case
« Reply #6 on: July 06, 2012, 09:21:58 am »
Thanks for the reply Laurent. :)  I missed that because my program doesn't run in a console. It's a win32 program which emulates the argc/argv setup. Upon calling freopen() on stderr, I discovered this:

Failed to load image "a.png". Reason : PNG not supported: 8-bit only

Hmm, why's it not supported? It's not a limitation of OpenGL is it? Does SFML use libpng? I'll probably try that next unless someone knows for sure it won't handle it either.



Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image::loadFromFile test case
« Reply #7 on: July 06, 2012, 09:28:09 am »
SFML uses stb_image, which doesn't support this kind of variants (progressive jpeg, 8-bit png, ...). Why do you need 8-bit png? Nobody uses them anymore. Can't you simlpy convert them to 32 bits?
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: sf::Image::loadFromFile test case
« Reply #8 on: July 06, 2012, 12:05:23 pm »
Might be caused by the program picking 8-bit-PNG just for the file size - not necessarily intentional. E.g. in Paint.net it always tries to pick the smallest possible sub-format in case you keep the format choice on "Automatic".

Silvah

  • Guest
Re: sf::Image::loadFromFile test case
« Reply #9 on: July 06, 2012, 02:43:46 pm »
Why do you need 8-bit png? Nobody uses them anymore.
Yeah, sure.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image::loadFromFile test case
« Reply #10 on: July 06, 2012, 07:15:56 pm »
Quote
Yeah, sure.
What are you trying to demonstrate with this blog article about web development?
Laurent Gomila - SFML developer

Celtic Minstrel

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: sf::Image::loadFromFile test case
« Reply #11 on: July 06, 2012, 07:40:07 pm »
I think he's just pointing out that some people do use 8-bit png.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image::loadFromFile test case
« Reply #12 on: July 06, 2012, 08:51:13 pm »
If so, this is totally irrelevant here. I really hope that he posted for a more useful reason than contradicting me for fun.
Laurent Gomila - SFML developer

DFPercush

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: sf::Image::loadFromFile test case
« Reply #13 on: July 07, 2012, 02:47:18 am »
Since you're curious, I have some digital scans of books which are in this format. If there's something that can convert them on the fly or in batches that would be fine, but there are thousands of them. Manually converting them is out of the question.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image::loadFromFile test case
« Reply #14 on: July 07, 2012, 09:21:25 am »
There are many batch image converters available on all platforms, I'm sure you can find one easily.
Laurent Gomila - SFML developer

 

anything