internal BitmapPalette(WICPaletteType paletteType, bool addtransparentColor) { switch (paletteType) { case WICPaletteType.WICPaletteTypeFixedBW: case WICPaletteType.WICPaletteTypeFixedHalftone8: case WICPaletteType.WICPaletteTypeFixedHalftone27: case WICPaletteType.WICPaletteTypeFixedHalftone64: case WICPaletteType.WICPaletteTypeFixedHalftone125: case WICPaletteType.WICPaletteTypeFixedHalftone216: case WICPaletteType.WICPaletteTypeFixedHalftone252: case WICPaletteType.WICPaletteTypeFixedHalftone256: case WICPaletteType.WICPaletteTypeFixedGray4: case WICPaletteType.WICPaletteTypeFixedGray16: case WICPaletteType.WICPaletteTypeFixedGray256: break; default: throw new System.ArgumentException(SR.Get(SRID.Image_PaletteFixedType, paletteType)); } _palette = CreateInternalPalette(); HRESULT.Check(UnsafeNativeMethods.WICPalette.InitializePredefined( _palette, paletteType, addtransparentColor)); // Fill in the Colors property. UpdateManaged(); }
internal static extern int /* HRESULT */ InitializeFormatConverter( IntPtr /* IWICFormatConverter */ THIS_PTR, IntPtr /* IWICBitmapSource */ source, ref Guid dstFormat, int dither, IntPtr /* IWICBitmapPalette */ bitmapPalette, double alphaThreshold, WICPaletteType paletteTranslate);
static internal Imaging.BitmapPalette FromMILPaletteType(WICPaletteType type, bool hasAlpha) { int key = (int)type; Debug.Assert(key < c_maxPalettes); Imaging.BitmapPalette palette; Imaging.BitmapPalette[] palettes; if (hasAlpha) { palettes = transparentPalettes; } else { palettes = opaquePalettes; } palette = palettes[key]; if (palette == null) { lock (palettes) { // palettes might have changed while waiting for the lock. // Need to check again. palette = palettes[key]; if (palette == null) { palette = new Imaging.BitmapPalette(type, hasAlpha); palettes[key] = palette; } } } return(palette); }
static internal Imaging.BitmapPalette FromMILPaletteType(WICPaletteType type, bool hasAlpha) { int key = (int)type; Debug.Assert(key < c_maxPalettes); Imaging.BitmapPalette palette; Imaging.BitmapPalette[] palettes; if (hasAlpha) { palettes = transparentPalettes; } else { palettes = opaquePalettes; } palette = palettes[key]; if (palette == null) { lock (palettes) { // palettes might have changed while waiting for the lock. // Need to check again. palette = palettes[key]; if (palette == null) { palette = new Imaging.BitmapPalette(type, hasAlpha); palettes[key] = palette; } } } return palette; }
internal static extern int /* HRESULT */ GetType(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, out WICPaletteType pePaletteType);
internal static extern int /* HRESULT */ InitializePredefined(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, WICPaletteType ePaletteType, bool fAddTransparentColor);
internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICFormatConverter */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, ref Guid dstFormat, DitherType dither, System.Windows.Media.SafeMILHandle /* IWICBitmapPalette */ bitmapPalette, double alphaThreshold, WICPaletteType paletteTranslate );