import pygame as pygame , sys
pygame.init()
size = (700,500)
window_game = pygame.display.set_mode(size)
print(pygame.mouse.get_cursor())
_run_ = True
class mySprite(pygame.sprite.Sprite):
def __init__ (self,width,height,cord_x,cord_y,color):
super().__init__()
self.image = pygame.Surface([width,height])
self.image.fill(color)
self.rect = self.image.get_rect()
self.rect.center = [cord_x,cord_y]
#my background image
bgimg = pygame.image.load("download.jpg")
bgimg = pygame.transform.smoothscale(bgimg, size)
placeSP = [mySprite(50,20,100,150,(10,205,120))]
placeSP_group = pygame.sprite.Group()
Clock = pygame.time.Clock()
FPS = 240
while _run_:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT
sys.exit()
placeSP.append(mySprite(50,20,100,170,(10,25,0)))
pygame.display.flip()
window_game.blit(bgimg,(0,0))
placeSP_group.draw(window_game)
placeSP_group.add(placeSP[:])
Clock.tick(FPS)
now the problem I have is that the download.jpg is 4k res and if I try to fit that image in my window the img is very blurry and i have also tried many more img but they were all blurry do I try to get a picture of the window size or do i have to do something else pls tell me....
CodePudding user response:
You can't. You can choose between a blurred image with pygame.transform.smoothscale
bgimg = pygame.transform.smoothscale(bgimg, size)
or a jagged image with pygame.transform.scale
bgimg = pygame.transform.scale(bgimg, size)
If you don't want that, you'll need to use a higher resolution image.