Meet us at PRINT 19. Chicago, IL. Oct. 3 - 5.
This documentation is for the old version. Go to the latest Graphics Mill docs

ColorPalette Class

This class represents palette, i.e. an array of color values. Used in indexed bitmaps.

Namespace: Aurigma.GraphicsMill
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
<DefaultMemberAttribute("Item")> _
Public Class ColorPalette _
	Inherits LockableObject _
	Implements ICloneable, IEnumerable
C#
[DefaultMemberAttribute("Item")]
public class ColorPalette : LockableObject, ICloneable, IEnumerable

Remarks

Color palettes are used in indexed bitmaps to store colors. Each pixel of the indexed bitmap is an index you should pass to Item[Int32] to get an actual color this pixel represents. These indices should not exceed total number of palette entries which you can get through Count property.

You can create a predefined palette, or create an empty one, and then import colors from array using Import(RgbColor[]) method. You can also export the palette into array using Export() method.

Since the palettes never store more than 256 entries, only few of 16 millions 24-bit RGB colors are available in the palette. That's why if you need change a color of some pixel, you cannot pass arbitrary color. You should find nearest color in the palette and pass its index instead. To convert the color into index in this palette, you can use FindNearestIndex(RgbColor) method. Note, this method works quite slow, that's why you should cache nearest index if possible.

Graphics Mill for .NET fully supports palette entries with alpha channels. It means that if you put semi-transparent entries, they will be drawn and processed properly. However not all file formats support alpha channel in palettes. In particular GIF format can have only one transparent entry (so-called key color). That's why in such cases only first entry with zero alpha channel will be treated as transparent. So if you need to set transparent index of GIF file, you should use SetColorKey(Int32) method instead of modifying alpha channel of the entry.

Examples

Visual Basic
Dim palette As New Aurigma.GraphicsMill.ColorPalette( _
 Aurigma.GraphicsMill.ColorPaletteType.WebSafe, True)
C#
Aurigma.GraphicsMill.ColorPalette palette = new Aurigma.GraphicsMill.ColorPalette( 
    Aurigma.GraphicsMill.ColorPaletteType.WebSafe, true);

Inheritance Hierarchy

System.Object
L Aurigma.GraphicsMill.LockableObject
L Aurigma.GraphicsMill.ColorPalette

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

Object Model




See Also

Reference