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 / ImageSource.cs / 1 / ImageSource.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All Rights Reserved. // // File: ImageSource.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.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Windows.Media.Animation; using System.Windows.Media.Composition; using System.Windows.Markup; using MS.Win32; namespace System.Windows.Media { #region ImageSource ////// Interface for Bitmap Sources, included decoders and effects /// [TypeConverter(typeof(System.Windows.Media.ImageSourceConverter))] [ValueSerializer(typeof(ImageSourceValueSerializer))] [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)] public abstract partial class ImageSource : Animatable { #region Constructor ////// Don't allow 3rd party extensibility. /// internal ImageSource() { } #endregion Constructor ////// Get the width of the image in measure units (96ths of an inch). /// abstract public double Width { get; } ////// Get the height of the image in measure units (96ths of an inch). /// abstract public double Height { get; } ////// Get the metadata associated with this image source /// abstract public ImageMetadata Metadata { get; } ////// Get the Size associated with this image source /// internal virtual Size Size { get { return new Size(Width, Height); } } #region ToInstanceDescriptor ////// Can serialze "this" to a string /// internal virtual bool CanSerializeToString() { return false; } #endregion ////// Derived classes must override this method and update realizations on dependent /// resources if required. /// internal virtual void UpdateRealizations(RealizationContext ctx) { return; } ////// Converts pixels to DIPs in a way consistent with MIL. Protected here is okay /// because ImageSource isn't extensible by 3rd parties. /// protected static double PixelsToDIPs(double dpi, int pixels) { // Obtain the natural size in MIL Device Independant Pixels (DIPs, or 1/96") of the bitmap. // This is: (Bitmap Pixels) / (Bitmap DotsPerInch) * (DIPs per inch) float dpif = (float)dpi; // To be consistent with BitmapBrush // // Floating-point precision is used to maintain consistent // logic with BitmapBrush DPI scaling, which is implemented in // unmanaged code using single-precision math. Any changes to // this logic must also be updated in the UCE BitmapBrush // resource to maintain this consistency. if (dpif < 0.0F || FloatUtil.IsCloseToDivideByZero(96.0F, dpif)) { dpif = 96.0F; } return (double)(pixels * (96.0F / dpif)); } } #endregion // ImageSource } // 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: ImageSource.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.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Windows.Media.Animation; using System.Windows.Media.Composition; using System.Windows.Markup; using MS.Win32; namespace System.Windows.Media { #region ImageSource ////// Interface for Bitmap Sources, included decoders and effects /// [TypeConverter(typeof(System.Windows.Media.ImageSourceConverter))] [ValueSerializer(typeof(ImageSourceValueSerializer))] [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)] public abstract partial class ImageSource : Animatable { #region Constructor ////// Don't allow 3rd party extensibility. /// internal ImageSource() { } #endregion Constructor ////// Get the width of the image in measure units (96ths of an inch). /// abstract public double Width { get; } ////// Get the height of the image in measure units (96ths of an inch). /// abstract public double Height { get; } ////// Get the metadata associated with this image source /// abstract public ImageMetadata Metadata { get; } ////// Get the Size associated with this image source /// internal virtual Size Size { get { return new Size(Width, Height); } } #region ToInstanceDescriptor ////// Can serialze "this" to a string /// internal virtual bool CanSerializeToString() { return false; } #endregion ////// Derived classes must override this method and update realizations on dependent /// resources if required. /// internal virtual void UpdateRealizations(RealizationContext ctx) { return; } ////// Converts pixels to DIPs in a way consistent with MIL. Protected here is okay /// because ImageSource isn't extensible by 3rd parties. /// protected static double PixelsToDIPs(double dpi, int pixels) { // Obtain the natural size in MIL Device Independant Pixels (DIPs, or 1/96") of the bitmap. // This is: (Bitmap Pixels) / (Bitmap DotsPerInch) * (DIPs per inch) float dpif = (float)dpi; // To be consistent with BitmapBrush // // Floating-point precision is used to maintain consistent // logic with BitmapBrush DPI scaling, which is implemented in // unmanaged code using single-precision math. Any changes to // this logic must also be updated in the UCE BitmapBrush // resource to maintain this consistency. if (dpif < 0.0F || FloatUtil.IsCloseToDivideByZero(96.0F, dpif)) { dpif = 96.0F; } return (double)(pixels * (96.0F / dpif)); } } #endregion // ImageSource } // 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
- SQLRoleProvider.cs
- CalloutQueueItem.cs
- DesignerTransactionCloseEvent.cs
- TableRow.cs
- ComboBoxRenderer.cs
- Control.cs
- PersonalizationStateInfo.cs
- HttpCookiesSection.cs
- WebBrowser.cs
- RSAPKCS1SignatureDeformatter.cs
- ExtentKey.cs
- Attributes.cs
- TableHeaderCell.cs
- ItemDragEvent.cs
- ColumnMapTranslator.cs
- RewritingValidator.cs
- FontWeightConverter.cs
- StylusPointDescription.cs
- ModelChangedEventArgsImpl.cs
- XmlNode.cs
- TextBoxBase.cs
- WpfGeneratedKnownProperties.cs
- ReturnEventArgs.cs
- DataGridLinkButton.cs
- XmlDigitalSignatureProcessor.cs
- HtmlAnchor.cs
- SamlSerializer.cs
- XmlSchemaAttributeGroup.cs
- JavaScriptSerializer.cs
- ThreadStateException.cs
- AsyncResult.cs
- UnsupportedPolicyOptionsException.cs
- SqlCacheDependency.cs
- HotSpot.cs
- TreeViewCancelEvent.cs
- SQLString.cs
- DetailsViewDeletedEventArgs.cs
- MatrixAnimationUsingKeyFrames.cs
- UserUseLicenseDictionaryLoader.cs
- SimpleRecyclingCache.cs
- PenContexts.cs
- InstanceKeyCollisionException.cs
- DataGridViewBand.cs
- DateTimeConverter.cs
- PageAsyncTask.cs
- FormDesigner.cs
- ObjectTag.cs
- EntityClientCacheEntry.cs
- QualificationDataAttribute.cs
- AppSettingsExpressionBuilder.cs
- UnaryNode.cs
- LogSwitch.cs
- RectValueSerializer.cs
- XpsResourceDictionary.cs
- StackOverflowException.cs
- CodeVariableReferenceExpression.cs
- NativeMethods.cs
- DynamicQueryableWrapper.cs
- DBPropSet.cs
- ExecutionEngineException.cs
- ExcCanonicalXml.cs
- QueryServiceConfigHandle.cs
- TypeResolvingOptionsAttribute.cs
- HwndHostAutomationPeer.cs
- FontUnitConverter.cs
- DocumentStatusResources.cs
- input.cs
- TextSyndicationContent.cs
- DataGridColumnCollection.cs
- DataGridTextBoxColumn.cs
- PlaceHolder.cs
- ShaderEffect.cs
- InitializationEventAttribute.cs
- WorkflowApplicationAbortedException.cs
- ListViewUpdateEventArgs.cs
- RankException.cs
- ColorTransformHelper.cs
- X509Utils.cs
- SystemIPGlobalStatistics.cs
- Byte.cs
- TimeoutValidationAttribute.cs
- UriScheme.cs
- NoClickablePointException.cs
- TogglePattern.cs
- PassportPrincipal.cs
- UnSafeCharBuffer.cs
- LineGeometry.cs
- SourceItem.cs
- TimeManager.cs
- AutoResizedEvent.cs
- GlobalEventManager.cs
- Win32NamedPipes.cs
- RestClientProxyHandler.cs
- dtdvalidator.cs
- ToolStripManager.cs
- XmlQueryTypeFactory.cs
- EditCommandColumn.cs
- SerializableTypeCodeDomSerializer.cs
- EditorAttribute.cs
- EventMap.cs