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

Re: [pygame] Flood Filling Images



Kevin wrote:
Hi, I'm looking for a fast way of "flood-filling" an image, like changing all green to red and such (akin to PHP's imageColorSet() function if that helps). The current method I'm looking at is locking the surface, getting every pixel on the surface one by one and then setting it if it's a certain color, and unlocking, but even the documentation says that's going to be slow (maybe it's fast enough with the new PyGame release?). There's a good chance I might have missed something in pygame.display, but any suggestions or pointing to some built-in thing would be appreciated.
Will the surface have alpha? The simplest way is to use a palette. If that is not an option then use Surface.set_colorkey. Set the color key of the source surface to the color to change. Then blit to a surface that is filled with the target color.

--
Lenard Lindstrom
<len-l@xxxxxxxxx>