lightknight Posted September 9, 2022 Share Posted September 9, 2022 I do not know if this is the best subforum to post this question to, but here it goes: So, I've added the ability to modify brightness and contrast to my plug-in (which I will be releasing soon), only, I do not understand the contrast adjustment code. I've googled around, and despite reading several tutorials, I still do not grasp it. I've checked the official Paint.Net book, and while it briefly discusses contrast, it doesn't go into details or provide a formula. The code I am using is from this Stackoverflow answer: https://stackoverflow.com/questions/3115076/adjust-the-contrast-of-an-image-in-c-sharp-efficiently What is going on here? Why is 100f being added to the contrast Value, and why is it then being divided by 100f? Why is this Value then being multiplied by itself? Value = (100.0f + Value) / 100.0f; Value *= Value; And what is the significance of the 0.5f in the code below? What variable is 0.5f filling in for? Red = (((Red - 0.5f) * Value) + 0.5f) * 255.0f; Green = (((Green - 0.5f) * Value) + 0.5f) * 255.0f; Blue = (((Blue - 0.5f) * Value) + 0.5f) * 255.0f; Could someone explain it to me like I'm 5? I apologize if this question seems stupid, but I am trying to understand. Thank you Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.