[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] pygame for 2d graphics
Madhubala wrote:
> My code is below
> -------------------------------------
> s = pygame.Surface((4892,3164)) #original dimension of a screen in
> pixels got from some other application
> s.fill((255,255,255))
>
>
pygame.draw.aalines(s,(0,0,0),True,[(3000,2500),(3192,2500),(3192,2648),(3000,2648)],0)
> #original dimensions of a rect
> pygame.display.init()
> w = pygame.display.set_mode((1000,750))
> s1 = pygame.transform.scale(s,(1000,750))
> w.blit(s1,(0,0))
> pygame.display.flip()
> When i am trying to scale down the original surface to pygame window ,
> the rectangle is not visible.
> This is original scalling. I have to provide different scalling
> levels to provide zooming effect .
>
You are experiencing the destructive effects of aliasing. The scale
function probably does point or at best bilinear sampling. When scaling
down by such a large factor you must first filter the image to remove
frequencies above 1/2 the sampling rate, then sample. This can be done
with a convolution but is likely to be slow. You'll likely also be
unhappy with the resulting dimness of the lines. The filtering will
blend them with their environment causing them to be light gray instead
of black.
You can read more about aliasing at http://en.wikipedia.org/wiki/Aliasing
gb