Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
#include "l_bitmap.h"
L_LTIMGCLR_API L_INT L_LineProfile(pBitmap, FirstPoint, SecondPoint, pRed, pGreen, pBlue, uFlags)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
POINT FirstPoint; |
/* starting point of the line */ |
POINT SecondPoint; |
/* end point of the line */ |
L_INT **pRed; |
/* pointer to a pointer */ |
L_INT **pGreen; |
/* pointer to a pointer */ |
L_INT **pBlue; |
/* pointer to a pointer */ |
L_UINT32 uFlags; |
/* flags */ |
Allocates three arrays and updates them with the R, G and B profile for each pixel in the specified line.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle that references the bitmap for which to get the line profile. |
FirstPoint |
POINT structure that contains the starting point for the line. |
SecondPoint |
POINT structure that contains the end point for the line. Information for this point is included in the arrays. |
pRed |
Pointer to a pointer to be updated with an array that contains the red values for the line specified by FirstPoint and SecondPoint. A memory buffer for this array is allocated by the function. When the array is no longer needed, it should be freed by the user by calling the GlobalFreePtr macro. |
pGreen |
Pointer to a pointer to be updated with an array that contains the green values for the line specified by FirstPoint and SecondPoint. A memory buffer for this array is allocated by the function. When the array is no longer needed, it should be freed by the user by calling the GlobalFreePtr macro. |
pBlue |
Pointer to a pointer to be updated with an array that contains the blue values for the line specified by FirstPoint and SecondPoint. A memory buffer for this array is allocated by the function. When the array is no longer needed, it should be freed by the user by calling the GlobalFreePtr macro. |
uFlags |
Reserved for future use. Must be 0. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function supports signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
The range of the returned values will be from 0 - 65535 for 64-bit, 48-bit and 16-bit grayscale images; from -32768 to 32767 for signed images; and from 0 - 4095 for 12-bit grayscale images. Otherwise, it is from 0 to 255.
This function allocates memory buffers for the three arrays using the GlobalAllocPtr macro. When the buffers are no longer needed, they should be freed by calling the GlobalFreePtr macro. If the GlobalFreePtr macro is not supported by the compiler, the buffers can be freed using the following code:
void MyGlobalFreePtr(void *ptr)
{
HGLOBAL hGlobal = (HGLOBAL) GlobalHandle(ptr);
GlobalUnlock(hGlobal);
GlobalFree(hGlobal);
}
This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Supportfor 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.
This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Required DLLs and Libraries
LTIMGCLR 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
Win32, x64.
See Also
Functions: |
L_AccessBitmap, L_ReleaseBitmap, L_ClearBitmap, L_GetBitmapRow, L_PutBitmapRow, L_GetBitmapRowCol, L_PutBitmapRowCol, L_PutPixelColor, L_GetPixelColor |
Topics: |
|
|
Example
This example assumes there is a bitmap loaded into Bitmap, which is of type BITMAPHANDLE.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName #if defined (LEADTOOLS_V16_OR_LATER) L_INT LineProfileExample(L_VOID) { L_INT nRet; L_INT * nactRed; L_INT * nactGreen; L_INT * nactBlue; POINT StartPoint, EndPoint; BITMAPHANDLE Bitmap; nactRed=NULL; nactGreen=NULL; nactBlue=NULL; /* Load the bitmap, keeping the bits per pixel of the file */ nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet !=SUCCESS) return nRet; StartPoint.x=0; StartPoint.y=0; EndPoint.x = Bitmap.Width - 1; EndPoint.y=0; nRet = L_LineProfile(&Bitmap,StartPoint,EndPoint,&nactRed,&nactGreen,&nactBlue, 0); if(nRet !=SUCCESS) return nRet; // … use the colors in the arrays here // free the three buffers GlobalFreePtr(nactRed); GlobalFreePtr(nactGreen); GlobalFreePtr(nactBlue); nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &Bitmap, FILE_BMP, 24, 0, NULL); if(nRet !=SUCCESS) return nRet; //free bitmap if(Bitmap.Flags.Allocated) L_FreeBitmap(&Bitmap); return SUCCESS; } #else L_INT LineProfileExample(L_VOID) { L_INT nRet; L_INT * nactRed; L_INT * nactGreen; L_INT * nactBlue; POINT StartPoint, EndPoint; BITMAPHANDLE Bitmap; nactRed=NULL; nactGreen=NULL; nactBlue=NULL; /* Load the bitmap, keeping the bits per pixel of the file */ nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet !=SUCCESS) return nRet; StartPoint.x=0; StartPoint.y=0; EndPoint.x = Bitmap.Width - 1; EndPoint.y=0; nRet = L_LineProfile(&Bitmap,StartPoint,EndPoint,&nactRed,&nactGreen,&nactBlue); if(nRet !=SUCCESS) return nRet; // … use the colors in the arrays here // free the three buffers GlobalFreePtr(nactRed); GlobalFreePtr(nactGreen); GlobalFreePtr(nactBlue); nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &Bitmap, FILE_BMP, 24, 0, NULL); if(nRet !=SUCCESS) return nRet; //free bitmap if(Bitmap.Flags.Allocated) L_FreeBitmap(&Bitmap); return SUCCESS; } #endif // LEADTOOLS_V16_OR_LATER