---
title: "ColorPalette Class"
canonical: https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_ColorPalette.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# ColorPalette Class
 
This class represents palette, i.e. an array of color values. Used in indexed bitmaps.
 
**Namespace:** [Aurigma.GraphicsMill](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
<DefaultMemberAttribute("Item")> _
Public Class ColorPalette _Inherits LockableObject _Implements ICloneable, IEnumerable
```
 
```csharp
[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\]](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_ColorPalette_Item_1_e1836fc4.htm.md) to get an actual color this pixel represents. These indices should not exceed total number of palette entries which you can get through [Count](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_ColorPalette_Count.htm.md) property.
 
You can [create a predefined palette](https://www.graphicsmill.com/docs/gm5/C_Aurigma_GraphicsMill_ColorPalette_ctor_2_4fcbac4d.htm.md), or [create an empty one](https://www.graphicsmill.com/docs/gm5/C_Aurigma_GraphicsMill_ColorPalette_ctor_2_ca3359b5.htm.md), and then import colors from array using [Import(RgbColor\[\])](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_ColorPalette_Import_1_3508ff56.htm.md) method. You can also export the palette into array using [Export()](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_ColorPalette_Export.htm.md) 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)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_ColorPalette_FindNearestIndex_1_99a0633e.htm.md) 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)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_ColorPalette_SetColorKey_1_e1836fc4.htm.md) method instead of modifying alpha channel of the entry.
 
## Examples
  
```
Dim palette As New Aurigma.GraphicsMill.ColorPalette( _
 Aurigma.GraphicsMill.ColorPaletteType.WebSafe, True)
```
 
```csharp
Aurigma.GraphicsMill.ColorPalette palette = new Aurigma.GraphicsMill.ColorPalette( 
    Aurigma.GraphicsMill.ColorPaletteType.WebSafe, true);
```
 
## Inheritance Hierarchy
  
- [System.Object](http://msdn2.microsoft.com/en-us/e5kfa45b)
    - [Aurigma.GraphicsMill.LockableObject](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_LockableObject.htm.md)
        - 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

[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_11.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_ColorPalette.htm.md)![](https://www.graphicsmill.com/docs/gm5/ObjectModel3.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_12.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_RgbColor.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel1.png)![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_13.png)
  
## See Also

### Reference

- [ColorPalette Members](https://www.graphicsmill.com/docs/gm5/AllMembers_T_Aurigma_GraphicsMill_ColorPalette.htm.md)
- [Aurigma.GraphicsMill Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill.htm.md)
- [Bitmap.Palette](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Bitmap_Palette.htm.md)
