The StartBitmapAccess method is used to allow access to pixels in the Device Independent Bitmap (DIB). This method is to be used in conjunction with the EndBitmapAccess method.
Parameters
None
Return Value
Returns True if successful. Returns False if unsuccessful.
Explanation
The StartBitmapAccess method is used to allow access to pixels in the Device Independent Bitmap (DIB). This method is to be used in conjunction with the EndBitmapAccess method.
To execute the StartBitmapAccess method, set the image handle of the image in the Image property or the Layer(LayerNumber).Image property. This method supports 1, 4, 8, 16, 24, and 32 bit images.
To access the DIB and manipulate pixel data, you must use the following methods as a group:
StartBitmapAccess
|
GetBitmapPixel, SetBitmapPixel
|
EndBitmapAccess
Example
The following code starts access to the DIB, then loops through each pixel in the image, using the GetBitmapPixel method to retrieve the pixels' rgb values. Then those values are reversed and set using the SetBitmapPixel method (For 1, 16, 24, or 32 bit images).
Dim Ret As Boolean
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.StartBitmapAccess()
If Ret = False Then Exit Sub
For i = 0 To ImageKit1.Image.Height - 1
For j = 0 To ImageKit1.Image.Width - 1
Ret = ImageKit1.Effect.GetBitmapPixel(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.SetBitmapPixel(j, i, PalNo, Red, Green, Blue)
Next j
Next i
Ret = ImageKit1.Effect.EndBitmapAccess()
ImageKit1.Refresh()