[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] loss of transparency in scaling surfaces



 

Hi

 I am drawing a line on pygame screen and created one transparent surface of size (800,700) and scaling down using smoothscale to the pygame screen size .In this condition everything is working fine.

 

If have created the transparent surface of size like 4892X3614 and then scaling down to the pygame screen size then transparency is lost. Can any one help me understanding this? The script is shown below

 

 

 

import pygame

BACKGROUNDCOLOR = (255,255,255)

pygame.display.init()

screen = pygame.display.set_mode((800,700))

screen.fill(BACKGROUNDCOLOR)

# draw a line on pygame screen

pygame.draw.line(screen,(255,0,0), (50,50),(100,100),1)

# for small surface like this transparecy is fine

## *************************************************

##surf = pygame.Surface((800,700))

## **************************************************************

# for large surface like this transparecy is Lost

surf = pygame.Surface((4892,3614))

surf.fill(BACKGROUNDCOLOR)

# set transparency

surf.set_colorkey(BACKGROUNDCOLOR,pygame.RLEACCEL)

#draw a line on transparent surface

pygame.draw.line(surf,(200,155,155), (550,550),(750,550),2)

#scale down

surf3  = pygame.transform.smoothscale(surf, (800,700))

screen.blit(surf3,(0,0))

 

pygame.display.flip()

while 1:

    events = pygame.event.get()

    for event in events:

        if event.type==pygame.KEYDOWN and event.key ==pygame.K_ESCAPE:

            pygame.display.quit()

 

thanks,

Sibtey