Sign in to follow this  

PySDL2 error loading jpeg

This topic is 671 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))
    window.show()
    
    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
                break
        window.refresh()

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

File "sdlimg", line 24, in <module>
main()
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

This topic is 671 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this