Prod.: Engine, ver.: 6016, ID: 60001039, Wish : Change ImageDef palette colors

Wish : Change ImageDef palette colors

Article60001039
TypeWish
ProductEngine
Version6016
Date Added12/17/2009
FixedYes [12/18/2009]
Submitted byDominique PREMILLIEU
Keywords

Subject

Change ImageDef palette colors

Summary

Change ImageDef palette

Solution

In 6017 new methods was added for vdImageDef object:

///


/// Returns the Palette of the selected Bitmap or null if the bitmap is not ColorIndexed.
///

/// The Palette of the selected Bitmap or null if the bitmap is not ColorIndexed.
Color[] GetPalette()

///
/// Select a new palette for the selected image.
///

/// An array of colors that defines the palette.
/// True if the palette of the image was changed.
/// The selected image must be an uncompress 1bb,4bb or 8bb Color index Bitmap.
/// The number of colors in the input palette must be the same length with the palette that used from the selected bitmap.
///

bool SelectPalette(Color[] colorPalette)

 

Example:

//Supose that we have add an 1bpp Bitmap in the Images colllection with Black and White palette
//Following code will make the image embeded in the drawing and it will change the palette to Blue and Red background

if (doc.Images.Count == 0) return;
vdImageDef imagedef = doc.Images[0];
imagedef.InternalSetBytes(new VectorDraw.Geometry.ByteArray(imagedef.Image.GetImageBytes(true)));
Color[] palette = imagedef.GetPalette();
if (palette != null && palette.Length == 2)
{
   palette[0] = Color.Blue;
   palette[1] = Color.Red;
   bool test = imagedef.SelectPalette(palette);
}
imagedef.Update();
doc.Redraw(true);