Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / ImageSource.cs / 1305600 / 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 ////// 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
- PrimarySelectionGlyph.cs
- HitTestParameters.cs
- WriteStateInfoBase.cs
- DataTable.cs
- TextureBrush.cs
- OdbcConnectionHandle.cs
- Enumerable.cs
- OdbcCommand.cs
- ScriptManager.cs
- TreeViewItem.cs
- ChangeDirector.cs
- AmbientLight.cs
- MissingFieldException.cs
- UITypeEditor.cs
- FormViewInsertedEventArgs.cs
- VisualStyleTypesAndProperties.cs
- ApplicationException.cs
- FormViewInsertEventArgs.cs
- GeometryCombineModeValidation.cs
- FillErrorEventArgs.cs
- FunctionUpdateCommand.cs
- EntityDataSourceChangingEventArgs.cs
- XmlElementAttributes.cs
- IODescriptionAttribute.cs
- BasicHttpBinding.cs
- SqlServer2KCompatibilityAnnotation.cs
- EventLogQuery.cs
- AddInIpcChannel.cs
- mediaeventargs.cs
- NumericExpr.cs
- Visual3DCollection.cs
- ProcessModelSection.cs
- OracleDataReader.cs
- OdbcConnectionHandle.cs
- ObjectConverter.cs
- MarkupWriter.cs
- DeviceSpecificChoiceCollection.cs
- BamlLocalizationDictionary.cs
- TableLayoutColumnStyleCollection.cs
- Control.cs
- TransformGroup.cs
- StateWorkerRequest.cs
- BatchServiceHost.cs
- ToolStripArrowRenderEventArgs.cs
- SafeArrayRankMismatchException.cs
- TitleStyle.cs
- Random.cs
- PublishLicense.cs
- DirectionalLight.cs
- InputProcessorProfilesLoader.cs
- EntityTransaction.cs
- SystemFonts.cs
- UInt64.cs
- ProfileBuildProvider.cs
- ResourceReader.cs
- TextBoxBase.cs
- NamespaceEmitter.cs
- HttpConfigurationSystem.cs
- GuidConverter.cs
- CodeAssignStatement.cs
- BaseParser.cs
- HttpsTransportBindingElement.cs
- CompositeCollection.cs
- GeneralTransform2DTo3D.cs
- OLEDB_Enum.cs
- ContentElement.cs
- ValueType.cs
- SkinBuilder.cs
- ConnectionConsumerAttribute.cs
- Accessible.cs
- EntityDataSourceWizardForm.cs
- SerializationIncompleteException.cs
- HybridDictionary.cs
- ObsoleteAttribute.cs
- TransactionScopeDesigner.cs
- RankException.cs
- BreadCrumbTextConverter.cs
- SharedDp.cs
- Menu.cs
- TypedReference.cs
- MetadataArtifactLoaderResource.cs
- Control.cs
- SmiMetaData.cs
- XmlSchemaSimpleTypeRestriction.cs
- SqlServer2KCompatibilityAnnotation.cs
- DataServiceException.cs
- SelectionList.cs
- TreeViewImageIndexConverter.cs
- HostingEnvironmentException.cs
- TextTreeFixupNode.cs
- ObjectFullSpanRewriter.cs
- MailAddressCollection.cs
- ComboBoxAutomationPeer.cs
- TextBoxView.cs
- ThumbAutomationPeer.cs
- DeferredReference.cs
- DataPager.cs
- StrokeDescriptor.cs
- AxWrapperGen.cs
- UnsafeNativeMethods.cs