buggood first issuetransform
描述
Environment:
You can get some of this info from the text that pops up in the console when you run a pygame program.
- Operating system: Linux(Ubuntu)
- Python version : 3.12.2
- SDL version: 2.28.5+dfsg-2+22.04+jammy+release+build2
- PyGame version: 2.6.0
- Relevant hardware : not relevant
Current behavior:
I have a picture that is 1468 pixels wide. I want to resize it to be 240 wide. I wanted to use scale_by so that the vertical dimension is automatically scaled by the same factor. What I get is a factor of 0.16348773841961853, which, when fed into scale_by, results in a 239 pixel wide Surface.
Expected behavior:
Manually multiplying 0.16348773841961853 * 1468 in Python is 240.0, so I would expect the final Surface to have the same width (i.e. 240).
Test code
import pygame
pygame.transform.scale_by(pygame.Surface((1468, 200)), 240 / 1468)
# Returns <Surface(239x32x32 SW)>
Possible solution
Line 630 in transform.c should probably read round(surf->w * scalex) instead of (int)(surf->w * scalex).