Index   Commented   Search   About

Locating and Opening Compressors and Decompressors

The following example uses the ICLocate function to find a compressor that can compress an 8-bits-per-pixel bitmap.

BITMAPINFOHEADER bih;

HIC hIC

// Initialize the bitmap structure.

bih.biSize = sizeof(BITMAPINFOHEADER);

bih.biWidth = bih.biHeight = 0;

bih.biPlanes = 1;

bih.biCompression = BI_RGB; // standard RGB bitmap

bih.biBitcount = 8; // 8 bits-per-pixel format

bih.biSizeImage = 0;

bih.biXPelsPerMeter = bih.biYPelsPerMeter = 0;

bih.biClrUsed = bih.biClrImportant = 256;

hIC = ICLocate (ICTYPE_VIDEO, 0L, (LPBITMAPINFOHEADER) &bih,

NULL, ICMODE_COMPRESS);

The following example enumerates the decompressors in the system to find one that can handle the format of its images. This example uses ICTYPE_VIDEO (which is equivalent to the "VIDC" four-character code) and the ICDecompressQuery macro to determine if a compressor or decompressor supports the image format.

for (i=0; ICInfo(fccType, i, &icinfo); i++)

{

hic = ICOpen(icinfo.fccType, icinfo.fccHandler, ICMODE_QUERY);

if (hic)

{

// Skip this compressor if it can't handle the format.

if (fccType == ICTYPE_VIDEO && pvIn != NULL &&

ICDecompressQuery(hic, pvIn, NULL) != ICERR_OK)

{

ICClose(hic);

continue;

}

// Find out the compressor name.

ICGetInfo(hic, &icinfo, sizeof(icinfo));

// Add it to the combo box.

n = ComboBox_AddString(hwndC,icinfo.szDescription);

ComboBox_SetItemData(hwndC, n, hic);

}

}

The following example attempts to locate a specific compressor to compress the 8-bit RGB format to an 8-bit RLE format.

BITMAPINFOHEADER bihIn, bihOut;

HIC hIC

// Initialize the bitmap structure.

biSize = bihOut.biSize = sizeof(BITMAPINFOHEADER);

bihIn.biWidth = bihIn.biHeight = bihOut.biWidth = bihOut.biHeight = 0;

bihIn.biPlanes = bihOut.biPlanes= 1;

bihIn.biCompression = BI_RGB; // standard RGB bitmap for input

bihOut.biCompression = BI_RLE8; // 8-bit RLE for output format

bihIn.biBitcount = bihOut.biBitCount = 8; // 8 bits-per-pixel format

bihIn.biSizeImage = bihOut.biSizeImage = 0;

bihIn.biXPelsPerMeter = bih.biYPelsPerMeter =

bihOut.biXPelsPerMeter = bihOut.biYPelsPerMeter = 0;

bihIn.biClrUsed = bih.biClrImportant =

bihOut.biClrUsed = bihOut.biClrImportant = 256;

hIC = ICLocate (ICTYPE_VIDEO, 0L,

(LPBITMAPINFOHEADER)&bihIn,

(LPBITMAPINFOHEADER)&bihOut, ICMODE_COMPRESS);

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference (win32.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun