If you read the hex value from the color picker, you can get it in the correct format. Look at line 1323 in emperor.js 

That way you don't need to create an rgb2hex function.