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

Author Topic: Question regarding image loading.  (Read 4235 times)

0 Members and 1 Guest are viewing this topic.

Lamonte

  • Newbie
  • *
  • Posts: 46
    • View Profile
Question regarding image loading.
« on: July 07, 2014, 06:26:43 pm »
Yesterday I was messing around and tried downloading an image from the internet: http://wfiles.brothersoft.com/c/cat-photograph_195926-1280x720.jpg this image to be exact.  The program crashed repeatedly saying it couldn't load the image, so I thought it was to do w/ my bindings (went sort of nuts w/ recompiling etc... lol) and then I opened the image in paint and resaved it to something else and it loaded properly?

Why exactly was the script crashing?  It was a basic:
Image bg = new Image("bg.jpg");

W/ bare minimum window creation:

RenderWindow window = new RenderWindow(new VideoMode(windowSize.X, windowSize.Y), "Window", Styles.Titlebar | Styles.Close);

window.Closed += (object s, EventArgs e) => {
        RenderWindow w = (RenderWindow) s;
        w.Close();
};

Image bg = new Image("bg.jpg");

while(window.IsOpen) {
        window.DispatchEvents();
        window.Clear(Color.Magenta);
        window.Draw(bg);
        window.Display();
}

Which was weird to me.  Note was using the latest source bindings, compiled w/ VS2012 + the CSFML files from here http://nightlybuilds.ch/project/show/4/CSFML/

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Question regarding image loading.
« Reply #1 on: July 07, 2014, 08:08:13 pm »
Does 'bg.jpg' actually exist in your working directory?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Lamonte

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Question regarding image loading.
« Reply #2 on: July 07, 2014, 08:39:10 pm »
Of course it existed lol.  Like I said when I downloaded the file from the internet it crashed the program saying it couldn't load the file.  I opened the image and resaved it using mspaint and it worked perfectly fine.  The question is why does the original internet file crash the app?

More clarification: I downloaded the file from the internet to my computer as bg.jpg, crashed.  Opened the same file in mspaint, resaved it, worked fine.
« Last Edit: July 07, 2014, 08:59:09 pm by Lamonte »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Question regarding image loading.
« Reply #3 on: July 07, 2014, 11:11:16 pm »
It works wonders to read the documentation.

Quote
The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Lamonte

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Question regarding image loading.
« Reply #4 on: July 08, 2014, 02:01:16 am »
It works wonders to read the documentation.

Quote
The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.

I should have known that it was a progression jpeg, my mistake.

 

anything