LBitmapBase::ChangeCompression

#include "ltwrappr.h"

virtual L_INT LBitmapBase::ChangeCompression(nComp)

L_INT nComp;

/* compression type */

Compresses or decompresses a bitmap.

Parameter

Description

nComp

Flag that indicates the type of compression to use on the bitmap. Possible values are:

 

Value

Meaning

 

COMP_NONE

[0] No compression. This option can be used to decompress compressed or super compressed bitmaps.

 

COMP_RLE

[1] 1-bit RLE compression. This compression is very fast and Lossless. For more information, refer to Speeding Up 1-Bit Documents. This is the same as passing TYPE_COMPRESSED to LBitmapBase::Allocate.

 

COMP_SUPER

[2] Super compression. This is available for 1-bit, 8-bit, and 24-bit bitmaps only. The 24-bit and 8-bit compression is lossy, while the 1-bit compression is lossless.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Required DLLs and Libraries

LTDIS
LTFIL
LFCMP (for 24-bit Super compression)
LFFAX (for 1-bit Super compression)

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:

LBitmapBase::Allocate, LBitmapBase::Create, LBitmapBase::IsSuperCompressed,
Class Members

Topics:

Super Compressed Bitmaps
Speeding up 1-Bit Documents

Raster Image Functions: Compression Functions

Example

L_INT LBitmapBase__ChangeCompressionExample(LBitmapBase & Bitmap, L_TCHAR * pszFile)
{
   L_INT nRet;
   L_TCHAR szMessage[256];
   nRet =Bitmap.Load(pszFile);
   if(nRet !=SUCCESS)
      return nRet;
   if (Bitmap.GetBitsPerPixel() == 1 || Bitmap.GetBitsPerPixel() == 24)
   {
      wsprintf(szMessage, TEXT("BEFORE:\nImage Size: %ld bytes\nType: %s"),
                Bitmap.GetMemSize(),
                Bitmap.IsSuperCompressed() ? 
               TEXT("Super Compressed") : TEXT("Uncompressed"));
      MessageBox(NULL, szMessage, TEXT("Changing Compression"), MB_OK);
      nRet = Bitmap.ChangeCompression(Bitmap.IsSuperCompressed() ? 
                                       COMP_NONE : COMP_SUPER);
      if(nRet == SUCCESS)
         wsprintf(szMessage, 
                   TEXT("AFTER:\nImage Size: %ld bytes\nType: %s"),
                   Bitmap.GetMemSize(),
                   Bitmap.IsSuperCompressed() ? 
                   TEXT("Super Compressed") : TEXT("Uncompressed"));
      else
      {
         wsprintf(szMessage, TEXT("Change Compressions Failed!"));
         return nRet;
      }
      MessageBox(NULL, szMessage, TEXT("Changing Compression"), MB_OK);
   }
   return SUCCESS;
}