L_EncodeABIC

#include "ltfil.h"

L_LTFIL_API L_INT L_EncodeABIC(pInputData, nAlign, nWidth, nHeight, ppOutputData, pnLength, bBiLevel)

Compresses the input raw data using the ABIC encoder.

Parameters

L_UCHAR* pInputData

Pointer to a buffer that contains the uncompressed raw data.

L_INT nAlign

Number of bytes used to align the uncompressed raw data pointed to by pInputData.

L_INT nWidth

Width of the uncompressed raw data image, in pixels.

L_INT nHeight

Height of the uncompressed raw data image, in pixels.

L_UCHAR** ppOutputData

Pointer to a pointer to an output data buffer to be updated with the resulting compressed ABIC data.

L_SSIZE_T* pnLength

Pointer to a variable to be updated with the length of the resulting compressed data pointed to by ppOutputData.

L_BOOL bBiLevel

Flag that indicates whether to encode the uncompressed input data pointed to by pInputData as bi-level or grayscale. Possible values are:

Value Meaning
TRUE Encodes the input buffer as 1-bit Bi-level.
FALSE Encodes the input buffer as 4-bit Grayscale.

Returns

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

Comments

This function compresses the input raw data to 1-bit bi-level or 4-bit grayscale ABIC data.

The output buffer pointed by ppOutputData is allocated automatically by the function. The user is responsible to free this ppOutputData buffer by calling GlobalFreePtr() function.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT EncodeABICExample( HWND hWnd, pBITMAPHANDLE  pBitmap) 
{ 
   HGLOBAL   hGlobal=NULL; 
   L_UCHAR   *pData=NULL; 
   L_SIZE_T  uLength=0; 
   L_UCHAR   *pOutData=NULL; 
   L_SSIZE_T nOutLength=0; 
   L_INT  nRet; 
   L_HANDLE  pFile; 
   DWORD wWrittenBytes; 
 
   nRet = 0; 
   if( pBitmap->Flags.Allocated ) 
   { 
      nOutLength = 0; 
      pOutData = NULL; 
 
      nRet = L_SaveBitmapMemory( &hGlobal, pBitmap, FILE_RAW, pBitmap->BitsPerPixel, 0, &uLength, NULL ); 
      if( SUCCESS == nRet ) 
      { 
         pData = (L_UCHAR *)GlobalLock( hGlobal ); 
 
         nRet = L_EncodeABIC( pData, 4, pBitmap->Width, pBitmap->Height, &pOutData, &nOutLength, FALSE ); 
         if( SUCCESS == nRet ) 
         { 
            pFile = CreateFile(MAKE_IMAGE_PATH(TEXT("output.ica")), GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); 
            if( pFile ) 
            { 
               if( !WriteFile(pFile, pOutData,(DWORD)(sizeof( L_UCHAR ) * nOutLength), &wWrittenBytes, NULL) ) 
               { 
                  nRet = -1; /* failed to write data */  
               } 
               CloseHandle( pFile ); 
            } 
            else 
            { 
               nRet = -1; /* failed to open file */ 
            } 
 
            GlobalFreePtr( pOutData ); 
            
         } 
         else 
         { 
            return nRet; /* failed to encode data */  
         } 
         GlobalUnlock( hGlobal ); 
         GlobalFree( hGlobal ); 
      } 
      else 
      { 
         MessageBox( hWnd, TEXT("Do decode first please!"), TEXT("Information!"), MB_OK | MB_ICONINFORMATION); 
         return nRet; 
      } 
   } 
   else 
      return FAILURE; 
 
   return nRet ; 
} 
Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help