[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] How to replace a color in an image?
Hi,
You could replace the pixels of the given color using surfarray or pixelarray before blitting. You could also make it an 8 bit surface and adjust the palette. You could also just do a manual loop though all the pixels with .get_at(), .set_at(). Personally, I'd go with surfarray or pixelarray--it's fast, and doesn't suffer from bit-depth loss like palettes.
There may be better ways, contingent on what exactly you're doing. You may be able to adjust your algorithm so that this situation doesn't happen. A more complete description of what you're doing?
Ian