This method is used to allow access to pixels in the Device Independent Bitmap (DIB). This method is to be used in conjunction with the StartBitmapAccess method.
Public Function EndBitmapAccess(imgNo As Integer) As Boolean
public bool EndBitmapAccess(int imgNo);
Parameters
imgNo
The image number (from -1 to 99)
Return Value
Returns True if successful. Returns False if unsuccessful.
Explanation
The EndBitmapAccess method is to be used in conjunction with the StartBitmapAccess method. To execute the EndBitmapAccess method, set the image handle of the image in the SourceImage property. The EndBitmapAccess method supports 1, 4, 8, 16, 24, and 32 bit images.
To access the bitmap 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).
[Visual Basic] Dim IkEffect As Newtone.ImageKit.WPF.Effect Dim Ret As Boolean Dim i As Long, j As Long Dim PalNo As Integer, Red As Integer, Green As Integer, Blue As Integer IkEffect = New Newtone.ImageKit.WPF.Effect If IkEffect.SourceImage = Nothing Then Exit Sub Ret = IkEffect.StartBitmapAccess(0) If Ret = False Then Exit Sub
For i = 0 To IkEffect.SourceImage.Height - 1 For j = 0 To IkEffect.SourceImage.Width - 1 Ret = IkEffect.GetBitmapPixel(0, j, i, PalNo, Red, Green, Blue) If Image.GetPixelFormatSize(IkEffect.SourceImage.PixelFormat) = 1 Then If PalNo <> 0 Then PalNo = 0 Else PalNo = 1 End If Else If Image.GetPixelFormatSize(IkEffect.SourceImage.PixelFormat) > 8 Then Blue = 255 - Blue Green = 255 - Green Red = 255 - Red End If Ret = IkEffect.SetBitmapPixel(0, j, i, PalNo, Red, Green, Blue) Next j Next i Ret = IkEffect.EndBitmapAccess(0)