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

Re: [pygame] imprecise outlines using set_colorkey()



arg,  I already saw a bug.

#untested... with 1 less bug.
def whitish(c):
    r,g,b,a = c
    return 255-r < 10 and 255-g < 10 and 255-b < 10
edges = pygame.transform.laplacian(s)
for y in edges.get_height():
    for x in edges.get_width():
        if edges.get_at((x,y)) != (0,0,0,0) and whitish( s.get_at((x,y)) ):
            s.set_at((x,y), (0,0,0))




On Mon, Oct 10, 2011 at 8:38 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
Yeah, that is the cause.

You'll have to look at those pixels and change them if you want to use color keying.

You could manually edit them, or come up with an algorithm that changes the color of those edge pixels.  I'd use an edge detection algo (eg, pygame.transform.laplacian) and then replace those pixels that are whiteish to black.  Since the sprite has a black outline already, maybe that will work.  But I'm not sure it will look that great.

#untested...
def whitish(c):
    r,g,b,a = c
    return 255-r < 10 and 255-g < 10 and 255-b < 10
edges = pygame.transform.laplacian(s)
for y in edges.get_height():
    for x in edges.get_width():
        if whitish( edges.get_at((x,y)) ):
            s.set_at((x,y), (0,0,0))



Some manual editing will give best results, but obviously it will take longer.



On Mon, Oct 10, 2011 at 8:24 PM, Sean Wolfe <ether.joe@xxxxxxxxx> wrote:
Hey all,

I am wondering if there's a fix for this. I'm using art is originally
on a white background, so I used set_colorkey([255,255,255]) to remove
the background, but I'm getting an imprecise outline. I'm thinking
it's because of antialiasing?

See attached picture ragged_outline.png .

Thanks!



--
A musician must make music, an artist must paint, a poet must write,
if he is to be ultimately at peace with himself.
- Abraham Maslow