Adjusting Brightness and Contrast in C# using csXImage


The Brightness method in csXImage provides the ability to increase or decrease the brightness of images, either as an overall adjustment, or acting on the individual red, green and blue colours in the image.

The first example below shows an image that has been increased in brightness overall. This was done using the C# demo application. A value of 60 was used for the brightness, giving a slight increase. Red, green and blue were all checked to give the overall effect.

ActiveX control to adjust image brightness

Original image

ActiveX C# adjust photograph brightness

Brightened image

This is equivalent to using the following line of C# code directly:

axImageBox1.Brightness(65, true, true, true);

A second example shows how an image can be tinted with a specific colour by using the brightness method acting on only one or two of the colour channels. Here, a greyscale image is brightened using only red and blue, with green unchanged.

C# image colour adjustment

Original image

Apply tint to image in C#

Tinted image

This is equivalent to the following lines of C# code. Note the need to change the colour format before using the brightness method. This is because the original image is in a greyscale format which does not allow colours other than greyscale ones to be introduced into the image.

axImageBox1.ColorFormat = csXImageTrial.TxColorFormat.cf24bit;
axImageBox1.Brightness(70, true, false, true);


Images which are slightly blurred can be sharpened using the 'Sharpen' or 'SharpenBy' methods. These give the same effect, the only difference being that 'SharpenBy' gives an option to the user to define the amount of sharpening to be done. 'Sharpen' uses a default for this parameter.

In the C# demo, the Sharpen option uses the default settings. Using the same image as above, the effect of the 'Sharpen' method is shown below.

ActiveX image sharpen

Original image

ActiveX control to apply sharpness in C#

Sharpened image

This is achieved with the very simple line of code:


<<Previous page  Next page>>