#include "l_bitmap.h"
L_LTKRN_API L_UINT * L_CreateUserMatchTable(pPalette, uColors)
Creates a table that speeds color conversion when using a palette that you create. The table is referenced by the L_ColorResBitmap function.
The array of values that is your palette.
Each item in the array can have one of the following values:
Value | Meaning |
---|---|
Actual RGBQUAD value | Use the specified color as a fixed color. |
RGB_RESERVED | [0x01] Leave the item blank, for possible later use. |
RGB_EMPTY | [0x02] Let the L_ColorResBitmap function fill in the color. The function supplies optimized colors to fill the RGB_EMPTY items. |
The number of colors in your palette.
The pointer to the table, or NULL if the function fails.
This function is used with other functions in the following sequence:
Call L_CreateUserMatchTable to create the table.
Call L_SetUserMatchTable to make this the current table. (Having this as a separate function allows you to save tables in files and get the one you need, without creating it again.)
Call L_ColorResBitmap with the CRF_USERPALETTE and CRF_FASTMATCHPALETTE options.
Call L_FreeUserMatchTable when the table is no longer needed.
The completed table is a 32K array of integers. On a 32-bit system, it occupies 128K bytes of memory. Creation of the table is a slow, memory-intensive process that is useful only if you are using your own palette more than once. For example, you may want to create the table once, save it to a file, and ship that file with your application.
Required DLLs and Libraries
Win32, x64, Linux.
This example changes the color resolution of a bitmap, using a user-defined palette and a match table for fast color matching.
L_INT CreateUserMatchTableExample(HWND hWnd, pBITMAPHANDLE pBitmap)
{
L_INT nRet;
L_UINT* pMatchTable; /* Pointer to the user match table */
RGBQUAD Rainbow[64] = /* 64-color rainbow palette */
{
{0, 0, 0, 0}, {85, 0, 0, 0}, {170, 0, 0, 0}, {255, 0, 0, 0}, {0, 85, 0, 0},
{85, 85, 0, 0}, {170, 85, 0, 0}, {255, 85, 0, 0}, {0, 170, 0, 0}, {85, 170, 0, 0},
{170, 170, 0, 0}, {255, 170, 0, 0}, {0, 255, 0, 0}, {85, 255, 0, 0}, {170, 255, 0, 0},
{255, 255, 0, 0}, {0, 0, 85, 0}, {85, 0, 85, 0}, {170, 0, 85, 0}, {255, 0, 85, 0},
{0, 85, 85, 0}, {85, 85, 85, 0}, {170, 85, 85, 0}, {255, 85, 85, 0}, {0, 170, 85, 0},
{85, 170, 85, 0}, {170, 170, 85, 0}, {255, 170, 85, 0}, {0, 255, 85, 0},
{85, 255, 85, 0}, {170, 255, 85, 0}, {255, 255, 85, 0}, {0, 0, 170, 0}, {85, 0, 170, 0},
{170, 0, 170, 0}, {255, 0, 170, 0}, {0, 85, 170, 0}, {85, 85, 170, 0}, {170, 85, 170, 0},
{255, 85, 170, 0}, {0, 170, 170, 0}, {85, 170, 170, 0}, {170, 170, 170, 0},
{255, 170, 170, 0}, {0, 255, 170, 0}, {85, 255, 170, 0}, {170, 255, 170, 0},
{255, 255, 170, 0}, {0, 0, 255, 0}, {85, 0, 255, 0}, {170, 0, 255, 0}, {255, 0, 255, 0},
{0, 85, 255, 0}, {85, 85, 255, 0}, {170, 85, 255, 0}, {255, 85, 255, 0}, {0, 170, 255, 0},
{85, 170, 255, 0}, {170, 170, 255, 0}, {255, 170, 255, 0}, {0, 255, 255, 0},
{85, 255, 255, 0}, {170, 255, 255, 0}, {255, 255, 255, 0},
};
/* Create and set the user match table */
pMatchTable = L_CreateUserMatchTable(Rainbow, 64);
L_SetUserMatchTable(pMatchTable);
/* Change the color resolution using the new palette. Note that the user match table
is makes your code faster only if you use it more than once. It is included here only
to show how it can be coded. */
nRet = L_ColorResBitmap(pBitmap, pBitmap, sizeof(BITMAPHANDLE), 8,
CRF_FLOYDSTEINDITHERING|CRF_USERPALETTE|CRF_FASTMATCHPALETTE,
Rainbow, NULL, 64, NULL, NULL );
if(nRet != SUCCESS)
return nRet;
/* Free the user match table when it is no longer needed */
nRet = L_FreeUserMatchTable(pMatchTable);
if(nRet != SUCCESS)
return nRet;
/* Get the new palette as the current paint palette */
SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document