Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- InfoCardAsymmetricCrypto.cs
- SendOperation.cs
- GeneralTransform.cs
- Command.cs
- KeyNotFoundException.cs
- MobileRedirect.cs
- indexingfiltermarshaler.cs
- ComponentGlyph.cs
- TextTreeUndoUnit.cs
- FixedFlowMap.cs
- ListCardsInFileRequest.cs
- TableItemPattern.cs
- TableRowCollection.cs
- MergeFailedEvent.cs
- HiddenField.cs
- Expression.cs
- RectAnimation.cs
- RowToParametersTransformer.cs
- CompilerLocalReference.cs
- Transform3D.cs
- EmptyCollection.cs
- metadatamappinghashervisitor.cs
- FilterableAttribute.cs
- WinFormsComponentEditor.cs
- DataKeyPropertyAttribute.cs
- UnSafeCharBuffer.cs
- SecurityNegotiationException.cs
- OdbcTransaction.cs
- ToolStripPanelSelectionBehavior.cs
- ApplicationSecurityInfo.cs
- PageBuildProvider.cs
- MergeFilterQuery.cs
- PropertyItem.cs
- AttributeTableBuilder.cs
- FormatException.cs
- SystemIPv6InterfaceProperties.cs
- HyperLinkDataBindingHandler.cs
- TableAdapterManagerNameHandler.cs
- FixedFlowMap.cs
- MessageDecoder.cs
- RC2CryptoServiceProvider.cs
- EntityDescriptor.cs
- RequestCache.cs
- HtmlTableRowCollection.cs
- CompositeCollectionView.cs
- SoapProtocolImporter.cs
- RuntimeCompatibilityAttribute.cs
- GuidelineSet.cs
- NavigationProgressEventArgs.cs
- MapPathBasedVirtualPathProvider.cs
- SortQuery.cs
- CharEnumerator.cs
- InheritanceContextChangedEventManager.cs
- ClockGroup.cs
- TransformerTypeCollection.cs
- OleDbFactory.cs
- ObjectViewEntityCollectionData.cs
- ResourceContainerWrapper.cs
- Encoder.cs
- PauseStoryboard.cs
- MemberInitExpression.cs
- DbProviderFactories.cs
- SecUtil.cs
- ListManagerBindingsCollection.cs
- LassoSelectionBehavior.cs
- ProcessHostFactoryHelper.cs
- SchemaDeclBase.cs
- Control.cs
- ErrorInfoXmlDocument.cs
- SqlTypeSystemProvider.cs
- CompositeActivityTypeDescriptorProvider.cs
- ParameterToken.cs
- dsa.cs
- DNS.cs
- CompilerGeneratedAttribute.cs
- SlotInfo.cs
- MarkupObject.cs
- StorageModelBuildProvider.cs
- ScriptingRoleServiceSection.cs
- Timer.cs
- DockingAttribute.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- Descriptor.cs
- TextServicesDisplayAttributePropertyRanges.cs
- QuestionEventArgs.cs
- RegexCompilationInfo.cs
- SqlParameterizer.cs
- DataSetMappper.cs
- Vertex.cs
- UserControlParser.cs
- PartialCachingControl.cs
- SchemaNamespaceManager.cs
- KeyConverter.cs
- MenuItemCollection.cs
- StateMachineWorkflow.cs
- NavigationCommands.cs
- XmlUtil.cs
- PropertyStore.cs
- Constraint.cs
- ThreadStaticAttribute.cs