SFML community forums

Bindings - other languages => DotNet => Topic started by: Mario1159 on September 22, 2018, 04:01:08 am

Title: Error loading images/textures
Post by: Mario1159 on September 22, 2018, 04:01:08 am
My program let the user select an image (examine) and load it.
Most of the images load and display fine but some of them throw an exception
(SFML.LoadingFailedException: 'Failed to load texture from file C:\Users\ ... \t_bg.jpg')
  in the following line:
Image img = new Image(path);
or
Texture texture = new Texture(path);
At first i thought it could be the path that is wrong so i tested opening a file that throw the exception in the search bar of a windows folder and it opened successfully.
To confirm that the path is not wrong i tried creating an image but with System.Drawing and it didn't gave me an exception.

Next i thought maybe it has to do with the security so i placed this in my code:
        [FileIOPermissionAttribute(SecurityAction.PermitOnly,
     ViewAndModify = @"C:\Users\ ... \(folder that cointains t_bg.jpg file)\")]
But it didnt work either.

What could be the problem?
Title: Re: Error loading images/textures
Post by: Gleade on October 08, 2018, 06:43:43 am
To clarify, you were able to load the exact same image using System.Drawing but not SFML?
Title: Re: Error loading images/textures
Post by: dabbertorres on October 11, 2018, 08:08:53 pm
stb_image (which SFML uses to load images) doesn't support a few kinds of jpeg images as I recall. You might want to check if this is the case.

Limitations: (https://github.com/nothings/stb/blob/master/stb_image.h#L112-L113)
Quote
//    - no 12-bit-per-channel JPEG
//    - no JPEGs with arithmetic coding
Title: Re: Error loading images/textures
Post by: Mario1159 on October 16, 2018, 09:21:58 pm
thanks, also is there any way to change the "format" (limitation properties) of the incompatible images keeping the jpeg format?
Title: Re: Error loading images/textures
Post by: Mario1159 on October 16, 2018, 09:22:54 pm
To clarify, you were able to load the exact same image using System.Drawing but not SFML?
yes