Skip to content

Blur algorithm works badly when the pitch is not equal to width*bytes_per_pixel. #2027

@yunline

Description

@yunline
import pygame
import sys

pygame.font.init()

font=pygame.font.SysFont('Arial',100)

pygame.display.init()
dsf=pygame.display.set_mode((1280,720))

sf=font.render('HelloWorld',1,(255,255,255))#.convert_alpha()
print(sf)
print(sf.get_pitch())
print(sf.get_width()*sf.get_bitsize()//8)

sf_blur=pygame.transform.box_blur(sf,10)

dsf.fill((0,150,0))
dsf.blit(sf,(0,0,1,1))
dsf.blit(sf_blur,(640,0,1,1))
pygame.display.update()

while 1:
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            sys.exit()
pygame-ce 2.2.0.dev1 (SDL 2.0.22, Python 3.10.6)
<Surface(487x115x32 SW)>
2016
1948

image

And, when I use the convert_alpha() to convert the surface, the bug disappeared:

pygame-ce 2.2.0.dev1 (SDL 2.0.22, Python 3.10.6)
<Surface(487x115x32 SW)>
1948
1948

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions