Sets all pixels with negative color values to 0.
#include "l_bitmap.h"
L_LTKRN_API L_INT L_ClearNegativePixels(pBitmap)
Pointer to the bitmap handle referencing the bitmap that holds the image data.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
If ELO_SIGNED flag has been set using LOADFILEOPTION, when a file is loaded, the bitmap may contain negative pixel values and LEADTOOLS will paint/process the image incorrectly. In order to use this bitmap correctly, you must call L_ClearNegativePixels. If the ELO_SIGNED flag has not been set, all negative pixels are cleared internally, during the load process. Since some TIFF files are saved with negative values for pixel colors, you should call L_ClearNegativePixels if, after loading a bitmap, pBitmap
->Flags.Signed is TRUE.
L_ClearNegativePixels does nothing if Flags.Signed is not set.
💡 TIP
Call L_ClearNegativePixels right after L_LoadBitmap.
Regions are not supported on the Windows CE platform.
Win32, x64, Linux.
This example sets the ELO_SIGNED flag in LOADFILEOPTION,
loads a tif file and clears the negative pixels.
L_INT ClearNegativePixelsExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
LOADFILEOPTION LoadFileOption;
/* enable negative pixels to be loaded from TIFF files */
nRet = L_GetDefaultLoadFileOption(&LoadFileOption, sizeof(LOADFILEOPTION));
if(nRet != SUCCESS)
return nRet;
LoadFileOption.Flags |= ELO_SIGNED;
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image4.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, &LoadFileOption, NULL);
if(nRet != SUCCESS)
return nRet;
/* clear negative pixels if signed */
if(LeadBitmap.Flags.Signed)
{
nRet = L_ClearNegativePixels(&LeadBitmap);
if(nRet != SUCCESS)
{
L_FreeBitmap(&LeadBitmap);
return nRet;
}
}
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.TIF")), &LeadBitmap, FILE_BMP, 24, 0, NULL);
if(nRet != SUCCESS)
{
L_FreeBitmap(&LeadBitmap);
return nRet;
}
L_FreeBitmap(&LeadBitmap);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.