L_ChangeBitmapCompression

#include "l_bitmap.h"

L_LTKRN_API L_INT L_ChangeBitmapCompression(pBitmap, nComp)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nComp;

/* compression type */

Compresses of decompresses a bitmap.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to compress or decompress.

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

 

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.

Comments

This function should be used instead of L_ToggleBitmapCompression.

Required DLLs and Libraries

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

Platforms

Windows 2000 / XP/Vista, Windows CE.

See Also

Functions:

L_AllocateBitmap, L_CreateBitmap

Topics:

Super Compressed Bitmaps

 

Speeding up 1-Bit Documents

 

Raster Image Functions: Compression Functions

Example

This function toggles bitmap compression.

L_INT ChangeBitmapCompressionExample(HWND  hWnd, pBITMAPHANDLE   pBitmap)
{
   L_INT     nRet = 0;
   L_TCHAR   s[100];

   if(pBitmap->BitsPerPixel == 1 || pBitmap->BitsPerPixel == 8 || pBitmap->BitsPerPixel == 24)
   {
      wsprintf(s, TEXT("BEFORE - ImageSize: %ld bytes, Type: %s"), pBitmap->Size, (pBitmap->Flags.SuperCompressed ? TEXT("SUPERCOMP") : TEXT("UNCOMP")));
      MessageBox(hWnd, s, TEXT("ChangeBitmapCompression"), MB_OK);
      nRet = L_ChangeBitmapCompression(pBitmap, pBitmap->Flags.SuperCompressed ? COMP_NONE : COMP_SUPER);
      if(nRet == SUCCESS)
         wsprintf(s, TEXT("AFTER - ImageSize: %ld bytes, Type: %s"), pBitmap->Size, (pBitmap->Flags.SuperCompressed ? TEXT("SUPERCOMP") : TEXT("UNCOMP")));
      else
      {
         wsprintf(s, TEXT("L_ChangeBitmapCompression Failed"));
         return nRet;
      }
      MessageBox(hWnd, s, TEXT("ChangeBitmapCompression"), MB_OK);
   }
   return SUCCESS;
}