Leadtools.CF Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.6.15
GetPixelData Method
See Also 
Leadtools Namespace > RasterImage Class : GetPixelData Method



row
The row number of the pixel.
column
The column number of the pixel
row
The row number of the pixel.
column
The column number of the pixel
Returns the pixel data of the specified pixel.

Syntax

Visual Basic (Declaration) 
Public Overridable Function GetPixelData( _
   ByVal row As Integer, _
   ByVal column As Integer _
) As Byte()
Visual Basic (Usage)Copy Code
Dim instance As RasterImage
Dim row As Integer
Dim column As Integer
Dim value() As Byte
 
value = instance.GetPixelData(row, column)
C# 
public virtual byte[] GetPixelData( 
   int row,
   int column
)
C++/CLI 
public:
virtual array<byte>^ GetPixelData( 
   int row,
   int column
) 

Parameters

row
The row number of the pixel.
column
The column number of the pixel

Return Value

This method returns a byte array which may represent an index into this RasterImage palette, a grayscale value or red, green, and blue color values.

Remarks

This method should be called only for 8, 16, 24, 32, 48 and 64-bit images. It works as follows:

  • For 8-bit images, this method will retrieve the palette index for the specified pixel.
  • For 16-bit images, this method will retrieve the 2-byte value that forms the pixel.
    • For color 16-bit images, the data contains packed 5-bit R, G and B values. The high bit contains the alpha information.
      The RasterImage.Order determines whether the data is RGB or BGR.
  • For 24-bit images, this method will retrieve the 3 bytes containing the pixel color. The RasterImage.Order determines whether the data is RGB or BGR.
  • For 32-bit images, this method will retrieve the 4 bytes containing the pixel color and alpha information. The first 3 bytes contain the pixel color. The The RasterImage.Order determines whether the data in the first 3 bytes is RGB or BGR. The 4th byte is the alpha channel information.
  • For 48-bit images, this method will retrieve the 6 bytes containing the pixel color. The RasterImage.Order determines whether the data is RGB or BGR. Each color component is stored as a 16-bit value, where 0 corresponds to black and 0xFFFF corresponds to full white.
  • For 64-bit images, this method will retrieve the 8 bytes containing the pixel color and alpha information. The RasterImage.Order determines whether the data in the first 6 bytes is RGB or BGR. Each color component is stored as a 16-bit value, where 0 corresponds to black and 0xFFFF corresponds to full white. The last two bytes contain the alpha information (also stored as a short value).

The minimum size of the returned byte array is calculated:

(BitsPerPixel + 7) / 8

You can use the SetPixelData method to assign the returned value to another pixel.

This method uses image coordinates to specify the pixel. Therefore, you must account for the view perspective of the image. If you specify a pixel that is outside the image or outside the region (if the image has one), this method throws an exception.

For more information, refer to Introduction to Image Processing With LEADTOOLS.

Requirements

Target Platforms: Microsoft .NET CF Framework 2.0, Windows Mobile 5 PocketPC, Windows Mobile 5 Smartphone, Windows Mobile 6

See Also