Click here to Skip to main content
15,879,094 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSOLVED Re: How do you read / use this code? Pin
Vaclav_9-Sep-16 18:23
Vaclav_9-Sep-16 18:23 
QuestionReference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp - My best solution Pin
Keith Davis3-Sep-16 6:28
Keith Davis3-Sep-16 6:28 
QuestionRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Richard MacCutchan3-Sep-16 6:36
mveRichard MacCutchan3-Sep-16 6:36 
AnswerRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Keith Davis3-Sep-16 6:47
Keith Davis3-Sep-16 6:47 
AnswerRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Keith Davis3-Sep-16 7:11
Keith Davis3-Sep-16 7:11 
AnswerRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
leon de boer4-Sep-16 3:54
leon de boer4-Sep-16 3:54 
GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Keith Davis4-Sep-16 9:10
Keith Davis4-Sep-16 9:10 
GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
leon de boer4-Sep-16 22:36
leon de boer4-Sep-16 22:36 
I started working a much more detailed description of how to play with the curve but realized that isn't what you were confused about.

Gamma-correcting an image is essentially raising its color intensities to 1/gamma, so that when the monitor in turn raises the value to gamma, these cancel out.

You said ... I'm trying to work the problem backwards from the GetDeviceGammaRamp function call to whatever input values would be required to create the current gamma ramp array. You need to explain why you want to reverse it .. you aren't a hardware device. Your code is designed for something like a game where it simply loads a slight adjustment to the colors at start up where it will set the gamma ramp table on the DC. You sound more like you are trying to do something like an ICC profile.

Your code is a basic exponential function it wouldn't really match a real monitor gamma output distortion which would need something like a spline. That would all be done in a processing phase not down on the output out to a device context. So I think you need to explain more what you are trying to do.

Perhaps read the Microsoft overview of gamma control on windows and expand it from there.
Using gamma correction (Windows)[^]

The current gamma correction occurs on 1 line of code in your example above
value = (Math.Pow(value / 65535, 1 / gamma) * 65535) + 0.5;

The initial gamma is divided by 10 so if you enter 10 you get Math.Pow(value / 65535, 1) that is it's linear
and the value is basically value/65535*65535 .. AKA the same value.

Value is defined as
double value = i * 256;

So all that whole function does is return a value in 256 step increments.
With gamma set to 10 you are going to get 0,255,511, ... 65535

The reverse table can be built using the line
value = (Math.Pow(value / 65535, gamma) * 65535) + 0.5;

Straight mathematics anything raised to a power is inverted by raising to 1/power so replace 1/gamma with gamma, I made bold and underlined so the substitution is more obvious.

Still confused what you are trying to do, but hopefully something there helps.
In vino veritas


modified 5-Sep-16 6:26am.

GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Keith Davis5-Sep-16 4:38
Keith Davis5-Sep-16 4:38 
GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
leon de boer5-Sep-16 6:06
leon de boer5-Sep-16 6:06 
GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Keith Davis5-Sep-16 8:23
Keith Davis5-Sep-16 8:23 
GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
leon de boer5-Sep-16 18:55
leon de boer5-Sep-16 18:55 
GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Keith Davis5-Sep-16 19:55
Keith Davis5-Sep-16 19:55 
GeneralRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp Pin
Keith Davis8-Sep-16 9:31
Keith Davis8-Sep-16 9:31 
AnswerRe: Reference CalculateRamp - How to derive entry arguments from the existing Gamma Ramp - My Solution Pin
Keith Davis7-Sep-16 10:30
Keith Davis7-Sep-16 10:30 
QuestionPrinter Control Pin
Bram van Kampen27-Aug-16 15:38
Bram van Kampen27-Aug-16 15:38 
QuestionRe: Printer Control Pin
Richard MacCutchan27-Aug-16 20:31
mveRichard MacCutchan27-Aug-16 20:31 
AnswerRe: Printer Control Pin
Bram van Kampen28-Aug-16 14:20
Bram van Kampen28-Aug-16 14:20 
GeneralRe: Printer Control Pin
Richard MacCutchan28-Aug-16 20:56
mveRichard MacCutchan28-Aug-16 20:56 
GeneralRe: Printer Control Pin
Jochen Arndt28-Aug-16 21:38
professionalJochen Arndt28-Aug-16 21:38 
GeneralRe: Printer Control Pin
Richard MacCutchan28-Aug-16 22:03
mveRichard MacCutchan28-Aug-16 22:03 
GeneralRe: Printer Control Pin
Jochen Arndt28-Aug-16 22:09
professionalJochen Arndt28-Aug-16 22:09 
GeneralRe: Printer Control Pin
Richard MacCutchan28-Aug-16 22:19
mveRichard MacCutchan28-Aug-16 22:19 
GeneralRe: Printer Control Pin
Bram van Kampen1-Sep-16 13:37
Bram van Kampen1-Sep-16 13:37 
GeneralRe: Printer Control Pin
Richard MacCutchan1-Sep-16 23:37
mveRichard MacCutchan1-Sep-16 23:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.