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

Author Topic: Load From File  (Read 284 times)

0 Members and 1 Guest are viewing this topic.

CrowbarJones

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Load From File
« on: February 14, 2024, 11:23:18 am »
I tried to load an image for a texture, but the program failed to load that image with the reason "Image not of any known type, or corrupt". Why does this error happen? I used .png image, it is supported, for sure. Also, I've checked that the image it a real png image by checking in "Properties" of that image file. In addition, after testing, I'm quite sure that the program successfully found the location of the file.
« Last Edit: February 14, 2024, 11:27:29 am by CrowbarJones »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10822
    • View Profile
    • development blog
    • Email
Re: Load From File
« Reply #1 on: February 14, 2024, 12:36:50 pm »
Are you mixing debug and release version (e.g. building in debug while using SFML release libraries)?

Try some other image to be sure.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CrowbarJones

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Load From File
« Reply #2 on: February 14, 2024, 02:04:13 pm »
Are you mixing debug and release version (e.g. building in debug while using SFML release libraries)?

Try some other image to be sure.
Thanks for your quick response.
I've tried some other images, and the result is some images work well, while some do not. But I think the problem is in the image itself.
Just one more quick question, do you know in which case SFML will mark an image as corrupt? I've searched for some information on the Internet and I found that generally, if I can open and see the image, it is not corrupt. However, when I'm testing, I successfully opened and viewed all the images that SFML marked as corrupt.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10822
    • View Profile
    • development blog
    • Email
Re: Load From File
« Reply #3 on: February 14, 2024, 02:06:57 pm »
SFML uses stb_image for loading images. If you're using SFML 2.6 you should have the latest version.
Not sure what it considers corrupt exactly. If you're on an older version, it might simply be a bug in stb_image that has already been solved (e.g. 8-bit png wasn't supported for a while).

Here's the supported (and unsupported) formats from stb_image directly:

      JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
      PNG 1/2/4/8/16-bit-per-channel

      TGA (not sure what subset, if a subset)
      BMP non-1bpp, non-RLE
      PSD (composited view only, no extra channels, 8/16 bit-per-channel)

      GIF (*comp always reports as 4-channel)
      HDR (radiance rgbE format)
      PIC (Softimage PIC)
      PNM (PPM and PGM binary only)
 
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CrowbarJones

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Load From File
« Reply #4 on: February 15, 2024, 04:55:23 am »
Thank you

 

anything