Author Topic: _LOADIMAGE supported image types  (Read 4093 times)

0 Members and 1 Guest are viewing this topic.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
_LOADIMAGE supported image types
« on: April 28, 2020, 04:39:39 pm »
What's the official image types supported by _LOADIMAGE? In the Wiki this is stated:

"Various common image file formats supported, like BMP, JPG, PNG, etc. A path can also be given."

It's the "etc." that is throwing me. Are there more than just BMP, JPG, and PNG? I know in the SDL version the following were supported:

BMP, JPG, PNG, GIF, PNM, XPM, XCF, PCX, TIF, LBM, and TGA.

Does that still hold true for later versions?
In order to understand recursion, one must first understand recursion.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: _LOADIMAGE supported image types
« Reply #1 on: April 28, 2020, 05:42:19 pm »
BMP, JPG, PNG, GIF are all I know which is supported, which is why I never expect to expand my Save Image library beyond those 4 formats.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline 40wattstudio

  • Newbie
  • Posts: 82
    • View Profile
    • 40wattstudio
Re: _LOADIMAGE supported image types
« Reply #2 on: April 28, 2020, 06:47:52 pm »
JP2 doesn't work. I tried that one a while back.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: _LOADIMAGE supported image types
« Reply #3 on: April 29, 2020, 11:28:18 am »
JPEG "Progressive" format does not work either.
however JPEG "Entropy Optimization" does.

both those affect the final file size and can make it a fair deal smaller, while maintaining a decent level of quality.


was kind of bummed that PCX doesn't work natively as almost all my old QB45 programs use that format for the sprite sheets and such.
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: _LOADIMAGE supported image types
« Reply #4 on: April 29, 2020, 11:49:33 am »
Officially: BMP, JPG and PNG. Check internal/c/parts/video/image/decode

Now we do have a fallback library (check internal/c/parts/video/image/decode/other) which is tried when none of the file format routines succeeds. I just checked that there is a newer version of it available (https://github.com/nothings/stb) and we may get this new version in the upcoming update to QB64 (v1.4.5?).

FellippeHeitor

  • Guest
Re: _LOADIMAGE supported image types
« Reply #5 on: April 29, 2020, 11:53:57 am »
These are the formats currently supported by stb: JPEG, PNG, BMP, GIF, PSD, PIC, PNM, TGA.

Code: C++: [Select]
  1. static unsigned char *stbi_load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp)
  2. {
  3.    #ifndef STBI_NO_JPEG
  4.    if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp);
  5.    #endif
  6.    #ifndef STBI_NO_PNG
  7.    if (stbi__png_test(s))  return stbi__png_load(s,x,y,comp,req_comp);
  8.    #endif
  9.    #ifndef STBI_NO_BMP
  10.    if (stbi__bmp_test(s))  return stbi__bmp_load(s,x,y,comp,req_comp);
  11.    #endif
  12.    #ifndef STBI_NO_GIF
  13.    if (stbi__gif_test(s))  return stbi__gif_load(s,x,y,comp,req_comp);
  14.    #endif
  15.    #ifndef STBI_NO_PSD
  16.    if (stbi__psd_test(s))  return stbi__psd_load(s,x,y,comp,req_comp);
  17.    #endif
  18.    #ifndef STBI_NO_PIC
  19.    if (stbi__pic_test(s))  return stbi__pic_load(s,x,y,comp,req_comp);
  20.    #endif
  21.    #ifndef STBI_NO_PNM
  22.    if (stbi__pnm_test(s))  return stbi__pnm_load(s,x,y,comp,req_comp);
  23.    #endif
  24.  
  25.    #ifndef STBI_NO_HDR
  26.    if (stbi__hdr_test(s)) {
  27.       float *hdr = stbi__hdr_load(s, x,y,comp,req_comp);
  28.       return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp);
  29.    }
  30.    #endif
  31.  
  32.    #ifndef STBI_NO_TGA
  33.    // test tga last because it's a crappy test!
  34.    if (stbi__tga_test(s))
  35.       return stbi__tga_load(s,x,y,comp,req_comp);
  36.    #endif
  37.  
  38.    return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt");
  39. }

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: _LOADIMAGE supported image types
« Reply #6 on: April 29, 2020, 11:58:58 am »
Thanks Fell, I'll include that in the tutorial.
In order to understand recursion, one must first understand recursion.