File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -403,8 +403,12 @@ def load_pygame_image_file(image_path: str, **kwargs) -> 'pygame.Surface':
403403 pil_invalid_exception = UnidentifiedImageError
404404 img_pil = Image .open (image_path )
405405 # noinspection PyTypeChecker,PyUnusedLocal
406- surface = pygame .image .fromstring (
407- img_pil .tobytes (), img_pil .size , img_pil .mode ).convert ()
406+ if pygame .version .vernum >= (2 , 3 , 0 ):
407+ surface = pygame .image .frombytes (
408+ img_pil .tobytes (), img_pil .size , img_pil .mode ).convert ()
409+ else :
410+ surface = pygame .image .fromstring (
411+ img_pil .tobytes (), img_pil .size , img_pil .mode ).convert ()
408412 except (ModuleNotFoundError , ImportError ):
409413 warn (f'Image file "{ image_path } " could not be loaded, as pygame.error '
410414 f'is raised. To avoid this issue install the Pillow library' )
You can’t perform that action at this time.
0 commit comments