Lich4r
Lich4r

Reputation: 1383

Set pygame surface DPI

I am rendering Mandelbrot fractal on a pygame surface from a numpy array.

When I generate a 10k px * 10k px image and save it using pylab in a 10 * 10 inch image with a 1000dpi I get a 10k pixels image which render pretty well when windows build in photo app display it with zoom ajustment. In pygame, the image looks pretty ugly although it is displayed with the same size :

enter image description here

I'm using this code :

pygame.init()
display = pygame.display.set_mode((1000, 1000))
surf = pygame.surfarray.make_surface(gimage)

surf = pygame.transform.rotate(surf, 90)
surf = pygame.transform.scale(surf, (1000, 1000))

How would one set pygame image size and ajust DPI ?

Upvotes: 1

Views: 1644

Answers (1)

furas
furas

Reputation: 142631

scale() is "fast scale operation" and doesn't use resampling.
There is also smoothscale() which uses different algorythm.
Maybe it will give you better result.

You can also use PIL/Pillow to resize() with different methods of resampling.

You can also try to use CV2 to resize().
Yesterday there was question how to use CV2 with PyGame

Upvotes: 2

Related Questions