L_DecodeABIC

#include "ltfil.h"

L_LTFIL_API L_INT L_DecodeABIC(pInputData, nLength, ppOutputData, nAlign, nWidth, nHeight, bBiLevel)

Decodes the ABIC data and updates the ppOutputData parameter with the uncompressed raw data.

Parameters

L_UCHAR *pInputData

Pointer to the input buffer that contains the ABIC compressed data.

L_SSIZE_T nLength

Size of the compressed data.

L_UCHAR ** ppOutputData

Pointer to a pointer to an output buffer to be updated with the uncompressed raw data.

L_INT nAlign

Number of bytes used for aligning the uncompressed raw data pointed to by ppOutputData.

L_INT nWidth

Width of the compressed ABIC data image, in pixels.

L_INT nHeight

Height of the compressed data image, in pixels.

L_BOOL bBiLevel

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.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

The 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.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

#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  DecodeABICExample(pBITMAPHANDLE pBitmap, HWND hwnd) 
{ 
   L_INT  nRet; 
   L_INT nLength; 
   L_UCHAR  *pData; 
   L_INT  nOutLength; 
   L_UCHAR  *pOutData; 
   L_HANDLE hFile; 
   DWORD wReadBytes; 
   RGBQUAD  MyGrayPal[ 16 ]; 
 
   /* open file */  
   /* this is IMAGE1.CMP resaved as 4-bit ABIC RAW */ 
   hFile = CreateFile(MAKE_IMAGE_PATH(TEXT("ABIC4.RAW")), 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, NULL, FILE_CURRENT) ; 
      SetFilePointer(hFile, 0, 0, FILE_BEGIN); 
      pData = (L_UCHAR *)GlobalAllocPtr( GMEM_FIXED, nLength ); 
      if( NULL == pData ) 
      { 
        CloseHandle( hFile ); 
        return -1; /* no memory */  
      } 
      if(!ReadFile (hFile, pData, nLength, &wReadBytes, NULL)) 
      { 
        GlobalFreePtr( pData ); 
        CloseHandle( hFile ); 
 
         return -1; /* failed while reading */  
      } 
      CloseHandle( hFile ); 
 
      /* decode the data */  
      pOutData = NULL; 
      nRet = L_DecodeABIC( pData, nLength, &pOutData, 4, 1600 /* width */, 1200 /* height */, FALSE ); 
      GlobalFreePtr( pData ); 
      if( SUCCESS == nRet ) 
      { 
        if( pBitmap->Flags.Allocated ) 
           L_FreeBitmap( pBitmap );             
 
        nOutLength = 1200 * ROUNDEDBYTESPERLINE( 1600, 4 ); 
        struct  
        { 
           BITMAPINFO  info; 
           RGBQUAD     colors[ 15 ]; 
        } BitmapInfo; 
         
        memset(&BitmapInfo, 0, sizeof(BitmapInfo)); 
        BitmapInfo.info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 
        BitmapInfo.info.bmiHeader.biWidth = 1600; 
        BitmapInfo.info.bmiHeader.biHeight = 1200; 
        BitmapInfo.info.bmiHeader.biBitCount = 4; 
        nRet = L_ConvertFromDIB( pBitmap, sizeof(BITMAPHANDLE), &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 = L_PutBitmapColors( pBitmap, 0, 16, MyGrayPal ); 
        GlobalFreePtr( pOutData ); 
        InvalidateRect( hwnd, NULL, TRUE ); 
      } 
      
   } 
   else 
      return -1; 
 
   return SUCCESS; 
} 
Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.