I haven't had time to look at this yet. I don't have a math background so I am not sure how to read this:
Bg = (B/255)γ, where we use γ = 2.2
What happens when the value is 128? 128 / 255 ???? 2.2