The ImageKit10 allows you to process image effects in a variety
of useful ways. One of the most useful ways to involves the use of
a mask image. A mask image is simply a black and white image. When
a mask image is layered on the original image, the mask determines
what portion of the original image will be processed. When using
the ImageKit.Effect methods (or the IKEffect.dll user functions),
an image and mask image are created. Below are a few examples of
how to process image effects with both the ImageKit10 ActiveX and
ImageKit10 DLL versions:
Selecting images (SelectImage)
In the ImageKit10, there are three ways in which images or portions
of images can be selected for processing:
1 - selecting the total image
2 - selecting a polygon
3 - selecting an ellipse
In all cases, the image and the mask image are generated and, when
using the ImageKit10 ActiveX controls, the results are returned in
the ImageHandle
property or the
ImageKit.Layer(LayerNo).ImageHandle property. (When the
ImageKit10 Dll functions are used, the results are returned in the
IKSELECT_IMAGE structure).
Below is a brief explanation about each of these and the images and
mask images that they generate.
* When you select the whole image, an all white mask image is
generated. If the mask image is not needed, please free it it.
[VB Example (OCX)]
ImageKit1.LayerNo =
-1 'process the base
image
ImageKit1.ImageHandle =
ImgHandle 'set the
image
ImageKit1.Effect.MaskImageHandle =
0 'free the mask image
handle
ImageKit1.Effect.SelectMode =
ikEffectAll 'process
the whole image
Ret =
ImageKit1.Effect.SelectImage(x(0),y(0),0,255,0,0) 'execute
the SelectImage method
[VB Example (DLL)]
' the following function
creates the image and the mask image
DstHandle =
IKSelectImage(ImgHandle, 1, pt(0), 0, Rect, TRUE, 0, 0, 255, 0,
"Select", "Select", "Cancel")
IKFreeMemory(ImgHandle) ' Deletes the input image
handle.
Note: If the input image handle is not deleted, the image will
remain in the memory.
Selecting a polygonal area in the image (SelectMode = 2)
Polygons can be selected by passing the coordinate points of the
polygon as the arguments. The size of the output image and mask
image is the size of the smallest rectangle that can circumscribe
the polygon.
[VB Example (OCX)]
Dim x(0 To 2) As Long, y(0 To
2) As Long
x(0) = 90: y(0) =
60 'Sets the
coordinates of the points of the polygon
x(1) = 560: y(1) =
100
x(2) = 410: y(2) =
390
ImageKit1.LayerNo =
-1 'process the base
image
ImageKit1.ImageHandle =
ImgHandle 'set the
image
ImageKit1.Effect.MaskImageHandle =
0 'free the mask image
handle
ImageKit1.Effect.InOut =
ikInside 'process
inside the polygon
ImageKit1.Effect.SelectMode =
ikEffectPolygon 'process the polygonal area on the
image
Ret =
ImageKit1.Effect.SelectImage(x(0),y(0),3,255,0,0)
'execute SelectImage
method
[VB Example (DLL)]
Dim Pt(0 To 2) As
IKPOINT
Pt(0).x = 90: Pt(0).y =
60 ' Sets the
coordinates of the points of the polygon
Pt(1).x = 560: Pt(1).y =
100
Pt(2).x = 410: Pt(2).y =
390
' the following function
creates the image and the mask image
DstHandle =
IKSelectImage(ImgHandle, 2, pt(0), 3, Rect, True, 0, 0, 255, 0,
"Select", "Select", "Cancel")
IKFreeMemory(ImgHandle)
' Deletes the effect control
input image handle
ImgHandle = 0
Note: If the input image handle is not deleted, the image will
remain in the memory.
Selecting an elliptical area in the image (SelectMode =
3)
An ellipse can be selected by setting the location of the
coordinate points for the bounding rectangle in the RectLeft,
RectTop, RectBottom, and RectRight properties (when using the
ImageKit10 ActiveX controls) or by setting these coordinates in the
RECT structure (when using the DLL functions). The size of the
output image and mask image is the size of the smallest bounding
rectangle that circumscribes the ellipse.
[VB Example (OCX)]
ImageKit1.Effect.RectLeft =
100
ImageKit1.Effect.RectTop = 50
ImageKit1.Effect.RectRight = 540
ImageKit1.Effect.RectBottom = 400
ImageKit1.LayerNo = -1
ImageKit1.ImageHandle = ImgHandle
ImageKit1.Effect.MaskImageHandle = 0
ImageKit1.Effect.InOut = ikInside
ImageKit1.Effect.SelectMode = ikEffectEllipse
Ret =
ImageKit1.Effect.SelectImage(x(0),y(0),0,255,0,0)
[VB Example (DLL)]
Dim Rect As
IKRECT
Rect.Left = 100: Rect.Top
= 50
Rect.Right =
540: RectBottom = 400
DstHandle =
IKSelectImage(ImgHandle, 3, pt(0), 0, Rect, True,255, 0, 0, 0,
"Select", "Select", "Cancel")
IKFreeMemory(ImgHandle)
ImgHandle = 0
Embossing images (Emboss)
In the following, we have choosen to use the Emboss method as an
example of applying an effect.
Using an existing mask image (SelectMode = 0)
By setting the SelectMode to 0, an existing mask image can be used
to determine the area on the original image that will be processed.
The input mask image, input image, and the output image are shown
below. The ImgHandle can refer to an image that is 1, 4, 8, 16, 24,
or 32 bit color, however for the Emboss method, the input image
must be 8G, 16, 24, or 32 bit. The MskHandle refers to a black and
white 1 bit color image, where the white portion of the mask
determines the area on the image that will be processed and the
black portion determines the area that will be masked.
[VB Example (OCX)]
ImageKit1.LayerNo = -1
ImageKit1.ImageHandle = ImgHandle
ImageKit1.Effect.MaskImageHandle = MskHandle
ImageKit1.Effect.SelectMode = ikEffectMask
Ret =
ImageKit1.Effect.Emboss(x(0),y(0),0,0,3,128)
[VB Example (DLL)]
Dim Src As IKSELECT_IMAGE
Src.hImgBmh = ImgHandle
Src.hMskBmh = MskHandle
' executes the Emboss
function
DstHandle = IKEmboss(Src, 0,
pt(0), 0, Rect, True, 0, 3, 128, 0, "Emboss", " Emboss ",
"Cancel")
IKFreeMemory(ImgHandle) ' Deletes the input image handle and input mask
handle
IKFreeMemory(MskHandle) ' If these are not deleted they will remain in the
memory.
ImgHandle = 0
MskHandle = 0
[VB Example (OCX)]
ImageKit1.LayerNo = -1
ImageKit1.ImageHandle = ImgHandle
ImageKit1.Effect.MaskImageHandle = 0
ImageKit1.Effect.SelectMode =
ikEffectAll
Ret =
ImageKit1.Effect.Emboss(x(0),y(0),0,0,3,128)
[VB Example (DLL)]
Dim Src As IKSELECT_IMAGE
Src.hImgBmh = ImgHandle
Src.hMskBmh = 0
' executes the Emboss
function
DstHandle = IKEmboss(Src, 1,
pt(0), 0, Rect, True, 0, 3, 128, 0, "Emboss", "Emboss",
"Cancel")
IKFreeMemory(ImgHandle) ' Deletes the input image handle. If not freed the
image data will remain in the memory.
ImgHandle = 0
*Note: When the InOut property is TRUE, the area inside the polygon
is embossed. When the InOut property is False, the area outside the
polygon is processed.
[VB Example (OCX)]
Dim x(0 To 2) As Long, y(0 To
2) As Long
x(0) = 90: y(0) =
60 ' Sets the coordinates of the
points of the polygon
x(1) = 560: y(1) =
100
x(2) = 410: y(2) =
390
ImageKit1.LayerNo = -1
ImageKit1.ImageHandle = ImgHandle
ImageKit1.Effect.MaskImageHandle = 0
ImageKit1.Effect.InOut = ikInside
ImageKit1.Effect.SelectMode =
ikEffectPolygon
Ret =
ImageKit1.Effect.Emboss(x(0),y(0),3,0,3,128)
[VB Example (DLL)]
Dim Src As
IKSELECT_IMAGE
Dim Pt(0 To 2) As
IKPOINT
Pt(0).x = 90: Pt(0).y =
60
Pt(1).x = 560: Pt(1).y =
100
Pt(2).x = 410: Pt(2).y =
390
Src.hImgBmh =
ImgHandle ' Sets the image into the
input image handle
Src.hMskBmh = 0
' Executes the Emboss
function
DstHandle = IKEmboss(Src, 2,
pt(0), 0, Rect, True, 0, 3, 128, 0, "Emboss", "Emboss",
"Cancel")
IKFreeMemory(ImgHandle) ' Deletes the input image handle.
*Note: When the InOut property is TRUE, the area inside the ellipse
is embossed. When the InOut property is False, the area outside the
ellipse is processed.
[VB Example (OCX)]
ImageKit1.Effect.RectLeft =
100
ImageKit1.Effect.RectTop = 50
ImageKit1.Effect.RectRight = 540
ImageKit1.Effect.RectBottom = 400
ImageKit1.LayerNo = -1
ImageKit1.ImageHandle = ImgHandle
ImageKit1.Effect.MaskImageHandle = 0
ImageKit1.Effect.InOut = ikInside
ImageKit1.Effect.SelectMode = ikEffectEllipse
Ret =
ImageKit1.Effect.Emboss(x(0),y(0),0,0,3,128)
[VB Example (DLL)]
Dim Src As
IKSELECT_IMAGE
Dim Rect As IKRECT
Rect.Left = 100: Rect.Top =
50
Rect.Right = 540:Rect.Bottom =
400
Src.hImgBmh =
ImgHandle ' Sets the image into the
input image handle
Src.hMskBmh = 0
' Executes the Emboss
function
DstHandle = IKEmboss(Src, 3,
pt(0), 0, Rect, True, 0, 3, 128, 0, "Emboss", "Emboss",
"Cancel")
IKFreeMemory(ImgHandle) ' Deletes the input image handle
* Note: The Emboss method, like many other Effect methods and
IKEffect dll user functions, takes an image handle and a mask image
handle as input and returns an image handle as output. Below is a
list of other methods and dll functions that are used in the same
way.
Method Name (OCX) | Function Name (DLL) | Explanation |
---|---|---|
AntiAlias | IKAntiAlias | Smooths the edges in the image. |
Blur | IKBlur | Blurs the image |
Canvas | IKCanvas | Creates a canvas effect on the image |
Chroma | IKChroma | Adjusts chrominance |
CustomFilter | IKCustomFilter | Creates a user defined custom filter |
GlassTile | IKGlassTile | Creates a glass tile effect on the image |
Lens | IKLens | Creates a lens effect on the image |
Mosaic | IKMosaic | Creates a mosaic on the image |
MotionBlur | IKMotionBlur | Blurs the image as if it were in motion |
OilPaint | IKOilPaint | Creates an oil painting like effect on the image |
Outline | IKOutline | Creates an outline of the image |
RemoveNoise | IKRemoveNoise | Reduces noise in the image |
RGBGamma | IKRGBGamma | Adjusts image RGB values using gamma correction |
RGBLevel | IKRGBLevel | Increase or decreases image RGB values |
RGBRev | IKRGBRev | Reverses image RGB values |
RGBSpline | IKRGBSpline | Adjusts image RGB values using spline interpolation |
Ripple | IKRipple | Creates a ripple effect on the image |
Sharp | IKSharp | Sharpens contours |
UnifyColor | IKUnifyColor | Converts all colors within a certain range into one color |
Waves | IKWaves | Creates a wave like effect on the image |
WhirlPinch | IKWhirlPinch | An effect like pinching the image and twisting your fingers |
YCCGamma | IKYCCGamma | Adjusts image YCrCb values using gamma correction |
YCCLevel | IKYCCLevel | Increase or decreases image YCrCb values |
YCCRev | IKYCCRev | Reverses image YCrCb values |
YCCSpline | IKYCCSpline | Adjusts image YCrCb values using spline interpolation |
Pasting Images (PasteImage)
The PasteImage method (IKPasteImage function) allows you to use masks to select a portion of an image and paste this into another image. This technique shown below, involves using the MskHandle and ImgHandle then pasting those into SrcHandle. The result can be seen in the DstHandle.

[VB Example (OCX)]
ImageKit1.LayerNo = -1
ImageKit1.ImageHandle = ImgHandle
ImageKit1.Effect.MaskImageHandle = MskHandle
Ret = ImageKit1.Effect.PasteImage(SrcHandle,0,False,False,255,False,0,0,0,255,255,255,192,144,False)
If Ret = False Then Exit Sub
ImageKit1.FreeMemory(SrcHandle)
SrcHandle = 0
[VB Example (DLL)]
Dim Src As IKSELECT_IMAGE
Src.hImgBmh = ImgHandle
Src.hMskBmh = MskHandle
DstHandle = IKPasteImage(SrcHandle, Src, 0, 0, 0, 255, 0, 0, 0, 0, 255, 255, 255 192, 144, 0, 0, "Paste", "Paste", "Cancel")
IKFreeMemory(SrcHandle)
IKFreeMemory(Src.hImgBmh)
IKFreeMemory(Src.hMskBmh)
SrcHandle = 0
Src.hImgBmh = 0
Src.hMskBmh = 0
Layering Images (LayerImage)
The LayerImage method (IKLayer) is another way two images are combined. This technique involves setting a specific color to transparent and layering two images.

[VB Example (OCX)]
ImageKit1.LayerNo = -1
Ret = ImageKit1.Effect.LayerImage(ImgHandle1, ImgHandle2,255,True,0,0,0,255,255,255,0,0,False)
If Ret = False Then Exit Sub
ImageKit1.FreeMemory(ImgHandle1)
ImgHandle1 = 0
ImageKit1.FreeMemory(ImgHandle2)
ImgHandle2 = 0
[VB Example (DLL)]
Dim DstHandle As Long
DstHandle = IKLayer(ImgHandle1, ImgHandle2, 255, True, 0, 0, 0, 255, 255, 255, 0, 0, False, 0, "Layer", "Layer", "Cancel"); ' Executes the layer function
IKFreeMemory(ImgHandle1)
IKFreeMemory(ImgHandle2)
ImgHandle1 = 0
ImgHandle2 = 0
Resizing Images (Resize)
When using the Resize method (or IKResize) both images and mask image are resized together

[VB Example (OCX)]
ImageKit1.LayerNo = -1
ImageKit1.ImageHandle = ImgHandle
ImageKit1.Effect.MaskImageHandle = MskHandle
Ret = ImageKit1.Effect.Resize(179, 134, 1)
[VB Example (DLL)]
Dim Src As IKSELECT_IMAGE
Dim Dst As IKSELECT_IMAGE
Src.hImgBmh = InImgHandle
Src.hMskBmh = InMskHandle
Dst = IKResize(Src, 179, 134, 1, 0, "Reduction", "Reduction", "Cancel")
IKFreeMemory(InImgHandle)
IKFreeMemory(InMskHandle)
InImgHandle = 0
InMskHandle = 0
*Note: The Resize method (IKResize function) takes an image and mask image as input and returns an image and mask image as output. The following methods (dll functions) are used in the same way.
Method Name (OCX) | Function Name (DLL) | Explanation |
---|---|---|
Rotation | IKRotation | Rotates an image and mask image |