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

[pygame] Re: Help with pygame.transform.threshold



Renà Dudfield <renesd@...> writes:

> 
> 
> Hi,I think it is a bug.If you have change_return = 1, then it compares your
color (RED) to each pixel in surface2, and makes the pixels in surface1 (WHITE)
which are within the threadhold (0,0,0) of (RED). However since you have
inverse=True, it makes the pixels that are not within the threshold of RED
WHITE.Is that what you wanted?Really, the function should work by passing in
None... however it seems to require a Surface there when you're not using it.
> On Fri, Mar 4, 2011 at 1:45 AM, Thor Julsrud
<thrstein@xxxxxxxxx> wrote:Hi!
> I'm trying to use the threshold function in a roguelike to get appropriate
> background and foreground colors for tiles (simulating ASCII). I've simply
> used pygame.transform.threshold(surface1, surface2, WHITE, (0,0,0), RED, 1,
> None, True).
> However, it keeps complaining "TypeError: must be pygame.Surface, not None".
> If I change the None to a Surface it works, but obviously not the way I
> intended to use the function... Is this simply a bug, or am I doing something
> wrong?
> Thanks.
> 
> 
> 
> 

Well, it seems like there was a bug in the code, change_return was supposed 
to be 2. When not using inverse, anything outside the threshold is changed, 
while anything inside is kept as it were. This is now perfect for my 
purposes, except that it's opposite of what I want to do. I could probably 
try to work something out though. If it comes to it, there's always 
PixelArray...
Thanks for the help, does the bug count as reported by posting here, or should
I also post it in the Bug Tracker?