ImageEdit
Previous  

The ImageEdit object provides the following methods and properties.


Methods

Brightness(PerCent As Double) : Changes the brightness of the image by adding the PerCent value to all the colour values. PerCent is the value of full scale so adding 100 will turn the entire image white, and adding -100 will turn the entire image black.

Contrast( PerCent As Double) : Changes the contrast of the image by multiplying all the colour values by PerCent.  PerCent is the percentage change to apply to each value so 100 will leave the image unchanged and 0 will turn the entire image black.

Crop(X1 As Int32, Y1 As Int32, X2As Int32, Y2 As Int32) : Crops the image to the rectangle specified by X1,Y1 and X2,Y2. No checks are made so an exception will occur for invalid parameters.

Curve(PerCents() As Double(256), Channel As string) : The colour values are divided into 256 bands and each PerCent is a value by which a band of colour values is multiplied. PerCents(0) is the band at the black end of the spectrum, PerCents(255) is at the white end. Values of 100% leave a colour unchanged. The curve may be applied to a single colour by setting Channel as "R", "G" or "B". "C" or anything else applies the curve to all colours.

Filter(Matrix() As Int32(9), Weight as Int32) : Performs a filter operation on the entire image using the weight and filter parameters supplied. The Matrix parameters flow left to right and then down so Matrix(0) is top left of the matrix, Matrix(2) is top right, Matrix(4) is centre,  Matrix(6) is bottom left and Matrix(8) is bottom right. If bias were required it can be added afterwards using the Brightness method. As is common in image processing practice the outermost ring of pixels round the image are unchanged by the filter operation.

Flip : Flips the image vertically.

GetHistogram(Channel As String) : Returns an array(256) of Int32 representing the histogram of the specified colour channel of the image. "R" for red : "G" for green : "B" for blue : "L" or anything else for the luminance. The histogram is gamma corrected using the gamma specified by SetOpGamma or by 2.2 as the default and so represents the bitmap that would be obtained at this point in the image processing.

GetImage(Channel As String) : Returns the image processed bitmap. This call converts the internal 15 bit representation of the image to a bitmap using the gamma specified by SetOpGamma or by 2.2 as the default. This operation updates the bitmap returned by ControlRef but leaves the internal15 bit representation unchanged. The colour channels returned may be specified as "R", "G" or "B". "L" returns the luminance (grayscale) and "C" or anything else returns the full colour image. Note that in all cases a 24 bit 3 channel colour image is returned even if a single colour is specified

GrayScale: Converts the image to a black and white image. Note that this is not a single 8 bit grayscale image but is still a 24 bit colour image - albeit with all the colour channels containing identical values.

Highest : Returns the highest value, as a percentage of full scale, in any of the images' colour channels. This may be used to check how much contrast or brightness may be added before image information starts to be lost.

Hue(R% As Double, G% As Double, B% As Double) : Multiplies the colour values for each channel by the percentage specified. 100% leaves a channel unchanged.

InvertImage : Inverts all the colour information of the image. i.e. this creates a negative image.

LoadImage(Image As Bitmap) : Takes the supplied 24 (3 x 8) bit colour  bitmap and saves it internally as  linearised 3 x 15 bit values using a default gamma of 2.2. A different input gamma may be specified by SetIpGamma before loading a bitmap if required. This operation updates the bitmap returned by ControlRef.

Lowest: Returns the lowest value, as a percentage of full scale, in any of the images' colour channels. This may be used to check how much contrast or brightness may be added before image information starts to be lost.

Mirror : Flips the image vertically to create a mirror image.

New1: Create an instance of ImageEdit. Must called before trying to use an ImageEdit object. This call sets the default input and output gamma to 2.2. The input gamma may be changed by SetIpGamma before loading an image and the output gamma changed by SetOpGamma before Getting or Saving the image.

RotateLeft : Rotates the image 90 degrees to the left. i.e anti-clockwise.

RotateRight : Rotates the image 90 degrees to the right. i.e. clockwise.

Resize(Width As Int32, Height As Int32) : Resizes the image to the given size. Note that control of aspect ratio is up to the caller. If the supplied parameters imply a different aspect ratio the final image will be distorted to suit.

SaveImage(PathName As String, Channel As String, Format As String) : Saves a file to to the PathName specified in the Format specified. This converts the internal 15 bit representation of the image to a bitmap using the gamma specified by SetOpGamma or by 2.2 as the default and saves it as a file. This operation updates the bitmap returned by ControlRef but leaves the internal15 bit representation unchanged. The colour channels saved may be specified as "R", "G" or "B". "L" saves the luminance (grayscale) and "C" or anything else saves the full colour image. Note that in all cases a 24 bit 3 channel colour image is saved even if a single colour is specified. Note that a file extension is not added and must be specified as part of the PathName. The file formats are"J" for jpg : "B" for bmp : "G" for gif : "P" for png. Anything else  is saved as jpg.

Saturation(PerCent As Double) :  Alters the saturation of the colours of the image by PerCent. 100 leaves colours unchanged, 0 makes an image grayscale.

SetIpGamma(Gamma As Double) : Sets the gamma value used to linearise an image during LoadImage.

SetOpGamma(Gamma As Double) : Sets the gamma value used to delinearise an image during the GetImage or SaveImage methods.

Undo : If undo information is available returns the internal image to that state. Returns true if it could, false if not.

UndoClear : Clears any saved undo information. This may reclaim memory on memory limited devices.

UndoSave : Saves the present image state for a possible future undo. This may allocate a lot memory on a large image. Multiple UndoSaves do not increase the memory used as only a single set of undo information is saved at any one time. The memory may be reclaimed by UndoClear.


Properties

I signifies readable, O signifies settable.


CanUndo : Boolean [I] : Returns true if an undo operation is possible otherwise false.


ControlRef : Image [I] :The internal bitmap used by the library. Note that this bitmap is not updated by image processing functions. It is loaded by LoadImage and updated by the SaveImage method or any of the Get*** methods.

DllVersion : Double [I] : Returns the version number of the library.