1

I have a TIFF image for which I wish to change the BitmapPalette for a specific frame of the image.

I have the following code:

var width = image.Frames[0].PixelWidth;
var height = image.Frames[0].PixelHeight; 
var dpiX = image.Frames[0].DpiX;
var dpiY = image.Frames[0].DpiY;

var listOfColors = new List<System.Windows.Media.Color>();
for (int i = 0; i < 256; i++)
{
      listOfColors.Add(System.Windows.Media.Color.FromRgb((byte)i, (byte)i, (byte)i));
}
var pallet = new BitmapPalette(listOfColors);

newImage = new WriteableBitmap(width, height, dpiX, dpiY, PixelFormats.Indexed8, pallet );

This returns an white image: why? What am I doing wrong here?

Also, if you have any information on how can I parse a GGR file into a BitmapPalette, that would be nice.

Lee Goddard
  • 10,680
  • 4
  • 46
  • 63
CiucaS
  • 2,010
  • 5
  • 36
  • 63

1 Answers1

2

You only filled in the bitmappalette(pallete), not the writeablebitmap inage (newImage).

The bitmap palette plays the role of a look-up table for your writeablebitmap image.

You should fill in your writeablebitmap image (newImage) with indexes to the bitmappalette(palette).

Lee Goddard
  • 10,680
  • 4
  • 46
  • 63
Mojtaba
  • 21
  • 2