Click here to Skip to main content
15,890,336 members
Home / Discussions / C#
   

C#

 
QuestionRe: How to add a separator in menu? Pin
Neal Conrardy4-Mar-07 14:56
Neal Conrardy4-Mar-07 14:56 
QuestionHow to Pass More than One Value from Parent to Child? Pin
Khoramdin3-Mar-07 18:17
Khoramdin3-Mar-07 18:17 
AnswerRe: How to Pass More than One Value from Parent to Child? Pin
Tamimi - Code3-Mar-07 19:39
Tamimi - Code3-Mar-07 19:39 
AnswerRe: How to Pass More than One Value from Parent to Child? Pin
khmays1233-Mar-07 19:54
khmays1233-Mar-07 19:54 
Questionvisual commonet for angle... Pin
barak1604873-Mar-07 17:20
barak1604873-Mar-07 17:20 
Questionone textbox - bind to 2 fields Pin
Glen Harvy3-Mar-07 15:18
Glen Harvy3-Mar-07 15:18 
Questionfaster way to adjust contrast????? Pin
samreengr83-Mar-07 11:21
samreengr83-Mar-07 11:21 
AnswerRe: faster way to adjust contrast????? Pin
Christian Graus3-Mar-07 23:29
protectorChristian Graus3-Mar-07 23:29 
You can adjust brightness and contrast through a matrix operation in GDI+.


// return matrix for the specified contrast
public static float[][] GetContrastMatrix( int percent )
{
// perform contrast by setting the scale and offset at the same time

// calculate the scale and offset
float v = 0;
if ( percent > 0 )
{
// range from 0.0 (no change) to 3.8 (high contrast)
v = 0.0195F * percent;
v *= v;
}
else
{
// negative value, -1.0 is gray and 0.0 is no change
v = 0.009F * percent;
}

float scale = 1 + v;
float offset = v / 2;

// setup the matrix
float[][] matrix =
{
new float[]
{ scale, 0, 0, 0, 0 }, new float[]
{ 0, scale, 0, 0, 0 }, new float[]
{ 0, 0, scale, 0, 0 }, new float[]
{ 0, 0, 0, 1, 0 }, new float[]
{ -offset, -offset, -offset, 0, 1 } };

return matrix;
}

That returns a contrast matrix. This code:


ColorMatrix cm = new ColorMatrix( matrix );
ImageAttributes attr = new ImageAttributes();
attr.SetColorMatrix( cm );

Creates an ImageAttributes object that uses the matrix. Then the Graphics class has a DrawImage overload ( or more ) that take this ImageAttributes class as a parameter.

I should write an article on this, to complement my articles showing the 'lock bits' way of doing things.





Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

GeneralRe: faster way to adjust contrast????? Pin
samreengr85-Mar-07 8:19
samreengr85-Mar-07 8:19 
AnswerRe: faster way to adjust contrast????? Pin
Vasudevan Deepak Kumar4-Mar-07 5:06
Vasudevan Deepak Kumar4-Mar-07 5:06 
Questionpopulating a Treeview in c# [modified] Pin
Starzfighter3-Mar-07 10:55
Starzfighter3-Mar-07 10:55 
AnswerRe: populating a Treeview in c# Pin
Abisodun3-Mar-07 12:04
Abisodun3-Mar-07 12:04 
GeneralRe: populating a Treeview in c# Pin
Starzfighter4-Mar-07 0:33
Starzfighter4-Mar-07 0:33 
GeneralRe: populating a Treeview in c# Pin
Abisodun4-Mar-07 2:21
Abisodun4-Mar-07 2:21 
Questiondynamically generate the copy of background Pin
sushantkaura3-Mar-07 9:50
sushantkaura3-Mar-07 9:50 
Generalcollection class Pin
needhelpinnet3-Mar-07 9:44
needhelpinnet3-Mar-07 9:44 
GeneralRe: collection class Pin
Not Active3-Mar-07 10:20
mentorNot Active3-Mar-07 10:20 
GeneralRe: collection class Pin
needhelpinnet3-Mar-07 12:28
needhelpinnet3-Mar-07 12:28 
QuestionWord or Excel , get opened file name Pin
Muhammad Nauman Yousuf3-Mar-07 8:00
Muhammad Nauman Yousuf3-Mar-07 8:00 
QuestionSystem.Drawing.Bitmap byte[] Pin
KainPlan3-Mar-07 7:25
KainPlan3-Mar-07 7:25 
AnswerRe: System.Drawing.Bitmap byte[] Pin
Wayne Phipps3-Mar-07 8:03
Wayne Phipps3-Mar-07 8:03 
GeneralRe: System.Drawing.Bitmap byte[] Pin
KainPlan3-Mar-07 8:26
KainPlan3-Mar-07 8:26 
AnswerRe: System.Drawing.Bitmap byte[] Pin
.armin3-Mar-07 11:16
.armin3-Mar-07 11:16 
GeneralRe: System.Drawing.Bitmap byte[] Pin
KainPlan3-Mar-07 14:33
KainPlan3-Mar-07 14:33 
GeneralRe: System.Drawing.Bitmap byte[] Pin
KainPlan3-Mar-07 19:37
KainPlan3-Mar-07 19: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.