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

Author Topic: Error loading images/textures  (Read 8402 times)

0 Members and 1 Guest are viewing this topic.

Mario1159

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Error loading images/textures
« 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?

Gleade

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Error loading images/textures
« Reply #1 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?

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Error loading images/textures
« Reply #2 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:
Quote
//    - no 12-bit-per-channel JPEG
//    - no JPEGs with arithmetic coding

Mario1159

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Error loading images/textures
« Reply #3 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?

Mario1159

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Error loading images/textures
« Reply #4 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

 

anything