Adjusting Brightness and Contrast in Visual Basic using csXImage

Brightness

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 VB 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 VB adjust photograph brightness

Brightened image

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

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

Visual Basic image colour adjustment

Original image

Apply tint to image in Visual Basic

Tinted image

This is equivalent to the following lines of VB 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.

ImageBox1.ColorFormat = cf256Color
ImageBox1.Brightness 70, TRUE, FALSE, TRUE

Sharpen

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

Sharpened image

This is achieved with the very simple line of code:

ImageBox1.Sharpen

<<Previous page  Next page>>