Search code examples
pythonpyglet

I can't fit a picture in pyglet


I am trying to load a HD picture (1280x720) into pyglet window. I setup the same window size as the image has, but the output is still cropped. My screen resolution is 1920x1080 if it matters, but I won't have the window on fullscreen either.

image: enter image description here

output in pyglet app:

enter image description here

My code:

import pyglet
window = pyglet.window.Window(width=1280, height=720)
image = pyglet.image.load('pic.jpg')
@window.event
def on_draw():
    window.clear()
    image.blit(0,0)

pyglet.app.run()

Where is the problem?


Solution

  • The picture you linked is https://i.sstatic.net/bvdHj.jpg which is 1920x1080. I think you may the dimensions mixed up?