How to set the proper color in Color Picker?

Hi guys,

I’ve coded a little function in googlescript (I think it’s javascript). It takes a string formated like this #FFFFFF, performs the appropriate conversion then outputs the corrected color in the same format.
So you can feed it with a direct copy from the Photoshop color picker, then it outputs a string you can paste in the Unreal colorpicker.
Here you go :

function sRGBConvert(val)
{
  val = val.toUpperCase();
  var r = 0;
  if(val.charCodeAt(1) > 60)
    r += (10 + val.charCodeAt(1)-65) * 16;
  else
    r += (val.charCodeAt(1)-48) * 16;

  if(val.charCodeAt(2) > 60)
    r += (10 + val.charCodeAt(2)-65);
  else
    r += (val.charCodeAt(2)-48);

  var g = 0;
  if(val.charCodeAt(3) > 60)
    g += (10 + val.charCodeAt(3)-65) * 16;
  else
    g += (val.charCodeAt(3)-48) * 16;

  if(val.charCodeAt(4) > 60)
    g += (10 + val.charCodeAt(4)-65);
  else
    g += (val.charCodeAt(4)-48);

  var b = 0;
  if(val.charCodeAt(5) > 60)
    b += (10 + val.charCodeAt(5)-65) * 16;
  else
    b += (val.charCodeAt(5)-48) * 16;

  if(val.charCodeAt(6) > 60)
    b += (10 + val.charCodeAt(6)-65);
  else
    b += (val.charCodeAt(6)-48);
  
  r /= 255.0;
  g /= 255.0;
  b /= 255.0;
  
  r = FixValue(r);
  g = FixValue(g);
  b = FixValue(b);
  
  r *= 255.0;
  g *= 255.0;
  b *= 255.0;
  
  val = "#";
  if((r>>4) > 9)
    val += String.fromCharCode((r>>4) + 65 - 10);
  else
    val += String.fromCharCode((r>>4) + 48);
  
  if((r % 16) > 9)
    val += String.fromCharCode((r % 16) + 65 - 10);
  else
    val += String.fromCharCode((r % 16) + 48);
  
  if((g>>4) > 9)
    val += String.fromCharCode((g>>4) + 65 - 10);
  else
    val += String.fromCharCode((g>>4) + 48);
  
  if((g % 16) > 9)
    val += String.fromCharCode((g % 16) + 65 - 10);
  else
    val += String.fromCharCode((g % 16) + 48);
  
  if((b>>4) > 9)
    val += String.fromCharCode((b>>4) + 65 - 10);
  else
    val += String.fromCharCode((b>>4) + 48);
  
  if((b % 16) > 9)
    val += String.fromCharCode((b % 16) + 65 - 10);
  else
    val += String.fromCharCode((b % 16) + 48);
  
  setActiveValue(val);  
}

function FixValue(val)
{
  if(val >= 0.04045)
    val = Math.pow((val + 0.055) / 1.055, 2.4);
  else
    val = val / 12.92;
  
  return val;
}