Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / InterOp / Imaging.cs / 1305600 / 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: [....] (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: [....] (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
- KeyGesture.cs
- COAUTHINFO.cs
- Bits.cs
- HttpHandlersSection.cs
- FileDialog_Vista_Interop.cs
- FrameworkElementAutomationPeer.cs
- Propagator.JoinPropagator.cs
- UniqueEventHelper.cs
- SpotLight.cs
- DataBindEngine.cs
- TextDecorationLocationValidation.cs
- CodeDomConfigurationHandler.cs
- DataGrid.cs
- ServiceDesigner.xaml.cs
- MetadataCollection.cs
- FlagsAttribute.cs
- HttpEncoderUtility.cs
- BaseDataList.cs
- SecurityState.cs
- XmlChoiceIdentifierAttribute.cs
- OdbcTransaction.cs
- PropertiesTab.cs
- TeredoHelper.cs
- UniformGrid.cs
- _ListenerResponseStream.cs
- SqlDataAdapter.cs
- MethodBody.cs
- HttpApplication.cs
- StateManagedCollection.cs
- ScriptingRoleServiceSection.cs
- QilVisitor.cs
- CompilerHelpers.cs
- DataSourceView.cs
- MenuItemCollection.cs
- UserNamePasswordValidator.cs
- ReliabilityContractAttribute.cs
- NumberFormatInfo.cs
- CompiledIdentityConstraint.cs
- RemotingException.cs
- mansign.cs
- ObjectDataSourceFilteringEventArgs.cs
- DataSourceBooleanViewSchemaConverter.cs
- ToolBarPanel.cs
- MultiPropertyDescriptorGridEntry.cs
- ToolStripPanelRow.cs
- StringReader.cs
- Point4DConverter.cs
- HttpAsyncResult.cs
- LocalValueEnumerator.cs
- TextSelection.cs
- AutoResetEvent.cs
- SqlDataReader.cs
- DateTimeParse.cs
- DefaultAsyncDataDispatcher.cs
- MultipleCopiesCollection.cs
- TriggerBase.cs
- LinkedResource.cs
- XmlUnspecifiedAttribute.cs
- HttpProfileBase.cs
- Ops.cs
- GridLengthConverter.cs
- StylusPlugInCollection.cs
- DiscoveryClient.cs
- UDPClient.cs
- WinEventWrap.cs
- serverconfig.cs
- XPathDocumentIterator.cs
- InputScopeConverter.cs
- GeometryGroup.cs
- CssClassPropertyAttribute.cs
- LinkDescriptor.cs
- DataGridRow.cs
- TileBrush.cs
- XmlLoader.cs
- FileDialog.cs
- fixedPageContentExtractor.cs
- BufferBuilder.cs
- AssemblyCollection.cs
- DriveNotFoundException.cs
- SqlConnectionPoolGroupProviderInfo.cs
- BufferedReadStream.cs
- ConfigurationConverterBase.cs
- RecordConverter.cs
- AppSettingsSection.cs
- figurelength.cs
- QueueNameHelper.cs
- RadioButton.cs
- PermissionListSet.cs
- Expression.cs
- TextParagraph.cs
- BufferBuilder.cs
- DataGridTextBox.cs
- PointConverter.cs
- StringInfo.cs
- CompilerError.cs
- MenuItemAutomationPeer.cs
- VirtualizedItemPattern.cs
- DataComponentMethodGenerator.cs
- StopStoryboard.cs
- DesignerLabelAdapter.cs