GdPicture.NET Reference Guide
SetPixelArrayByte Method (GdPictureImaging)
Example 





GdPicture14 Namespace > GdPictureImaging Class : SetPixelArrayByte Method
GdPicture Image Identifier.
Array of pixel data.
The left destination pixel of the area.
The top destination pixel of the area.
The width of the destination area in pixel.
The height of the destination area in pixel.
Changes the pixel values contained into an area of a GdPicture image from an array which contains each each Blue, Green, Red and Alpha components of pixel.
Syntax
'Declaration
 
Public Function SetPixelArrayByte( _
   ByVal ImageID As Integer, _
   ByVal Data() As Byte, _
   ByVal DstLeft As Integer, _
   ByVal DstTop As Integer, _
   ByVal Width As Integer, _
   ByVal Height As Integer _
) As GdPictureStatus
public GdPictureStatus SetPixelArrayByte( 
   int ImageID,
   byte[] Data,
   int DstLeft,
   int DstTop,
   int Width,
   int Height
)
public function SetPixelArrayByte( 
    ImageID: Integer;
    Data: Bytearray of;
    DstLeft: Integer;
    DstTop: Integer;
    Width: Integer;
    Height: Integer
): GdPictureStatus; 
public function SetPixelArrayByte( 
   ImageID : int,
   Data : byte[],
   DstLeft : int,
   DstTop : int,
   Width : int,
   Height : int
) : GdPictureStatus;
public: GdPictureStatus SetPixelArrayByte( 
   int ImageID,
   byte[]* Data,
   int DstLeft,
   int DstTop,
   int Width,
   int Height
) 

Parameters

ImageID
GdPicture Image Identifier.
Data
Array of pixel data.
DstLeft
The left destination pixel of the area.
DstTop
The top destination pixel of the area.
Width
The width of the destination area in pixel.
Height
The height of the destination area in pixel.

Return Value

A member of the GdPictureStatus enumeration.
Remarks

The method automatically converts all images PixelFormat to PixelFormat.Format32bppArgb.

Example
Usage of GetPixelArrayByte() and SetPixelArrayByte() methods to apply negative effect on a GdPicture image
Dim oGdPictureImaging As New GdPictureImaging
Dim arPixel() As Byte
Dim X As Integer
Dim Y As Integer
Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("image.tif")
Dim ImageHeight As Integer = oGdPictureImaging.GetHeight(ImageID)
Dim ImageWidth As Integer = oGdPictureImaging.GetWidth(ImageID)
ReDim arPixel(ImageWidth * ImageHeight * 4)
oGdPictureImaging.GetPixelArrayByte(ImageID, arPixel, 0, 0, ImageWidth, ImageHeight)
For X = 0 To ImageWidth - 1
   For Y = 0 To ImageHeight - 1
      arPixel((Y * 4 * ImageWidth) + X * 4) = Not arPixel((Y * 4 * ImageWidth) + X * 4) 'Blue channel
      arPixel((Y * 4 * ImageWidth) + X * 4 + 1) = Not arPixel((Y * 4 * ImageWidth) + X * 4 + 1) 'Green channel
      arPixel((Y * 4 * ImageWidth) + X * 4 + 2) = Not arPixel((Y * 4 * ImageWidth) + X * 4 + 2) 'Red channel
      arPixel((Y * 4 * ImageWidth) + X * 4 + 3) = 255 'Alpha channel. Set 255 for full opacity
   Next Y
Next X
oGdPictureImaging.SetPixelArrayByte(ImageID, arPixel, 0, 0, ImageWidth, ImageHeight)
oGdPictureImaging.SaveAsTIFF(ImageID, "imageneg.tif", TiffCompression.TiffCompressionAUTO)
oGdPictureImaging.ReleaseGdPictureImage(ImageID)
See Also

Reference

GdPictureImaging Class
GdPictureImaging Members
GetPixelArrayByte Method