Leadtools Namespace > RasterImageResize Class > ResizeBuffer Method : ResizeBuffer(Int32,Int32,IntPtr,Int64) Method |
The number of bytes to retrieve. Consider the BitsPerPixel, and avoid specifying a number that goes past the end of the row.
You can use the 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; // Round up if necessary for a 1- or 4-bit image
'Declaration Public Overloads Sub ResizeBuffer( _ ByVal row As Integer, _ ByVal column As Integer, _ ByVal buffer As IntPtr, _ ByVal bytes As Long _ )
'Usage Dim instance As RasterImageResize Dim row As Integer Dim column As Integer Dim buffer As IntPtr Dim bytes As Long instance.ResizeBuffer(row, column, buffer, bytes)
The number of bytes to retrieve. Consider the BitsPerPixel, and avoid specifying a number that goes past the end of the row.
You can use the 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; // Round up if necessary for a 1- or 4-bit image
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 (bytes) in bytes. Therefore, you must consider the BitsPerPixel of the image when specifying these parameters. The following table describes the rules:
BitsPerPixel | 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. |
48 | Can be any column within the image. | Must be a multiple of 6 (such as 6, 12, or 18), because there are 6 bytes per pixel. |
64 | Can be any column within the image. | Must be a multiple of 8 (such as 8, 16, or 24), because there are 8 bytes per pixel. |
Do not pass a value in bytes that goes past the end of the row. The process is faster when rows are retrieved sequentially, either top-down or bottom-up.
For more information, refer to Introduction to Image Processing With LEADTOOLS.