【发布时间】:2021-12-21 09:26:51
【问题描述】:
任何人都可以清楚地说明我的代码,为什么当我尝试将我的 gif 缩放到全屏时,一半的屏幕是白色的,而另一个是 gif(动画)?这是使用 Pyglet python 模块。
这是我的代码以及问题的图片:
'Load animation'
animation = pyglet.image.load_animation('Goober#13427G.gif')
animSprite = pyglet.sprite.Sprite(animation)
# 'Scale image to screen *harcoded*'
# animSprite.scale_x = 3.2
# animSprite.scale_y = 1.71
' Get display and create a fullscreen window while scaling gif to screen'
display = pyglet.canvas.Display()
screen = display.get_screens()
H_ratio = max(animSprite.height, screen[1].height) / min(animSprite.height, screen[1].height)
W_ratio = max(animSprite.width, screen[1].width) / min(animSprite.width, screen[1].width)
animSprite.scale = min(H_ratio, W_ratio)
window = pyglet.window.Window(width=screen[1].width, height=screen[1].height, fullscreen=True, screen=screen[1])
r, g, b, alpha = 1, 1, 1, .5
pyglet.gl.glClearColor(r, g, b, alpha)
@window.event
def on_draw():
window.clear()
animSprite.draw()
pyglet.app.run()
```[Gif with second half of screen to the right is white][1]
[1]: https://i.stack.imgur.com/JsbJy.jpg
【问题讨论】:
-
您好! gif应该与屏幕具有相同的格式? (16/9) 你希望 gif 被拉伸到屏幕格式还是切到顶部/底部?
-
我希望 gif 会根据显示器尺寸进行拉伸,比如说我使用 27" 显示器,它应该相应地成比例。我尝试将我用来显示 gif 的显示器放在纵向上模式,但它会导致相同的问题,即一半屏幕是白色的。