Color picker RGB values

Hi all.

I'm trying to write a script that manipulates colors when using gamma 2.2.

Basically I want to have a color picker ("old") so the user can choose a colour and one next to it ("new") that is the result of the following equation.

new=255*((old/255)^2.2)

This will make the RGB values correct when using gamma.

Any help on this would be much appreciated.

Cheers.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

It isn't very precise, unfortunately. Dunno how to make it work better.

try (destroydialog X ) catch ()
rollout X "" width:100
(
	colorpicker cp  "" color:black across:2 width:51 pos:[-2,2] offset:[0,0]
	colorpicker cp2 "" color:black width:51 pos:[47,2] offset:[0,0]
	spinner gamma "Gamma " range:[0.0,1e6,2.2] fieldwidth:40 align:#center
 
	fn setColor2 =
	(
		local g = gamma.value as double
		local clr = cp.color
		v255 = 255.0 as double
		cp2.color = [ v255*((clr.r/v255)^g), v255*((clr.g/v255)^g), v255*((clr.b/v255)^g) ] as Color
	)
 
	fn setColor1 = 
	(
		local g = 1.0 / (gamma.value as double)
		local clr = cp2.color
		v255 = 255.0 as double
		cp.color = [ ceil (v255*((clr.r/v255)^g)), ceil (v255*((clr.g/v255)^g)), ceil (v255*((clr.b/v255)^g)) ] as Color
	)
	on cp  changed clr do setColor2()	
	on cp2 changed clr do setColor1()	
	on gamma changed val do setColor2()
 
)
createDialog X
igamaximus's picture

Practically perfect !

Hey Sergey,

perfect mate, this is practically perfect again!
I just tested on RGB value of 255,229,191 and your beautiful tool gives 255,201,134 which is just 1 step off in Blue channel (255,201,135 is perfectly accurate) and it should be impossible to tell the difference. Thank you so much, again and again for your valuable help !
I would like to ask you something, can you please give me your e-mail?

jahman's picture

.

Sent you a PM, should be in your mailbox

igamaximus's picture

Got it

Got it mate, will write to you soon. Thank you!

igamaximus's picture

Hi mate, this one is very old

Hi mate,

this one is very old but right now i need exactly the same thing. Have you ever found solution for this in this form you have asked for, or maybe as some color converter tool that works with colors exclusively (without using textures and gamma settings in them) ?

Thank you

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.