This method sets the RGB value and the palette number of a specified pixel in the Device Independent Bitmap (DIB)

[Visual Basic]   [ Boolean = ]imagekitcontrolname.Effect.SetDibPixel(DibNo As Integer, x As Long, y As Long, PalNo As Integer, Red As Integer, Green As Integer, Blue As Integer)
[Visual C++]     [ BOOL = ]imagekitcontrolname.GetEffect().SetDibPixel(short DibNo, long x, long y, short PalNo, short Red, short Green, short Blue)
[VB.NET]   [ Boolean = ]imagekitcontrolname.Effect.SetDibPixel(DibNo As Short, x As Integer, y As Integer, PalNo As Short, Red As Short, Green As Short, Blue As Short)
[C#.NET]   [ bool = ]imagekitcontrolname.Effect.SetDibPixel(short DibNo, int x, int y, short PalNo, short Red, short Green, short Blue)

Parameters

Name Explanation
DibNo The identification number of the DIB as retrieved from the StartDibAccess method.
x, y The x,y coordinates of the specified pixel
PalNo The palette number of the specified pixel
Red The red component of the RGB value of the specified pixel
Green The green component of the RGB value of the specified pixel
Blue The blue component of the RGB value of the specified pixel

Return Value

Returns True (nonzero) if successful, otherwise returns False (0).

Explanation

The SetDibPixel method sets the RGB values and palette number of the specified pixel in the Device Independent Bitmap (DIB). The DibNo parameter value must be the same as that retrieved from the StartDibAccess method. For 1, 4, and 8 bit images, the applicable values are set in the PalNo parameter. For 16, 24, and 32 bit images, the applicable values are set in the Red, Green, and Blue parameters

To access the DIB and manipulate pixel data, you must use the following methods as a group:
StartDibAccess
      |
GetDibPixel, SetDibPixel
      |
EndDibAccess

Note: If you want to access the DIB it is highly recommended that you use the ImageKit DLL functions. They are much faster than the ImageKit OCX controls at accessing the DIB. However, since you can also use the OCX controls to access the DIB, the explanation is included.

Sample Code
The following code starts access to the DIB, then loops through each pixel in the image, using the GetDibPixel method to retrieve the pixels' rgb values. Then those values are reversed and set using the SetDibPixel method. (For 1, 16, 24, or 32 bit images)

Visual Basic

   Dim Ret As Boolean
   Dim DibNo As Integer
   Dim i As Long, j As Long
   Dim PalNo As Integer, Red As Integer, Green As Integer, Blue As Integer

   Ret = ImageKit1.GetImageType
   If Ret = False Then Exit Sub
   Ret = ImageKit1.Effect.StartDibAccess(ImageKit1.ImageHandle, DibNo)
   If Ret = False Then Exit Sub

   For i = 0 To ImageKit1.ImageHeight - 1
      For j = 0 To ImageKit1.ImageWidth - 1
         Ret = ImageKit1.Effect.GetDibPixel(DibNo, j, i, PalNo, Red, Green, Blue)
         If ImageKit1.BitCount = 1 Then
            If PalNo <> 0 Then
               PalNo = 0
            Else
               PalNo = 1
            End If
         Else If ImageKit1.BitCount > 8 Then
            Blue = 255 - Blue
            Green = 255 - Green
            Red = 255 - Red
         End If
         Ret = ImageKit1.Effect.SetDibPixel(DibNo, j, i, PalNo, Red, Green, Blue)
      Next j
   Next i
   Ret = ImageKit1.Effect.EndDibAccess(DibNo)
   ImageKit1.Refresh

The ImageKit10 ActiveX is a product created by Newtone Corporation