static L_INT LBase::DecodeABIC(pInputData, nLength, ppOutputData, nAlign, nWidth, nHeight, bBiLevel)
Decodes the ABIC data and updates the ppOutputData parameter with the uncompressed raw data.
Pointer to the input buffer that contains the ABIC compressed data.
Size of the compressed data.
Pointer to a pointer to an output buffer to be updated with the uncompressed raw data.
Number of bytes used for aligning the uncompressed raw data pointed to by ppOutputData.
Width of the compressed ABIC data image, in pixels.
Height of the compressed data image, in pixels.
Flag that indicates whether the input data is bi-level or grayscale. Possible values are:
Value | Meaning |
---|---|
TRUE | Input data pointed to by pInputData is 1-bit Bi-level. |
FALSE | Input data pointed to by pInputData is 4-bit Grayscale. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function decompresses 1-bit bi-level or 4-bit grayscale ABIC raw data.
The output buffer pointed to by ppOutputData is allocated automatically by the function. The user is responsible for freeing this ppOutputData buffer by calling GlobalFreePtr() function. The length of the output buffer can be calculated as follows:
bBiLevel value | nLength |
---|---|
TRUE | ( ( (nWidth + 31) >> 3) & ~3) |
FALSE | ( ( (nWidth * 4 + 31) >> 3) & ~3) |
Win32, x64.
#define DIB_WIDTH_BYTES(b) (((L_UINT) ((((L_UINT32) (b)) + 31) >> 3)) & ~3)
#define ROUNDEDBYTESPERLINE(w, b) DIB_WIDTH_BYTES((L_UINT32) (w) * (L_UINT32) (b))
L_INT LBase__DecodeABICExample( LBitmapBase& Bitmap )
{
L_INT nRet;
L_INT nLength;
L_UCHAR *pData;
L_INT nOutLength;
L_UCHAR *pOutData;
HANDLE hFile;
RGBQUAD MyGrayPal[ 16 ];
DWORD wgReadBytes = 0;
/* open file */
hFile = CreateFile(MAKE_IMAGE_PATH(TEXT("Image2Raw.ica")), GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if( NULL != hFile )
{
/* calculate length of data and load it from the file */
SetFilePointer(hFile, 0, 0, FILE_END);
nLength = SetFilePointer(hFile, 0, 0, FILE_CURRENT);
SetFilePointer(hFile, 0, 0, FILE_BEGIN);
pData = (L_UCHAR *)GlobalAllocPtr( GMEM_FIXED, nLength );
if( NULL == pData )
{
CloseHandle(hFile );
return -1; /* no memory */
}
while(wgReadBytes < (DWORD)nLength)
{
DWORD wReadBytes = 0;
if(! ReadFile (hFile, &pData[wgReadBytes], nLength-wgReadBytes, &wReadBytes, NULL))
{
GlobalFreePtr( pData );
CloseHandle(hFile );
return -1; /* failed while reading */
}
wgReadBytes+= wReadBytes;
}
CloseHandle(hFile );
/* decode the data */
pOutData = NULL;
nRet = LBase::DecodeABIC( pData, nLength, &pOutData, 4, 472 /* width */, 221 /* height */, FALSE );
GlobalFreePtr( pData );
if( SUCCESS == nRet )
{
if(Bitmap.IsAllocated())
Bitmap.Free();
nOutLength = 221 * ROUNDEDBYTESPERLINE( 472, 4 );
struct
{
BITMAPINFO info;
RGBQUAD colors[ 15 ];
} BitmapInfo;
memset(&BitmapInfo, 0, sizeof(BitmapInfo));
BitmapInfo.info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
BitmapInfo.info.bmiHeader.biWidth = 472;
BitmapInfo.info.bmiHeader.biHeight = 221;
BitmapInfo.info.bmiHeader.biBitCount = 4;
nRet = Bitmap.ConvertFromDIB( &BitmapInfo.info, pOutData);
/* prepare gray scale 16-color palette */
for( L_INT k = 0 ; k < 16 ; k++ )
{
MyGrayPal[ k ].rgbBlue =(BYTE)( 0x11 * k);
MyGrayPal[ k ].rgbRed = (BYTE)(0x11 * k);
MyGrayPal[ k ].rgbGreen =(BYTE)(0x11 * k);
MyGrayPal[ k ].rgbReserved = 0;
}
nRet = Bitmap.PutColors( 0, 16, MyGrayPal );
GlobalFreePtr( pOutData );
return nRet;
}
}
return -1;
}
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