Jump to content
  • Advertisement
Sign in to follow this  
Milton W

PySDL2 error loading jpeg

This topic is 975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I am in the process of learning sdl2 with pysdl. I copied this simple code snippet to load a jpeg and it causes an error:

    window = sdl2.ext.Window("SDL2 Image Test", size=(800, 600))
    renderer = sdl2.ext.Renderer(window, -1, 0)
    image = sdl2.ext.load_image("test_img.jpg", enforce="SDL") # <--- ERROR
    running = True
    while running:
        events = sdl2.ext.get_events()
        for event in events:
            if event.type == sdl2.SDL_QUIT:
                running = False

Here is the error output, which I find very uninformative:

File "sdlimg", line 24, in <module>
File "sdlimg", line 12, in main
image = sdl2.ext.load_image("test_img.jpg")
File "/usr/lib64/python3.5/site-packages/sdl2/ext/image.py", line 71, in load_image
raise SDLError(sdlimage.IMG_GetError())
sdl2.ext.common.SDLError: b'JPEG loading error'

I tried searching the error and got literally no results. I also tried sdl2.sdlimage.IMG_Load() instead but then it simply gives a "wrong type" error. I tested with BMP files and they load fine.

So anyone have any ideas why it fails to load JPG images?


Or if there is another way to achieve hardware-accelerated image rendering in python that integrates well with PyGObject/GTK then I'd like to hear about it.

Thank you!

Share this post

Link to post
Share on other sites

Today I got a lot of this errors (not Py, not SDL), where the jpg was really a png or where a file was opened exclusively by another app. Sure about the path? JPEG2000? File extension jpeg jpg jiff ? You know this not programming errors.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!