Anonymous
Изображение в pygame черное
Сообщение
Anonymous » 11 янв 2025, 04:56
Когда я загружаю свое изображение в pygame (см. код ниже), изображение выглядит черным, а не отображается правильно!
Использование 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()
Черный ящик вместо изображения.
Подробнее здесь:
https://stackoverflow.com/questions/793 ... e-is-black
1736560590
Anonymous
Когда я загружаю свое изображение в pygame (см. код ниже), изображение выглядит черным, а не отображается правильно! Использование Python 3.12.8 [code]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() [/code] Черный ящик вместо изображения. Подробнее здесь: [url]https://stackoverflow.com/questions/79347385/image-in-pygame-is-black[/url]