# python - How to color accurately convert from rgb 0-255 format to values in 0.0f-1.0f

The color accuracy is completely wrong when you convert from byte rgb to float.

13/255.0, 105/255.0, 171/255.0 =
R: 0.050980, G: 0.411764, B: 0.67058


While if you were to convert the byte rgb to hex and insert that into blender where you change the base color of the material, you would get these values.

R: 0.004025, G: 0.141263, B: 0.40724


I first thought that the inaccuracy might happen because of floating division accuracy but that isn't the case and its most likely some sort of gamma correction happening within blender.

The problem is that you can not create materials by giving diffuse_color hex values let alone byte values since it only accepts floating numbers. https://docs.blender.org/api/current/bpy.types.Material.html#bpy.types.Material.diffuse_color

Is there some sort of way to do the gamma correction which blender does but apply it when converting from byte rgb to floats?

def color_srgb_to_scene_linear(c):