BitmapDataExtensionsTrySetPalette Method

Tries to the set the specified palette for this IWritableBitmapData.


Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 7.0.0
public static bool TrySetPalette(
	this IWritableBitmapData bitmapData,
	Palette palette


bitmapData  IWritableBitmapData
The IWritableBitmapData whose Palette should be set.
palette  Palette
A Palette instance to set.

Return Value

 palette can be set as the Palette of this bitmapData; otherwise, .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IWritableBitmapData. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).


Setting may fail if bitmapData PixelFormat is not an indexed one, the number of entries in palette is less than Count of the current Palette, the number of entries in palette is larger than the possible maximum number of colors of the current PixelFormat, or when the current IWritableBitmapData does not support setting the palette.

The Palette.BackColor and Palette.AlphaThreshold properties of the Palette property will continue to return the same value as the original BackColor and AlphaThreshold values of this bitmapData.


ArgumentNullExceptionbitmapData is .

See Also