最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Image in pygame is black - Stack Overflow

programmeradmin5浏览0评论

When I load my image in pygame (see code below), the image appears pitch black, instead of drawing properly!

Using Python 3.12.8

import pygame
pygame.init()
def imageload(imagepath):
    return pygame.image.load(imagepath)
    
Surface = pygame.Surface
screen = pygame.display.set_mode((300, 200), 0, 32)
pygame.display.set_caption('Python Clicker')
background_colour = (255,255,255)
cookieimage = Surface.convert(imageload('images/python.bmp'))
running = True
while running:
  screen.fill(background_colour)
  screen.blit(Surface((64,64), 0, cookieimage), (150, 100), None, 0)
  pygame.display.flip()
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      running = False
      pygame.quit()

Black box in place of image.

发布评论

评论列表(0)

  1. 暂无评论