Advertising (This ad goes away for registered users. You can Login or Register)

C++ SDL2_image IMG_LoadTexture: Unsupported image format

Open discussions on programming specifically for the PS Vita.
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
domis4
Posts: 12
Joined: Sun Jun 12, 2011 8:19 am

C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by domis4 »

Hello everyone,

i tried to get in touch with c++ for the first time and used one of the vitasdk samples in order to create some basic SDL2 application. Currently, i can't get past image loading using SDL2_image, as the image format is always unsupported no matter what format and properties i use (png, jpg, bmp). The small code behind loading and rendering is:

Code: Select all

SDL_Texture* image = IMG_LoadTexture(gRenderer, path.c_str());
https://github.com/domis4/vita-sdl2-tes ... module.cpp
which throws

Code: Select all

Unsupported image format
and results in an application crash due to texture nullpointer in SDL_RenderCopy().

After some research i thought to include libpng and zlib headers and use IMG_init(flags), but the application still throws and crashes.

Maybe a experienced Dev can see my mistake.
Advertising
noname120
Developer
Posts: 777
Joined: Thu Oct 07, 2010 4:29 pm

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by noname120 »

Your homebrew runs in safe mode, this means that it can only access ux0:data/* and ux0:app/YOURTITLEID/*.

If you're willing to embed resources in your app, add them here: https://github.com/domis4/vita-sdl2-tes ... ts.txt#L49
Advertising
Funny stuff
<yifanlu> I enjoy being loud and obnoxious
<yifanlu> rooting an android is like getting a hooker pregnant
<xerpi> I sometimes think I should leave all this stressing **** and be a farmer instead
domis4
Posts: 12
Joined: Sun Jun 12, 2011 8:19 am

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by domis4 »

thank you. This should have crossed my mind sooner. I wasn't too sure how i'd embed my assets.

While including it with

Code: Select all

FILE src/assets/test.png assets/test.png
worked like a charm and is totally fine for me, the file got installed to ux0:/app/ap-id/assets/test.png but It still throws Unsupported Image format using either
app0:assets/test.png
or
ux0:/app/ap-id/assets/test.png

i figured, that even a wrong path specified to either of those dirs would throw "unsuported image format" while a completely different, wrong directory would throw "could not open file". Besides that, i'm still a bit worried why it would let me write to "ux0:domis4/log.txt" in safe mode.
noname120
Developer
Posts: 777
Joined: Thu Oct 07, 2010 4:29 pm

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by noname120 »

Strange. I don't have much experience with SDL2, you should probably ask xerpi on http://webchat.freenode.net/?channels=%23henkaku

By the way, you should change your VITA_TITLEID because "VSDK00013" is already used by a Vita sample.
Funny stuff
<yifanlu> I enjoy being loud and obnoxious
<yifanlu> rooting an android is like getting a hooker pregnant
<xerpi> I sometimes think I should leave all this stressing **** and be a farmer instead
nop90
Posts: 7
Joined: Sun Oct 15, 2017 7:24 pm

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by nop90 »

This post is some months old, but I startes coding for the vita only a couple of weeks ago, and I had the same problem. Since no one answered to the problem, reporting the solution could be of help to other developers.

I found that SDL2_Image is compiled without the flags that enable the supported file formats, this maked that lib useless.

Adding that flags (-DLOAD_BMP -DLOAD_GIF -DLOAD_LBM -DLOAD_PCX -DLOAD_PNM -DLOAD_TGA -DLOAD_XCF -DLOAD_XPM -DLOAD_XV -DLOAD_JPG -DLOAD_PNG) and compiling again the lib solved the problem.

Hope this helps.
noname120
Developer
Posts: 777
Joined: Thu Oct 07, 2010 4:29 pm

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by noname120 »

Feel free to make a pull request here with modified compilations params: https://github.com/lourinaldi/SDL_image ... SDL2_image

The change will then make its way to the sdk.
Funny stuff
<yifanlu> I enjoy being loud and obnoxious
<yifanlu> rooting an android is like getting a hooker pregnant
<xerpi> I sometimes think I should leave all this stressing **** and be a farmer instead
nop90
Posts: 7
Joined: Sun Oct 15, 2017 7:24 pm

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by nop90 »

noname120 wrote:Feel free to make a pull request here with modified compilations params: https://github.com/lourinaldi/SDL_image ... SDL2_image

The change will then make its way to the sdk.
Done
Red-j
Posts: 3
Joined: Thu Nov 30, 2017 8:50 am

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by Red-j »

Hi all I have try to use png but with no luck. I have compiled with new library but it doesn't work for me :(
I have replace the lib.a with the new file.
anyone can explain or show is cmakelist and explaine which includes used in their main.c
I have try to include png.h in my main.c and png flag in cmakelist
Thanks
Best regards
nop90
Posts: 7
Joined: Sun Oct 15, 2017 7:24 pm

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by nop90 »

Please, upload an example of your code somewhere (github , googledrive, or something else) and I'll check it.
Last edited by nop90 on Thu Nov 30, 2017 9:58 am, edited 1 time in total.
Red-j
Posts: 3
Joined: Thu Nov 30, 2017 8:50 am

Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format

Post by Red-j »

Ok bro I will upload in 8 hours, I'm at work ;) thank you a lot
Locked

Return to “Programming and Security”