Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
Questiondata from file Word in DataGridView Pin
Member 1071053221-Mar-15 5:10
Member 1071053221-Mar-15 5:10 
AnswerRe: data from file Word in DataGridView Pin
OriginalGriff21-Mar-15 5:22
mveOriginalGriff21-Mar-15 5:22 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 6:24
Member 1071053221-Mar-15 6:24 
GeneralRe: data from file Word in DataGridView Pin
OriginalGriff21-Mar-15 6:32
mveOriginalGriff21-Mar-15 6:32 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 6:47
Member 1071053221-Mar-15 6:47 
GeneralRe: data from file Word in DataGridView Pin
OriginalGriff21-Mar-15 6:57
mveOriginalGriff21-Mar-15 6:57 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 7:24
Member 1071053221-Mar-15 7:24 
GeneralRe: data from file Word in DataGridView Pin
OriginalGriff21-Mar-15 7:47
mveOriginalGriff21-Mar-15 7:47 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 8:04
Member 1071053221-Mar-15 8:04 
GeneralRe: data from file Word in DataGridView Pin
OriginalGriff21-Mar-15 8:14
mveOriginalGriff21-Mar-15 8:14 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053222-Mar-15 23:46
Member 1071053222-Mar-15 23:46 
GeneralRe: data from file Word in DataGridView Pin
OriginalGriff23-Mar-15 0:10
mveOriginalGriff23-Mar-15 0:10 
AnswerRe: data from file Word in DataGridView Pin
manchanx21-Mar-15 5:27
professionalmanchanx21-Mar-15 5:27 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 6:37
Member 1071053221-Mar-15 6:37 
GeneralRe: data from file Word in DataGridView Pin
manchanx21-Mar-15 6:46
professionalmanchanx21-Mar-15 6:46 
GeneralRe: data from file Word in DataGridView Pin
Member 1071053221-Mar-15 6:49
Member 1071053221-Mar-15 6:49 
GeneralRe: data from file Word in DataGridView Pin
manchanx21-Mar-15 6:50
professionalmanchanx21-Mar-15 6:50 
QuestionC# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317320-Mar-15 23:12
Member 1154317320-Mar-15 23:12 
AnswerRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
manchanx21-Mar-15 4:18
professionalmanchanx21-Mar-15 4:18 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317321-Mar-15 11:16
Member 1154317321-Mar-15 11:16 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
manchanx21-Mar-15 14:00
professionalmanchanx21-Mar-15 14:00 
Alright Smile | :)

Let's assume an initial background color of RGB 20/50/150.

1) Determine the color component with the smallest value and subtract it from 255. In this case: (Red) 255-20 = 235

2) Determine the color component with the highest value. In this case: (Blue) 150

3) Set the Maximum of the TrackBar to the sum of those values: 235+150 = 385

4) Set the Value (Position) of the TrackBar to the value from Step 2: 150

5) When the slider gets moved, take its Value and subtract the value from Step 2. Add the result of this to the color components of the initial background color (with Min/Max of 0/255 of course) and set it as current background color.

Example 1:
Let's assume the TrackBar got moved to 0. Then we calculate: 0-150 = -150
R: 20 + -150 = -130 ==> 0
G: 50 + -150 = -100 ==> 0
B: 150+ -150 = 0

Example 2:
Let's assume the TrackBar got moved to 200. Then we calculate: 200-150 = 50
R: 20 + 50 = 70
G: 50 + 50 = 100
B: 150+ 50 = 200

Example 3:
Let's assume the TrackBar got moved to 385. Then we calculate: 385-150 = 235
R: 20 + 235 = 255
G: 50 + 235 = 285 ==> 255
B: 150+ 235 = 385 ==> 255

Looks good?

Edit: If you want to achieve that all three color components reach the min/max value "at the same time" so that no value has to be "clipped" (which will probably produce a better result for image brightness adjustment) you would have to apply some slightly more sophisticated math but I think you'll get the basic idea from the above method.
Recursion: see Recursion.


modified 21-Mar-15 20:17pm.

GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317322-Mar-15 11:01
Member 1154317322-Mar-15 11:01 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
manchanx22-Mar-15 11:04
professionalmanchanx22-Mar-15 11:04 
GeneralRe: C# trackBar Control is losing Color (Hue) when adjusting Brightness Pin
Member 1154317325-Mar-15 11:02
Member 1154317325-Mar-15 11:02 
QuestionTic Tac Toe - Multiplayer Pin
Googooli8620-Mar-15 9:42
Googooli8620-Mar-15 9:42 

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.