Swaps two specified 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 SwapColors(
	FIBITMAP dib,
	ref RGBQUAD color_a,
	ref RGBQUAD color_b,
	bool ignore_alpha
)
Visual Basic (Declaration)
Public Shared Function SwapColors ( _
	dib As FIBITMAP, _
	ByRef color_a As RGBQUAD, _
	ByRef color_b As RGBQUAD, _
	ignore_alpha As Boolean _
) As UInteger
Visual C++
public:
static unsigned int SwapColors(
	FIBITMAP dib, 
	RGBQUAD% color_a, 
	RGBQUAD% color_b, 
	bool ignore_alpha
)

Parameters

dib
Type: FreeImageAPI..::.FIBITMAP
Handle to a FreeImage bitmap.
color_a
Type: FreeImageAPI..::.RGBQUAD %
One of the two colors to be swapped.
color_b
Type: FreeImageAPI..::.RGBQUAD %
The other of the two colors to be swapped.
ignore_alpha
Type: System..::.Boolean
If true, 32-bit images and colors are treated as 24-bit.

Return Value

The total number of pixels changed.

Remarks

This function swaps the two specified colors color_a and color_b on a palletized or high color image. For high color images, the actual image data will be modified whereas, for palletized images only the palette will be changed.

Note, that this behaviour is different from what SwapPaletteIndices(FIBITMAP, Byte%, Byte%) does, which modifies the actual image data on palletized images.

This is just a thin wrapper for ApplyColorMapping(FIBITMAP, array<RGBQUAD>[]()[], array<RGBQUAD>[]()[], UInt32, Boolean, Boolean) and resolves to:

CopyC#
return ApplyColorMapping(dib, color_a, color_b, 1, ignore_alpha, true);

Version Information

FreeImage.NET

Supported in: 3.11.0, 3.12.0, 3.13.0, 3.13.1

See Also