Custom color palette with BitmapPalette
<p>I am creating a custom palette in C#. My bitmap is as follows.</p>

<pre><code>List&lt;System.Windows.Media.Color&gt; colors = new List&lt;System.Windows.Media.Color&gt;();

//Add List entries here

BitmapPalette bitmapPalette = new BitmapPalette(colors);
wb = new WriteableBitmap(Width, Height, dpiX, dpiY, PixelFormats.Indexed8, bitmapPalette);
</code></pre>

<p>I need to create a map from 0-255. How do I get this done in the easiest way?</p>

<pre><code>colors.Add(System.Windows.Media.Colors.Red);
colors.Add(System.Windows.Media.Colors.Blue);
colors.Add(System.Windows.Media.Colors.Green);
</code></pre>

<p>One way of filling is as shown, but filling all 255 entries this way doesn't make sense. How do I fill using pixel values directly rather than <code>System.Windows.Media.Colors.[Color]</code>?</p>