Parameters
Name | Explanation |
---|---|
hDib | The raster image memory handle (supports 1, 4, 8, 16. 24, and 32 bit images) |
DibNo | The parameter that retrieves the identification number of the hDIB |
Return Value
Returns True (nonzero) if successful, otherwise returns False (0).
Explanation
The StartDibAccess method is used to allow access to
pixels in the Device Independent Bitmap (DIB). This method is to be
used in conjunction with the EndDibAccess method. The DibNo is the
identification number of the hDib used by the GetDibPixel, SetDibPixel, and EndDibAccess methods.
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
ImageKit1.LayerNo = -1
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