Skip to content

Possibly unreachable blit code #3247

Open
Open
@itzpr3d4t0r

Description

@itzpr3d4t0r

Alongside the many blitters in Pygame, we have a function called alphablit_colorkey:

alphablit_colorkey implementation.

It seems this blitter should be used with a surface that has both an alpha channel and a colorkey set. However, it doesn't appear to work as expected.

Here’s a minimal example where it should work:

import pygame

pygame.init()


screen = pygame.display.set_mode((800, 600))

surf = pygame.Surface((100, 100), flags=pygame.SRCALPHA)
print(surf.get_flags(), surf)
surf.fill((255, 0, 0, 128))
surf.set_colorkey((255, 0, 0, 255))
print(surf.get_flags(), surf)


screen.blit(surf, (100, 100))

I added print statements in alphablit_colorkey and the fallback SDL blitter to debug this. Here's the output:

65536 <Surface(100x100x32, global_alpha=255)>
69632 <Surface(100x100x32, colorkey=(255, 0, 0, 255), global_alpha=255)>
SDL_BlitSurface

From the output, it seems the default SDL blitter is used instead of alphablit_colorkey.

Is this a bug, or am I missing a condition that triggers alphablit_colorkey?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Surfacepygame.SurfacebugNot working as intended

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions