Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.3.5
GetRowColumn(Int32,Int32,IntPtr,Int32) Method
See Also 
Leadtools Namespace > RasterImage Class > GetRowColumn Method : GetRowColumn(Int32,Int32,IntPtr,Int32) Method




row
The number of the row to retrieve. The first row is 0, and the last row is 1 less than the image height.
column
The column offset within the row to retrieve. The first column offset is 0, and the last column offset is 1 less than the image width
buffer
Pointer to an unmanaged buffer to hold the image data that this method gets. The buffer will be filled with uncompressed data.
bufferCount

The number of bytes to retrieve. Consider the bits per pixel, and avoid specifying a number that goes past the end of the row.

For a 1-bit image, each byte represents 8 pixels. For a 4-bit image, each byte represents 2 pixels. For an 8-bit image, each byte represents 1 pixel. For a 16-bit image, every 2 bytes represents one pixel. For 24-bit images, every three bytes represents one pixel. For a 32-bit image, every four bytes represents one pixel. For 48-bit images, every six bytes represents one pixel. For 64-bit images, every eight bytes represents one pixel.

You can use the image BitsPerPixel property with integer math to calculate the number of bytes needed for a particular number of pixels. For example


NumberOfBytes = (Image.BitsPerPixel * NumberOfPixels) / 8;
if((Image.BitsPerPixel * NumberOfPixels) % 8)
   NumberOfBytes = NumberOfBytes + 1; // Round up if necessary for a 1- or 4-bit image

Accepts a column offset to retrieve data from an image and place it in an ummanaged memory buffer.

Syntax

Visual Basic (Declaration) 
Public Overloads Function GetRowColumn( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   ByVal buffer As IntPtr, _
   ByVal bufferCount As Integer _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As RasterImage
Dim row As Integer
Dim column As Integer
Dim buffer As IntPtr
Dim bufferCount As Integer
Dim value As Integer
 
value = instance.GetRowColumn(row, column, buffer, bufferCount)
C# 
public int GetRowColumn( 
   int row,
   int column,
   IntPtr buffer,
   int bufferCount
)
Managed Extensions for C++ 
public: int GetRowColumn( 
   int row,
   int column,
   IntPtr buffer,
   int bufferCount
) 
C++/CLI 
public:
int GetRowColumn( 
   int row,
   int column,
   IntPtr buffer,
   int bufferCount
) 

Parameters

row
The number of the row to retrieve. The first row is 0, and the last row is 1 less than the image height.
column
The column offset within the row to retrieve. The first column offset is 0, and the last column offset is 1 less than the image width
buffer
Pointer to an unmanaged buffer to hold the image data that this method gets. The buffer will be filled with uncompressed data.
bufferCount

The number of bytes to retrieve. Consider the bits per pixel, and avoid specifying a number that goes past the end of the row.

For a 1-bit image, each byte represents 8 pixels. For a 4-bit image, each byte represents 2 pixels. For an 8-bit image, each byte represents 1 pixel. For a 16-bit image, every 2 bytes represents one pixel. For 24-bit images, every three bytes represents one pixel. For a 32-bit image, every four bytes represents one pixel. For 48-bit images, every six bytes represents one pixel. For 64-bit images, every eight bytes represents one pixel.

You can use the image BitsPerPixel property with integer math to calculate the number of bytes needed for a particular number of pixels. For example


NumberOfBytes = (Image.BitsPerPixel * NumberOfPixels) / 8;
if((Image.BitsPerPixel * NumberOfPixels) % 8)
   NumberOfBytes = NumberOfBytes + 1; // Round up if necessary for a 1- or 4-bit image

Return Value

The number of bytes copied.

Example

This example is designed to work with images that have a bottom-left or top-left view perspective. This example uses GetRowColumn and SetRowColumn to invert the colors of a rectangle in the upper left part of the displayed image.

Remarks

By using this low-level method to get any part of a row, you can write a procedure that accesses a single pixel or a rectangular area within the image.

This method accepts an offset parameter (column) in pixels and a length (bufferCount) in bytes. Therefore, you must consider the bits per pixel of the image when specifying these parameters. The following table describes the rules:

Bits Per Pixel Column Offset (in Pixels) Bytes to Get
1 Must be a multiple of 8 (such as 0, 8, or 16). Can be any number up to the end of the row. Consider that there are 8 pixels per byte.
4 Must be an even number (such as 0, 2, or 4). Can be any number up to the end of the row. Consider that there are 2 pixels per byte.
8 Can be any column within the image. Can be any number up to the end of the row. Consider that there is 1 pixel per byte.
16 Can be any column within the image. Must be a multiple of 2 (such as 2, 4, or 6), because there are 2 bytes per pixel.
24 Can be any column within the image. Must be a multiple of 3 (such as 3, 6, or 9), because there are 3 bytes per pixel.
32 Can be any column within the image. Must be a multiple of 4 (such as 4, 8, or 12), because there are 4 bytes per pixel.

The image memory must be locked when you use this method. Normally, you can call Access to lock the memory before starting an operation that uses this method, then call Release when the operation is finished.

Color order is determined by the Order property of the RasterImage object. This value can be RasterByteOrder.Rgb, RasterByteOrder.Bgr, or RasterByteOrder.Romm.

RasterByteOrder.Gray is only valid for 12 and 16-bit grayscale images. Support for 12 and 16-bit grayscale images is only available in the Document/Medical Imaging editions.

For more information, refer to Processing an Image.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also