Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pygame.transform.rotozoom loses all surface flags #2446

Closed
DickerDackel opened this issue Sep 10, 2023 · 0 comments · Fixed by #2491
Closed

pygame.transform.rotozoom loses all surface flags #2446

DickerDackel opened this issue Sep 10, 2023 · 0 comments · Fixed by #2491
Assignees
Labels
bug Not working as intended transform pygame.transform

Comments

@DickerDackel
Copy link

DickerDackel commented Sep 10, 2023

Environment:

pygame-ce 2.3.2 (SDL 2.26.5, Python 3.11.4) on Windows 11

Current behavior:

pygame.transform.rotozoom loses all surface flags, incl. colorkey.

Docs say "The resulting Surface will be a filtered 32-bit Surface.", but from that I don't read that the "features" of the surface will be lost.

Expected behavior:

Returning a surface that preserves surface flags, as all other transforms do (see test script below)

Screenshots

Screenshot and output of test script below

image
pygame-ce 2.3.2 (SDL 2.26.5, Python 3.11.4)
original <Surface(64x64x32, colorkey=(0, 0, 0, 255))> 0x1000
rotated <Surface(64x64x32, colorkey=(0, 0, 0, 255))> 0x3000
scaled <Surface(64x64x32, colorkey=(0, 0, 0, 255))> 0x3000
smoothscale <Surface(64x64x32, colorkey=(0, 0, 0, 255))> 0x3000
scaled_by <Surface(64x64x32, colorkey=(0, 0, 0, 255))> 0x3000
smoothscale_by <Surface(64x64x32, colorkey=(0, 0, 0, 255))> 0x3000
rotozoom <Surface(64x64x32)> 0x0

Test code

If possible add a simple test program that shows the problem described in this report.

import pygame

TITLE = 'rotozoom test'
SCREEN = pygame.Rect(0, 0, 1024, 768)
FPS = 60
DT_MAX = 3 / FPS

pygame.init()
pygame.display.set_caption(TITLE)
screen = pygame.display.set_mode(SCREEN.size)
clock = pygame.time.Clock()

image = pygame.Surface((64, 64))
image.set_colorkey('black')
pygame.draw.circle(image, 'red', (32, 32), 32, width=0)

images = {
    'original': image,
    'rotated': pygame.transform.rotate(image, 0),
    'scaled': pygame.transform.scale(image, (64, 64)),
    'smoothscale': pygame.transform.smoothscale(image, (64, 64)),
    'scaled_by': pygame.transform.scale_by(image, 1),
    'smoothscale_by': pygame.transform.smoothscale_by(image, 1),
    'rotozoom': pygame.transform.rotozoom(image, 0, 1),
}

for kind, img in images.items():
    print(kind, img, hex(img.get_flags()))

running = True
while running:
    dt = min(clock.tick(FPS) / 1000.0, DT_MAX)

    for e in pygame.event.get():
        match e.type:
            case pygame.QUIT:
                running = False

            case pygame.KEYDOWN if e.key == pygame.K_ESCAPE:
                running = False

    screen.fill('green')
    x = 50
    for i in images:
        screen.blit(images[i], (x, 50))
        x += 100

    pygame.display.flip()

pygame.quit()
@DickerDackel DickerDackel added the bug Not working as intended label Sep 10, 2023
@MyreMylar MyreMylar added the transform pygame.transform label Oct 1, 2023
igordsm added a commit to igordsm/pygame-ce that referenced this issue Oct 2, 2023
Co-authored-by: jorascco@al.insper.edu.br
Co-authored-by: antonioarf@al.insper.edu.br
Co-authored-by: joaopga1@al.insper.edu.br
Co-authored-by: caioesr@al.insper.edu.br
Co-authored-by: cicerotcv@al.insper.edu.br
Co-authored-by: nataliaqmc@al.insper.edu.br
igordsm added a commit to igordsm/pygame-ce that referenced this issue Oct 2, 2023
Co-authored-by: Joras <jorascco@al.insper.edu.br>
Co-authored-by: antonioarf@al.insper.edu.br
Co-authored-by: joaopga1@al.insper.edu.br
Co-authored-by: caioesr@al.insper.edu.br
Co-authored-by: cicerotcv@al.insper.edu.br
Co-authored-by: nataliaqmc@al.insper.edu.br
igordsm added a commit to igordsm/pygame-ce that referenced this issue Oct 2, 2023
Co-authored-by: Joras <jorascco@al.insper.edu.br>
Co-authored-by: Antonio <antonioarf@al.insper.edu.br>
Co-authored-by: João <joaopga1@al.insper.edu.br>
Co-authored-by: Caio <caioesr@al.insper.edu.br>
Co-authored-by: Cícero <cicerotcv@al.insper.edu.br>
Co-authored-by: Natália <nataliaqmc@al.insper.edu.br>
@MyreMylar MyreMylar self-assigned this Oct 7, 2023
MyreMylar pushed a commit that referenced this issue Oct 27, 2023
Co-authored-by: Joras <jorascco@al.insper.edu.br>
Co-authored-by: Antonio <antonioarf@al.insper.edu.br>
Co-authored-by: João <joaopga1@al.insper.edu.br>
Co-authored-by: Caio <caioesr@al.insper.edu.br>
Co-authored-by: Cícero <cicerotcv@al.insper.edu.br>
Co-authored-by: Natália <nataliaqmc@al.insper.edu.br>
ankith26 pushed a commit that referenced this issue Oct 28, 2023
Co-authored-by: Joras <jorascco@al.insper.edu.br>
Co-authored-by: Antonio <antonioarf@al.insper.edu.br>
Co-authored-by: João <joaopga1@al.insper.edu.br>
Co-authored-by: Caio <caioesr@al.insper.edu.br>
Co-authored-by: Cícero <cicerotcv@al.insper.edu.br>
Co-authored-by: Natália <nataliaqmc@al.insper.edu.br>
Co-authored-by: Dan Lawrence <danintheshed@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended transform pygame.transform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants