Palette(IEnumerableColor32, WorkingColorSpace, Color32, Byte, FuncColor32, IPalette, Int32) Constructor
Initializes a new instance of the
Palette class.
See the
Remarks section of the
Palette class for details.
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.0-rc.1
public Palette(
IEnumerable<Color32> entries,
WorkingColorSpace workingColorSpace,
Color32 backColor = default,
byte alphaThreshold = 128,
Func<Color32, IPalette, int>? customGetNearestColorIndex = null
)
Public Sub New (
entries As IEnumerable(Of Color32),
workingColorSpace As WorkingColorSpace,
Optional backColor As Color32 = Nothing,
Optional alphaThreshold As Byte = 128,
Optional customGetNearestColorIndex As Func(Of Color32, IPalette, Integer) = Nothing
)
public:
Palette(
IEnumerable<Color32>^ entries,
WorkingColorSpace workingColorSpace,
Color32 backColor = Color32(),
unsigned char alphaThreshold = 128,
Func<Color32, IPalette^, int>^ customGetNearestColorIndex = nullptr
)
new :
entries : IEnumerable<Color32> *
workingColorSpace : WorkingColorSpace *
?backColor : Color32 *
?alphaThreshold : byte *
?customGetNearestColorIndex : Func<Color32, IPalette, int>
(* Defaults:
let _backColor = defaultArg backColor new Color32()
let _alphaThreshold = defaultArg alphaThreshold 128
let _customGetNearestColorIndex = defaultArg customGetNearestColorIndex null
*)
-> Palette
Parameters
- entries IEnumerableColor32
- The color entries to be stored by this Palette instance.
- workingColorSpace WorkingColorSpace
- Specifies the desired color space to be used by the GetNearestColor
and GetNearestColorIndex methods for blending and measuring color distance.
If customGetNearestColorIndex is set, then it depends on the custom lookup function whether it respects the value of this parameter.
- backColor Color32 (Optional)
- If entries does not contain partially transparent colors, then specifies the background color for
lookup operations (GetNearestColor, GetNearestColorIndex).
When a lookup is performed with a color, whose Color32.A field is equal to or greater than alphaThreshold, and there is no exact match among the entries,
then the color to be found will be blended with this color before performing the lookup. The Color32.A field of the background color is ignored. This parameter is optional.
Default value: The default value of the Color32 type, which has the same RGB values as Black. - alphaThreshold Byte (Optional)
- If there is at least one completely transparent color among entries,
then specifies a threshold value for the Color32.A field, under which lookup operations will return the first transparent color (GetNearestColor)
or the index of the first transparent color (GetNearestColorIndex). This parameter is optional.
Default value: 128. - customGetNearestColorIndex FuncColor32, IPalette, Int32 (Optional)
- A delegate specifying an optional custom lookup logic to obtain an index from entries
by a Color32 and an IPalette instance. If specified, it must be thread-safe, and it is expected to be fast.
The results returned by the specified delegate are not cached. Make sure you always obtain the palette properties such as BackColor,
AlphaThreshold and WorkingColorSpace from the IPalette argument
as this delegate can be re-used in another Palette instance when calling the Palette(Palette, WorkingColorSpace, Color32, Byte) constructor.
If , then GetNearestColor and GetNearestColorIndex methods will
perform a sequential lookup by using a default logic and results will be cached. This parameter is optional.
Default value: .