Inverting colors?

Blitz3D Forums/Blitz3D Programming/Inverting colors?

elseano(Posted 2004) [#1]
hi.
I wonder if you could help me with this. First I'll explain what it is. In MSpaint, if you select something and then press CTRL+I you can invert the colors. I was wondering if anyone knew how to do this in Blitz3D? ie. The all the colors on the screen are inverted? Thanks in advance.


WolRon(Posted 2004) [#2]
I don't know of any built-in commands to do such a thing but you could write your own routine to do it although it most likely would not be a very fast routine.

I think all you have to do is for R, G, and B each just subtract the current color from 255 for every pixel in the image.


ChrML(Posted 2004) [#3]
All pixel routines written in blitz will never get fast. That's because there are always many pixels to write (long loops). Like, if you have a screen at 800x600, then it have to loop 800*600 = 480 000 times a mainloop to invert them (which would result <2 frames a second). Anyway, if it's a onetime operation (like if you're coding some sort of image editor), then it should work out fine.


Agamer(Posted 2004) [#4]
yeh as your exspected to wait in things like taht


Anthony Flack(Posted 2004) [#5]
If you want *all* the pixels on the screen inverted, then the answer is yes, you can, very easily and quickly - simply invert all the values in the gamma table.

I haven't checked it but something along these lines:

for lp=0 to 255
  setgamma lp,lp,lp,255-lp,255-lp,255-lp
next
updategamma()



SopiSoft(Posted 2004) [#6]
now that's indeed an easy way to do it!!! ;-)


elseano(Posted 2004) [#7]
Wow, thanks!