Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How do you read / use this code? Pin
Vaclav_8-Sep-16 10:16
Vaclav_8-Sep-16 10:16 
AnswerRe: How do you read / use this code? Pin
Bram van Kampen8-Sep-16 14:40
Bram van Kampen8-Sep-16 14:40 
AnswerRe: How do you read / use this code? Pin
leon de boer8-Sep-16 17:26
leon de boer8-Sep-16 17:26 
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 
Here is my C++ implementation of the algorythm:

C++


C#
void __fastcall TForm1::SetRamp(double level, double gamma, double bright, double cntrst){
// level should be between 2 and 100
// gamma should be between 2 and 50
// brigntess should be between 0 and 100
// contrast should be between 0 and 100
   HDC GammaDC=GetDC(NULL);
   WORD GammaArray[3][256];

   gamma /= 10;
   bright = 1 + (((bright - 50) / 100) * 65535);
   cntrst = 1 + ((cntrst - 50) / 100);
   level = 1 + ((level - 50) / 100);

   for(DWORD i=0;i<256;i++){
      double value = i * 256;
      value = (pow(value / 65535, 1 / gamma) * 65535) + 0.5;
      value = ((((value / 65535) - 0.5) * cntrst) + 0.5) * 65535;
      value = value += bright;
      value *= level;
      if(value>65535){value=65535;}
      if(value<0){value=0;}
		GammaArray[0][i]=GammaArray[1][i]=GammaArray[2][i]=(WORD)value;
   }
   
   if(!SetDeviceGammaRamp(GammaDC,GammaArray)){
      Memo1->Lines->Add("SetDeviceGammaRamp Failed");
      GraphIt(&GammaArray[0][0], false);
   }else{
      GraphIt(&GammaArray[0][0], true);
   }
   ReleaseDC(NULL,GammaDC);
}

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 
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 

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.