-
-
Notifications
You must be signed in to change notification settings - Fork 186
pygame.transform.pixelate #2354
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
base: main
Are you sure you want to change the base?
pygame.transform.pixelate #2354
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great.
Before & After
Code
import pygame
screen = pygame.display.set_mode((500, 500))
creeper = pygame.image.load("creeper.jpg")
creeper = pygame.transform.scale_by(creeper, 0.5)
creeper = pygame.transform.pixelate(creeper, 50)
running = True
while running:
for e in pygame.event.get():
if e.type == pygame.QUIT:
running = False
screen.fill((0, 0, 0))
screen.blit(creeper, (0, 0))
pygame.display.update()
Could this effect be replicated with a smoothscale down and a scale up? It could even do that in C code, and it might be faster because those are SIMD optimized? Initial testing is promising that it replicates the effect, I didn't test performance. |
Shouldn't even need smoothscale for this, a bit of math with Would probably be worth a look at least to see if it is faster than this current method. |
I've converted this to a draft due to large open questions about how the implementation should work. |
I'll revive this soon, I promise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we implement this by way of generalizing the blur transforms by adding a stride argument to them? Then we could implement this as a blur with stride equal to the blur radius. Then we'd also have the stride argument for blurs and pixelate could be like a convenience function that simply calls one of the blur functions with stride equal to radius, though I suppose it'd be called pixel size or something. |
117975c
to
47b1ace
Compare
47b1ace
to
d2ca0b5
Compare
Addressing #2302
TODO: