简体   繁体   English

png,jpg图像在pygame中无法正确显示(mac osx pycharm / IDLE)

[英]png, jpg images not displaying properly in pygame (mac osx pycharm / IDLE)

recently started coding with python using pycharm / python IDLE on mac osx. 最近开始使用Mac OSX上pycharm /蟒蟒IDLE编码。

When it comes to showing / blitting images onto a defined pygame display, png and jpg formats don't appear properly (see images). 当涉及到表示/位图传输图像投影到规定的显示pygame的,PNG和JPG格式不正确显示(参照图像)。

Only bmp formats appear properly. 只有BMP格式正确显示。

Any suggestions to make jpg and png appear correctly in pygame? 有什么建议可以使jpg和png在pygame中正确显示吗?

Thank you 谢谢

source jpg image 源jpg图像

how it appears on pygame display 它是如何出现pygame的显示器上

import pygame, sys
    from pygame.locals import *

    pygame.init()

    width = 640
    height = 480

    screen = pygame.display.set_mode((width,height))
    pygame.display.set_caption('hello piggy')

    white = (255,255,255)
    image = pygame.image.load("flpig.jpg")

    x=160
    y=120

    running = True

    while running:
        screen.fill(white)
        screen.blit(image, (x, y))

        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

        pygame.display.update()
import pygame
from pygame.locals import*
img = pygame.image.load("flpig.jpg")
white = (255, 255, 255)
w = 640
h = 480
screen = pygame.display.set_mode((w, h))
screen.fill((white))
running = 1

while running:
 screen.fill((white))
 screen.blit(img,(0,0))
 pygame.display.flip()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM