[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Brightness/Contrast Code



Hi all,

While trying to "reverse engineer" the brightness/contrast code used in many
programs, this is what I have come up with and it resembles to 99% the
Photoshop "brightness/contrast" :


R,G,B:
val(1,-100,100)>0 ?
scl(c+val(0,-100,100),127*val(1,-100,100)/100,
255-127*val(1,-100,100)/100,0,255) :
scl(c+val(0,-100,100),0,
255,-val(1,-100,100)*128/100,256+val(1,-100,100)*128/100)

ctl(0):    Brightness
ctl(1):    Contrast

The ranges for these sliders go from -100 to 100.

---

In FiFo, it would look like the following:

Don't forget to go the the Options and change the slider names and ranges
(-100 to 100):


R=
ctl(1)>0 ?
scl(r+ctl(0),127*ctl(1)/100, 255-127*ctl(1)/100,0,255) :
scl(r+ctl(0),0, 255,-ctl(1)*128/100,256+ctl(1)*128/100);

G=
ctl(1)>0 ?
scl(g+ctl(0),127*ctl(1)/100, 255-127*ctl(1)/100,0,255) :
scl(g+ctl(0),0, 255,-ctl(1)*128/100,256+ctl(1)*128/100);

B=
ctl(1)>0 ?
scl(b+ctl(0),127*ctl(1)/100, 255-127*ctl(1)/100,0,255) :
scl(b+ctl(0),0, 255,-ctl(1)*128/100,256+ctl(1)*128/100);

---

Maybe we could create a new "FAQ" where we try to reverse engineer known
functions used in various painting programs (PS, PSP, PhotoPaint, etc...).

See also the FFPG with the codes for the apply modes (multiply, difference,
etc...)

Greetings from Germany,

Werner D. Streidt
http://privat.schlund.de/f/filter-factory