Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media / Imaging / BitmapPalettes.cs / 1 / BitmapPalettes.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All rights reserved. // // File: BitmapPalettes.cs // //----------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; using MS.Internal; using System.Diagnostics; using System.Windows.Media; using System.Globalization; using System.Runtime.InteropServices; namespace System.Windows.Media.Imaging { #region BitmapPalettes ////// Pre-defined palette types /// static public class BitmapPalettes { ////// BlackAndWhite /// static public Imaging.BitmapPalette BlackAndWhite { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedBW, false); } } ////// BlackAndWhiteTransparent /// static public Imaging.BitmapPalette BlackAndWhiteTransparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedBW, true); } } ////// Halftone8 /// static public Imaging.BitmapPalette Halftone8 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone8, false); } } ////// Halftone8Transparent /// static public Imaging.BitmapPalette Halftone8Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone8, true); } } ////// Halftone27 /// static public Imaging.BitmapPalette Halftone27 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone27, false); } } ////// Halftone27Transparent /// static public Imaging.BitmapPalette Halftone27Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone27, true); } } ////// Halftone64 /// static public Imaging.BitmapPalette Halftone64 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone64, false); } } ////// Halftone64Transparent /// static public Imaging.BitmapPalette Halftone64Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone64, true); } } ////// Halftone125 /// static public Imaging.BitmapPalette Halftone125 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone125, false); } } ////// Halftone125Transparent /// static public Imaging.BitmapPalette Halftone125Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone125, true); } } ////// Halftone216 /// static public Imaging.BitmapPalette Halftone216 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, false); } } ////// Halftone216Transparent /// static public Imaging.BitmapPalette Halftone216Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, true); } } ////// Halftone252 /// static public Imaging.BitmapPalette Halftone252 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone252, false); } } ////// Halftone252Transparent /// static public Imaging.BitmapPalette Halftone252Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone252, true); } } ////// Halftone256 /// static public Imaging.BitmapPalette Halftone256 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone256, false); } } ////// Halftone256Transparent /// static public Imaging.BitmapPalette Halftone256Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone256, true); } } ////// Gray4 /// static public Imaging.BitmapPalette Gray4 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray4, false); } } ////// Gray4Transparent /// static public Imaging.BitmapPalette Gray4Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray4, true); } } ////// Gray16 /// static public Imaging.BitmapPalette Gray16 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray16, false); } } ////// Gray16Transparent /// static public Imaging.BitmapPalette Gray16Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray16, true); } } ////// Gray256 /// static public Imaging.BitmapPalette Gray256 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray256, false); } } ////// Gray256Transparent /// static public Imaging.BitmapPalette Gray256Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray256, true); } } ////// WebPalette /// static public Imaging.BitmapPalette WebPalette { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, false); } } ////// WebpaletteTransparent /// static public Imaging.BitmapPalette WebPaletteTransparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, true); } } 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 private Imaging.BitmapPalette[] transparentPalettes { get { if (s_transparentPalettes == null) { s_transparentPalettes = new Imaging.BitmapPalette[c_maxPalettes]; } return s_transparentPalettes; } } static private Imaging.BitmapPalette[] opaquePalettes { get { if (s_opaquePalettes == null) { s_opaquePalettes = new Imaging.BitmapPalette[c_maxPalettes]; } return s_opaquePalettes; } } static private Imaging.BitmapPalette[] s_transparentPalettes; static private Imaging.BitmapPalette[] s_opaquePalettes; private const int c_maxPalettes = 64; } #endregion // Imaging.BitmapPalettes } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All rights reserved. // // File: BitmapPalettes.cs // //----------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; using MS.Internal; using System.Diagnostics; using System.Windows.Media; using System.Globalization; using System.Runtime.InteropServices; namespace System.Windows.Media.Imaging { #region BitmapPalettes ////// Pre-defined palette types /// static public class BitmapPalettes { ////// BlackAndWhite /// static public Imaging.BitmapPalette BlackAndWhite { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedBW, false); } } ////// BlackAndWhiteTransparent /// static public Imaging.BitmapPalette BlackAndWhiteTransparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedBW, true); } } ////// Halftone8 /// static public Imaging.BitmapPalette Halftone8 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone8, false); } } ////// Halftone8Transparent /// static public Imaging.BitmapPalette Halftone8Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone8, true); } } ////// Halftone27 /// static public Imaging.BitmapPalette Halftone27 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone27, false); } } ////// Halftone27Transparent /// static public Imaging.BitmapPalette Halftone27Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone27, true); } } ////// Halftone64 /// static public Imaging.BitmapPalette Halftone64 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone64, false); } } ////// Halftone64Transparent /// static public Imaging.BitmapPalette Halftone64Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone64, true); } } ////// Halftone125 /// static public Imaging.BitmapPalette Halftone125 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone125, false); } } ////// Halftone125Transparent /// static public Imaging.BitmapPalette Halftone125Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone125, true); } } ////// Halftone216 /// static public Imaging.BitmapPalette Halftone216 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, false); } } ////// Halftone216Transparent /// static public Imaging.BitmapPalette Halftone216Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, true); } } ////// Halftone252 /// static public Imaging.BitmapPalette Halftone252 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone252, false); } } ////// Halftone252Transparent /// static public Imaging.BitmapPalette Halftone252Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone252, true); } } ////// Halftone256 /// static public Imaging.BitmapPalette Halftone256 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone256, false); } } ////// Halftone256Transparent /// static public Imaging.BitmapPalette Halftone256Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone256, true); } } ////// Gray4 /// static public Imaging.BitmapPalette Gray4 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray4, false); } } ////// Gray4Transparent /// static public Imaging.BitmapPalette Gray4Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray4, true); } } ////// Gray16 /// static public Imaging.BitmapPalette Gray16 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray16, false); } } ////// Gray16Transparent /// static public Imaging.BitmapPalette Gray16Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray16, true); } } ////// Gray256 /// static public Imaging.BitmapPalette Gray256 { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray256, false); } } ////// Gray256Transparent /// static public Imaging.BitmapPalette Gray256Transparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedGray256, true); } } ////// WebPalette /// static public Imaging.BitmapPalette WebPalette { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, false); } } ////// WebpaletteTransparent /// static public Imaging.BitmapPalette WebPaletteTransparent { get { return BitmapPalettes.FromMILPaletteType(WICPaletteType.WICPaletteTypeFixedHalftone216, true); } } 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 private Imaging.BitmapPalette[] transparentPalettes { get { if (s_transparentPalettes == null) { s_transparentPalettes = new Imaging.BitmapPalette[c_maxPalettes]; } return s_transparentPalettes; } } static private Imaging.BitmapPalette[] opaquePalettes { get { if (s_opaquePalettes == null) { s_opaquePalettes = new Imaging.BitmapPalette[c_maxPalettes]; } return s_opaquePalettes; } } static private Imaging.BitmapPalette[] s_transparentPalettes; static private Imaging.BitmapPalette[] s_opaquePalettes; private const int c_maxPalettes = 64; } #endregion // Imaging.BitmapPalettes } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DecimalKeyFrameCollection.cs
- GatewayIPAddressInformationCollection.cs
- ConfigXmlElement.cs
- TraceSection.cs
- ClonableStack.cs
- XNodeValidator.cs
- InternalControlCollection.cs
- wgx_render.cs
- DataViewManager.cs
- EntitySqlQueryBuilder.cs
- DataContractSerializer.cs
- StreamMarshaler.cs
- TrackingServices.cs
- HyperlinkAutomationPeer.cs
- EventHandlersStore.cs
- NonParentingControl.cs
- MissingFieldException.cs
- UnmanagedHandle.cs
- AnonymousIdentificationModule.cs
- ItemCheckEvent.cs
- GridViewColumn.cs
- Vector3DIndependentAnimationStorage.cs
- ExpressionBuilder.cs
- AdornedElementPlaceholder.cs
- TransportBindingElement.cs
- ScriptBehaviorDescriptor.cs
- InkCanvasFeedbackAdorner.cs
- InkCollectionBehavior.cs
- ListItemCollection.cs
- ClientCredentialsSecurityTokenManager.cs
- CodeLinePragma.cs
- DesignerVerbCollection.cs
- DataControlFieldCell.cs
- ListDictionaryInternal.cs
- TargetFrameworkAttribute.cs
- DrawingImage.cs
- SchemaNamespaceManager.cs
- CommonObjectSecurity.cs
- SwitchAttribute.cs
- WindowVisualStateTracker.cs
- SubclassTypeValidatorAttribute.cs
- XsltArgumentList.cs
- TextBoxBase.cs
- ComponentDispatcher.cs
- MembershipValidatePasswordEventArgs.cs
- UnsafeNativeMethodsTablet.cs
- BitmapEffectCollection.cs
- DataError.cs
- EventlogProvider.cs
- designeractionbehavior.cs
- SynchronizationLockException.cs
- StyleCollection.cs
- StrongTypingException.cs
- DbUpdateCommandTree.cs
- FileEnumerator.cs
- XmlAtomicValue.cs
- SynchronizedInputHelper.cs
- RuntimeConfig.cs
- BStrWrapper.cs
- ProgressBarAutomationPeer.cs
- ModifierKeysConverter.cs
- QueryGenerator.cs
- PagesSection.cs
- ClassicBorderDecorator.cs
- NativeMethods.cs
- Label.cs
- SoapReflectionImporter.cs
- WebPartConnectionsDisconnectVerb.cs
- KeyPressEvent.cs
- NullableLongAverageAggregationOperator.cs
- StandardRuntimeEnumValidator.cs
- FlowDocumentFormatter.cs
- DesignerAttribute.cs
- DefaultSerializationProviderAttribute.cs
- Point3DAnimation.cs
- QueryOutputWriterV1.cs
- Misc.cs
- AdornerHitTestResult.cs
- PageTrueTypeFont.cs
- FormatterServices.cs
- HttpRawResponse.cs
- SQLInt16Storage.cs
- AppDomainUnloadedException.cs
- ComponentResourceKeyConverter.cs
- IdnElement.cs
- XsltInput.cs
- KoreanCalendar.cs
- FilterableAttribute.cs
- CacheDependency.cs
- NotificationContext.cs
- GridPattern.cs
- TextParaClient.cs
- AccessDataSource.cs
- DbgUtil.cs
- BaseCodeDomTreeGenerator.cs
- PointAnimationClockResource.cs
- CompareValidator.cs
- ClientScriptManager.cs
- InternalsVisibleToAttribute.cs
- RenderOptions.cs