[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] ChangeColor Routine
Use the add function.
Something like this(untested):
def modify_colors(pi, mycolor):
# does not do overflow correctly. Ie it does not clip max value to 255.
mycolor_mapped = pic.map_rgb(mycolor)
array = pygame.surfarray.pixels2d(pic)
array += mycolor_mapped
modify_colors(mysurf, [2,-4,0,0])
On Sun, 13 Feb 2005 20:54:38 -0800, Kamilche <klachemin@xxxxxxxxxxx> wrote:
> Wow, that is very fast. Thanks for the tip!
>
> I'm now wondering if it would be possible to apply a formula to all
> pixels in a picture at once, using numeric.
>
> I want to modify the R, G, B, A values of a picture separately -
> something like 'add 2 to r, subtract 4 from g, leave B and A alone' sort
> of thing.
>
> Do you know of a way to do that? I wish I knew Numeric better, but it's
> very confusing.
>
> Thanks in advance for any advice you can lend!
>
>