Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / ImageSource.cs / 2 / 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
- GridViewUpdatedEventArgs.cs
- AppLevelCompilationSectionCache.cs
- DynamicDataRouteHandler.cs
- _NTAuthentication.cs
- ServicesUtilities.cs
- CatalogPartChrome.cs
- NestPullup.cs
- SqlInfoMessageEvent.cs
- Light.cs
- SoapSchemaExporter.cs
- SamlSecurityTokenAuthenticator.cs
- DictionaryMarkupSerializer.cs
- CommonObjectSecurity.cs
- TextContainerChangedEventArgs.cs
- SecurityContext.cs
- ACL.cs
- _HTTPDateParse.cs
- SqlDataSourceFilteringEventArgs.cs
- AssociatedControlConverter.cs
- BackgroundFormatInfo.cs
- BindingParameterCollection.cs
- TypeElementCollection.cs
- DispatchWrapper.cs
- DES.cs
- SoapCodeExporter.cs
- CounterCreationDataCollection.cs
- WpfPayload.cs
- CreateUserWizard.cs
- AutomationPatternInfo.cs
- AnnotationService.cs
- OutputCacheSection.cs
- ObjectAnimationBase.cs
- SoapDocumentServiceAttribute.cs
- WindowsAuthenticationEventArgs.cs
- StreamUpdate.cs
- SubMenuStyle.cs
- Region.cs
- TableLayoutStyle.cs
- PreviewPageInfo.cs
- ColorTransformHelper.cs
- ColumnWidthChangingEvent.cs
- CustomErrorsSection.cs
- Base64Encoder.cs
- LogicalTreeHelper.cs
- StylusEventArgs.cs
- RijndaelManagedTransform.cs
- SchemaDeclBase.cs
- ExternalCalls.cs
- SQLStringStorage.cs
- Rotation3DAnimationBase.cs
- EntityDataSourceState.cs
- EncoderNLS.cs
- CodeDomSerializerException.cs
- OverflowException.cs
- OracleConnectionFactory.cs
- HttpHandlersSection.cs
- ScrollChrome.cs
- LayoutManager.cs
- SchemaNotation.cs
- InheritablePropertyChangeInfo.cs
- EntityProviderFactory.cs
- UnsafePeerToPeerMethods.cs
- TreeNodeBinding.cs
- CompilerGeneratedAttribute.cs
- SecurityTokenSpecification.cs
- util.cs
- SafePEFileHandle.cs
- PropertyPath.cs
- InvalidCastException.cs
- PolicyException.cs
- TimelineGroup.cs
- basecomparevalidator.cs
- UInt16.cs
- CriticalExceptions.cs
- RemoteDebugger.cs
- StructuredType.cs
- DataRowComparer.cs
- SafeArrayRankMismatchException.cs
- XamlWriter.cs
- ErrorHandler.cs
- x509store.cs
- VirtualDirectoryMapping.cs
- ComponentCodeDomSerializer.cs
- xsdvalidator.cs
- ListItemCollection.cs
- SetIndexBinder.cs
- WebPartZoneBase.cs
- ConnectionStringsExpressionBuilder.cs
- LinkButton.cs
- ExpandCollapsePatternIdentifiers.cs
- StandardToolWindows.cs
- NoneExcludedImageIndexConverter.cs
- BmpBitmapEncoder.cs
- DictionaryBase.cs
- UserInitiatedNavigationPermission.cs
- WmpBitmapDecoder.cs
- MessageQueueException.cs
- DictionaryTraceRecord.cs
- PackWebRequest.cs
- FormatConvertedBitmap.cs