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

Re: [pygame] ChangeColor Routine



Kamilche wrote:
> Do you know why this is so? Ideally, I'd like to use your colorizing
> method on the palettized version as well, so I have to understand it.
>
> Here's a link to my test suite, plus the 3 pictures I was using with it.
> I didn't zip it, so you don't have to worry about viruses.
>
> http://www.kamilche.com/python/colorize%20speed%20test/
>

colorize.py:
>        array  = array * (255+adj[0], 255+adj[1], 255+adj[2])
>        array /= 255

ah, where I was multiplying colors, you want to add them.
should be able to do just this:

        array += adj

That will add to the array, where before you were multiplying each color by (255+adj)/255. (Because of the way numeric handles operations on arrays, I had to do my multiplication in 2 steps. I think this will explain a bit better: http://numeric.scipy.org/numpydoc/numdoc.htm#pgfId-35984).