Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / InterOp / Imaging.cs / 1 / Imaging.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All Rights Reserved. // // File: Imaging.cs // //----------------------------------------------------------------------------- using System; using System.Security; using System.Security.Permissions; using MS.Internal; using System.Diagnostics; using System.Windows; using System.Windows.Media.Imaging; using Microsoft.Win32.SafeHandles; using MS.Internal.PresentationCore; // SecurityHelper using System.Windows.Interop; namespace System.Windows.Interop { ////// Managed/Unmanaged Interop for Imaging. /// public static class Imaging { ////// Construct an Bitmap from a HBITMAP. /// /// /// /// /// ////// Callers must have UnmanagedCode permission to call this API. /// ////// Critical - calls critical code, access unmanaged resources /// PublicOK - demands unmanaged code permission /// [SecurityCritical] unsafe public static BitmapSource CreateBitmapSourceFromHBitmap( IntPtr bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions) { SecurityHelper.DemandUnmanagedCode(); // CR: dwaynen (1681459) return CriticalCreateBitmapSourceFromHBitmap(bitmap, palette, sourceRect, sizeOptions, WICBitmapAlphaChannelOption.WICBitmapUseAlpha); } ////// Construct an Bitmap from a HBITMAP. /// /// /// /// /// /// ////// Critical - calls critical code, access unmanaged resources /// [SecurityCritical] unsafe internal static BitmapSource CriticalCreateBitmapSourceFromHBitmap( IntPtr bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions, WICBitmapAlphaChannelOption alphaOptions) { if (bitmap == IntPtr.Zero) { throw new ArgumentNullException("bitmap"); } return new InteropBitmap(bitmap, palette, sourceRect, sizeOptions, alphaOptions); // use the critical version } ////// Construct an Bitmap from a HICON. /// /// /// /// ////// Callers must have UnmanagedCode permission to call this API. /// ////// Critical - calls critical code, access unmanaged resources /// PublicOK - demands unmanaged code permission /// [SecurityCritical ] unsafe public static BitmapSource CreateBitmapSourceFromHIcon( IntPtr icon, Int32Rect sourceRect, BitmapSizeOptions sizeOptions) { SecurityHelper.DemandUnmanagedCode(); if (icon == IntPtr.Zero) { throw new ArgumentNullException("icon"); } return new InteropBitmap(icon, sourceRect, sizeOptions); } ////// Construct an Bitmap from a section handle. /// /// /// /// /// /// /// ////// Callers must have UnmanagedCode permission to call this API. /// ////// Critical - calls critical code, access unmanaged resources /// PublicOK - demands unmanaged code permission /// [SecurityCritical ] unsafe public static BitmapSource CreateBitmapSourceFromMemorySection( IntPtr section, int pixelWidth, int pixelHeight, Media.PixelFormat format, int stride, int offset) { SecurityHelper.DemandUnmanagedCode(); if (section == IntPtr.Zero) { throw new ArgumentNullException("section"); } return new InteropBitmap(section, pixelWidth, pixelHeight, format, stride, offset); } } } // 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: Imaging.cs // //----------------------------------------------------------------------------- using System; using System.Security; using System.Security.Permissions; using MS.Internal; using System.Diagnostics; using System.Windows; using System.Windows.Media.Imaging; using Microsoft.Win32.SafeHandles; using MS.Internal.PresentationCore; // SecurityHelper using System.Windows.Interop; namespace System.Windows.Interop { ////// Managed/Unmanaged Interop for Imaging. /// public static class Imaging { ////// Construct an Bitmap from a HBITMAP. /// /// /// /// /// ////// Callers must have UnmanagedCode permission to call this API. /// ////// Critical - calls critical code, access unmanaged resources /// PublicOK - demands unmanaged code permission /// [SecurityCritical] unsafe public static BitmapSource CreateBitmapSourceFromHBitmap( IntPtr bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions) { SecurityHelper.DemandUnmanagedCode(); // CR: dwaynen (1681459) return CriticalCreateBitmapSourceFromHBitmap(bitmap, palette, sourceRect, sizeOptions, WICBitmapAlphaChannelOption.WICBitmapUseAlpha); } ////// Construct an Bitmap from a HBITMAP. /// /// /// /// /// /// ////// Critical - calls critical code, access unmanaged resources /// [SecurityCritical] unsafe internal static BitmapSource CriticalCreateBitmapSourceFromHBitmap( IntPtr bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions, WICBitmapAlphaChannelOption alphaOptions) { if (bitmap == IntPtr.Zero) { throw new ArgumentNullException("bitmap"); } return new InteropBitmap(bitmap, palette, sourceRect, sizeOptions, alphaOptions); // use the critical version } ////// Construct an Bitmap from a HICON. /// /// /// /// ////// Callers must have UnmanagedCode permission to call this API. /// ////// Critical - calls critical code, access unmanaged resources /// PublicOK - demands unmanaged code permission /// [SecurityCritical ] unsafe public static BitmapSource CreateBitmapSourceFromHIcon( IntPtr icon, Int32Rect sourceRect, BitmapSizeOptions sizeOptions) { SecurityHelper.DemandUnmanagedCode(); if (icon == IntPtr.Zero) { throw new ArgumentNullException("icon"); } return new InteropBitmap(icon, sourceRect, sizeOptions); } ////// Construct an Bitmap from a section handle. /// /// /// /// /// /// /// ////// Callers must have UnmanagedCode permission to call this API. /// ////// Critical - calls critical code, access unmanaged resources /// PublicOK - demands unmanaged code permission /// [SecurityCritical ] unsafe public static BitmapSource CreateBitmapSourceFromMemorySection( IntPtr section, int pixelWidth, int pixelHeight, Media.PixelFormat format, int stride, int offset) { SecurityHelper.DemandUnmanagedCode(); if (section == IntPtr.Zero) { throw new ArgumentNullException("section"); } return new InteropBitmap(section, pixelWidth, pixelHeight, format, stride, offset); } } } // 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
- SingleObjectCollection.cs
- CngKeyCreationParameters.cs
- MSAAEventDispatcher.cs
- PasswordBox.cs
- Reference.cs
- DataListItemCollection.cs
- Animatable.cs
- Graph.cs
- ItemContainerProviderWrapper.cs
- CachedBitmap.cs
- ToolStripRendererSwitcher.cs
- WebPartEditVerb.cs
- TypedTableBase.cs
- SiteMap.cs
- MemberInfoSerializationHolder.cs
- HtmlLink.cs
- AutomationPropertyInfo.cs
- AffineTransform3D.cs
- StringValidatorAttribute.cs
- WindowsIdentity.cs
- SelectManyQueryOperator.cs
- UpdateEventArgs.cs
- ITextView.cs
- SafeEventLogWriteHandle.cs
- FilteredDataSetHelper.cs
- SafeNativeMethods.cs
- DomainConstraint.cs
- PersistenceException.cs
- GeometryModel3D.cs
- CompositeScriptReferenceEventArgs.cs
- RightNameExpirationInfoPair.cs
- FirstMatchCodeGroup.cs
- basecomparevalidator.cs
- Cursors.cs
- Misc.cs
- DataGridViewLayoutData.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs
- DBConnection.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- DocumentNUp.cs
- ColumnWidthChangingEvent.cs
- MSAAEventDispatcher.cs
- TypeUtil.cs
- UriTemplateClientFormatter.cs
- COMException.cs
- InputScopeAttribute.cs
- NameObjectCollectionBase.cs
- WindowsListView.cs
- X509Certificate2Collection.cs
- FontDifferentiator.cs
- UTF8Encoding.cs
- SRDisplayNameAttribute.cs
- Material.cs
- DbConnectionPoolCounters.cs
- MetadataArtifactLoader.cs
- GZipUtils.cs
- DataColumn.cs
- ConnectionStringsExpressionBuilder.cs
- TimerEventSubscriptionCollection.cs
- SingleStorage.cs
- ProfileModule.cs
- ProcessHost.cs
- DataGridLinkButton.cs
- ParenthesizePropertyNameAttribute.cs
- ArrayTypeMismatchException.cs
- ProviderSettings.cs
- MatrixTransform3D.cs
- FaultCallbackWrapper.cs
- UnionCqlBlock.cs
- OracleConnection.cs
- DataGridToolTip.cs
- ScanQueryOperator.cs
- storepermission.cs
- WebPartZoneBase.cs
- AuthenticationModuleElement.cs
- ConfigurationElement.cs
- AttachedPropertyMethodSelector.cs
- AncestorChangedEventArgs.cs
- MarkedHighlightComponent.cs
- CodeCommentStatementCollection.cs
- ShaperBuffers.cs
- EventLogger.cs
- BitmapDownload.cs
- ControlBuilder.cs
- TypedReference.cs
- XmlNamespaceManager.cs
- BinaryParser.cs
- WebPartConnectionsCloseVerb.cs
- MailBnfHelper.cs
- JoinQueryOperator.cs
- DataGridViewDataErrorEventArgs.cs
- XmlBinaryReaderSession.cs
- ListenerSessionConnection.cs
- LoadedEvent.cs
- Size3D.cs
- FilterQueryOptionExpression.cs
- DictionarySurrogate.cs
- LinqDataSourceContextEventArgs.cs
- MembershipValidatePasswordEventArgs.cs
- SchemaNotation.cs