Applies color mapping for one or several colors on a 1-, 4- or 8-bit palletized or a 16-, 24- or 32-bit high color image.

Namespace:  FreeImageAPI
Assembly:  FreeImageNET (in FreeImageNET.dll)

Syntax

C#
public static uint ApplyColorMapping(
	FIBITMAP dib,
	RGBQUAD[] srccolors,
	RGBQUAD[] dstcolors,
	uint count,
	bool ignore_alpha,
	bool swap
)
Visual Basic (Declaration)
Public Shared Function ApplyColorMapping ( _
	dib As FIBITMAP, _
	srccolors As RGBQUAD(), _
	dstcolors As RGBQUAD(), _
	count As UInteger, _
	ignore_alpha As Boolean, _
	swap As Boolean _
) As UInteger
Visual C++
public:
static unsigned int ApplyColorMapping(
	FIBITMAP dib, 
	array<RGBQUAD>^ srccolors, 
	array<RGBQUAD>^ dstcolors, 
	unsigned int count, 
	bool ignore_alpha, 
	bool swap
)

Parameters

dib
Type: FreeImageAPI..::.FIBITMAP
Handle to a FreeImage bitmap.
srccolors
Type: array< FreeImageAPI..::.RGBQUAD >[]()[]
Array of colors to be used as the mapping source.
dstcolors
Type: array< FreeImageAPI..::.RGBQUAD >[]()[]
Array of colors to be used as the mapping destination.
count
Type: System..::.UInt32
The number of colors to be mapped. This is the size of both srccolors and dstcolors.
ignore_alpha
Type: System..::.Boolean
If true, 32-bit images and colors are treated as 24-bit.
swap
Type: System..::.Boolean
If true, source and destination colors are swapped, that is, each destination color is also mapped to the corresponding source color.

Return Value

The total number of pixels changed.

Remarks

This function maps up to count colors specified in srccolors to these specified in dstcolors. Thereby, color srccolors[N], if found in the image, will be replaced by color dstcolors[N]. If swap is true, additionally all colors specified in dstcolors are also mapped to these specified in srccolors. For high color images, the actual image data will be modified whereas, for palletized images only the palette will be changed.

The function returns the number of pixels changed or zero, if no pixels were changed.

Both arrays srccolors and dstcolors are assumed not to hold less than count colors.

For 16-bit images, all colors specified are transparently converted to their proper 16-bit representation (either in RGB555 or RGB565 format, which is determined by the image's red- green- and blue-mask).

Note, that this behaviour is different from what ApplyPaletteIndexMapping(FIBITMAP, array<Byte>[]()[], array<Byte>[]()[], UInt32, Boolean) does, which modifies the actual image data on palletized images.

Version Information

FreeImage.NET

Supported in: 3.11.0, 3.12.0, 3.13.0, 3.13.1

See Also