This method sets the ARGB value and the palette number of a specified pixel in the Device Independent Bitmap (DIB).
Public Function SetBitmapPixel(imgNo As Integer, x As Integer, y As Integer, palette As Byte, alpha As Byte, red As Byte, green As Byte, blue As Byte) As Boolean
public bool SetBitmapPixel(int imgNo, int x, int y, byte palette, byte alpha, byte red, byte green, byte blue);
Parameters
imgNo
The image number (from -1 to 99)
x,y
The x,y coordinates of the specified
pixel
palette
The palette number of the specified
pixel
alpha
The alpha component of the ARGB value
of the specified pixel
red
The red component of the ARGB value
of the specified pixel
green
The green component of the ARGB value
of the specified pixel
blue
The blue component of the ARGB value
of the specified pixel
Return Value
Returns True if successful. Returns False if unsuccessful.
Explanation
The SetBitmapPixel method sets the ARGB values and palette number of the specified pixel in the Device Independent Bitmap (DIB). For 1, 4, and 8 bit images, the applicable values are set in the Palette parameter. For 16, 24, and 32 bit images, the applicable values are set in the Red, Green, and Blue parameters. The image uses is the image set in theStartBitmapAccess method.
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).
[Visual Basic] 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()