Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_GetResizedRowCol
#include "l_bitmap.h"
L_LTKRN_API L_INT32 L_GetResizedRowCol(pResizeData, pBuffer, nRow, nCol, uBytes)
L_VOID* pResizeData; |
/* pointer to the bitmap handle */ |
L_UCHAR *pBuffer; |
/* pointer to the target buffer */ |
L_INT nRow; |
/* number of the row to retrieve */ |
L_INT nCol; |
/* column offset within the row to retrieve */ |
L_SIZE_T uBytes; |
/* number of bytes to retrieve */ |
Retrieves resized data, one line at a time.
Parameter |
Description |
pResizeData |
Pointer to the resizing process. This is obtained from L_StartResizeBitmap. |
pBuffer |
Pointer to the buffer to hold the image data that this function gets. You must allocate the buffer before calling this function, and the buffer must be large enough to hold the image data. |
nRow |
The number of the row to retrieve. The first row is 0, and the last row is 1 less than the bitmap height. |
nCol |
The column offset within the row to retrieve. The first column offset is 0, and the last column offset is 1 less than the bitmap width. |
uBytes |
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 bitmap, each byte represents 8 pixels. For a 4-bit bitmap, each byte represents 2 pixels. For an 8-bit bitmap, each byte represents 1 pixel. For a 16-bit bitmap, every 2 bytes represents one pixel. For 24-bit images, every three bytes represents one pixel. For a 32-bit bitmap, 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 bitmap handle's BitsPerPixel field with integer math to calculate the number of bytes needed for a particular number of pixels. For example: |
|
NumberOfBytes = (Bitmap.BitsPerPixel * NumberOfPixels) / 8; |
|
if ((Bitmap.BitsPerPixel * NumberOfPixels) % 8) |
|
++NumberOfBytes; /* Round up if necessary for a 1- or 4-bit image */ |
Returns
>=1 |
The number of bytes gotten. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
By using this low-level function to get any part of a row, you can write a procedure that accesses a single pixel or a rectangular area within the bitmap.
This function accepts an offset parameter (nCol) in pixels and a length (uBytes) in bytes. Therefore, you must consider the bits per pixel of the bitmap when specifying these parameters. The following table describes the rules:
Bits Per |
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 bitmap. |
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 bitmap. |
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 bitmap. |
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 bitmap. |
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 bitmap. |
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 bitmap. |
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 uBytes that goes past the end of the row.
The process is faster when rows are retrieved sequentially, either top-down or bottom-up.
Required DLLs and Libraries
LTKRN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Windows 2000 / XP/Vista, Windows CE.
See Also
Functions: |
Example
For an example, refer to L_StartResizeBitmap.