LBase::EncodeABIC

#include "ltwrappr.h"

static L_INT LBase::EncodeABIC(pInputData, nLength, ppOutputData, nAlign, nWidth, nHeight, bBiLevel);

L_UCHAR * pInputData;

/* input data buffer */

L_INT nAlign;

/* number of bytes aligned for uncompressed input data*/

L_INT nWidth;

/* image width in pixels */

L_INT nHeight;

/* image height in pixels */

L_UCHAR ** ppOutputData;

/* output data buffer to receive */

L_INT * pnLength;

/* pointer to variable */

L_BOOL bBiLevel;

/* flag */

Compresses the input raw data using the ABIC encoder.

Parameter

Description

pInputData

Pointer to a buffer that contains the uncompressed raw data.

nAlign

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

nWidth

Width of the uncompressed raw data image, in pixels.

nHeight

Height of the uncompressed raw data image, in pixels.

ppOutputData

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

pnLength

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

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

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

LTFIL

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LBase::DecodeABIC

Topics:

Compressing and Decompressing Buffers

 

Raster Image Functions: Compression Functions

Example

L_INT myEncodeABIC( LBitmapBase&  Bitmap ) 
{
   L_UCHAR  *pData; 
   L_UCHAR  *pOutData; 
   L_INT  nOutLength; 
   L_INT  nRet; 
   FILE  *pFile; 
   
   LMemoryFile Memfile; 
   LBuffer     Buffer; 

   nRet = 0; 
   if( Bitmap.IsAllocated() ) 
   {
      nOutLength = 0; 
      pOutData = NULL; 
      Memfile.SetBitmap(&Bitmap); 
      nRet = Memfile.SaveBitmap( &Buffer, FILE_RAW, Bitmap.GetBitsPerPixel(), 0, NULL ); 
      if( SUCCESS == nRet ) 
      {
         pData = (L_UCHAR *)GlobalLock( Buffer.GetHandle() ); 

         nRet = LBase::EncodeABIC( pData, 4, Bitmap.GetWidth(), Bitmap.GetHeight(), &pOutData, &nOutLength, FALSE ); 
         if( SUCCESS == nRet ) 
         {
            pFile = fopen( "output.ica", "wb+" ); 
            if( pFile ) 
            {
               if( (L_UINT)nOutLength != fwrite( pOutData, sizeof( L_UCHAR ), nOutLength, pFile ) ) 
               {
                  nRet = -1; /* failed to write data */ 
               }
               fclose( pFile ); 
            }
            else
            {
               nRet = -1; /* failed to open file */
            }
            
            GlobalFreePtr( pOutData ); 
            
            nRet = 0; 
            
         }
         else
         {
            nRet = -1; /* failed to encode data */ 
         }
         
         GlobalUnlock( Buffer.GetHandle() ); 
         GlobalFree( Buffer.GetHandle() ); 
      }
   }
   else
   {
      MessageBox( AfxGetApp()->m_pMainWnd->GetSafeHwnd(), "Do decode first please!", "Information!", MB_OK | MB_ICONINFORMATION); 
      
      nRet = 0; 
   }
   
   return nRet; 
}