Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- UnauthorizedWebPart.cs
- WmpBitmapDecoder.cs
- SortDescription.cs
- RuntimeUtils.cs
- dataSvcMapFileLoader.cs
- OdbcRowUpdatingEvent.cs
- EntityDataSourceChangingEventArgs.cs
- OdbcConnectionHandle.cs
- SoundPlayer.cs
- AudioFormatConverter.cs
- ColorMap.cs
- Enum.cs
- Visitor.cs
- ProjectionPruner.cs
- RadioButtonList.cs
- FragmentNavigationEventArgs.cs
- TextAdaptor.cs
- PointLight.cs
- ToolStripItemCollection.cs
- Span.cs
- FillRuleValidation.cs
- EmptyControlCollection.cs
- Activator.cs
- ArgumentValueSerializer.cs
- RegexWriter.cs
- DataServiceStreamResponse.cs
- Misc.cs
- DesignerHelpers.cs
- SqlTopReducer.cs
- OdbcFactory.cs
- BooleanFunctions.cs
- VirtualDirectoryMappingCollection.cs
- Rotation3D.cs
- InfoCardProofToken.cs
- Object.cs
- Version.cs
- DecoderExceptionFallback.cs
- EncodingStreamWrapper.cs
- WebControlsSection.cs
- unsafenativemethodstextservices.cs
- StringComparer.cs
- SelectionEditingBehavior.cs
- RawStylusSystemGestureInputReport.cs
- DataContractAttribute.cs
- StickyNoteContentControl.cs
- TemplateBindingExtensionConverter.cs
- TemplateBindingExpression.cs
- MetadataSet.cs
- DragSelectionMessageFilter.cs
- FixedSOMTable.cs
- WsatServiceAddress.cs
- PeerPresenceInfo.cs
- PassportAuthenticationEventArgs.cs
- CultureSpecificStringDictionary.cs
- QuaternionAnimationUsingKeyFrames.cs
- RoamingStoreFile.cs
- IsolatedStoragePermission.cs
- XmlSubtreeReader.cs
- DbDataReader.cs
- QilInvokeEarlyBound.cs
- ObfuscateAssemblyAttribute.cs
- OTFRasterizer.cs
- ResourcesChangeInfo.cs
- DocumentXmlWriter.cs
- PowerModeChangedEventArgs.cs
- DBProviderConfigurationHandler.cs
- MetadataPropertyvalue.cs
- ConnectionConsumerAttribute.cs
- UnsafeNativeMethods.cs
- AsymmetricKeyExchangeFormatter.cs
- MergePropertyDescriptor.cs
- IdentifierService.cs
- TextServicesPropertyRanges.cs
- SrgsElementList.cs
- XmlILConstructAnalyzer.cs
- HttpsTransportBindingElement.cs
- _SslSessionsCache.cs
- PageParser.cs
- X509Utils.cs
- DiscoveryClientRequestChannel.cs
- ToolStripStatusLabel.cs
- GifBitmapDecoder.cs
- OrderedDictionaryStateHelper.cs
- WeakReference.cs
- Viewport2DVisual3D.cs
- DataGridViewRow.cs
- KeyConverter.cs
- Help.cs
- WeakRefEnumerator.cs
- Trace.cs
- TypeDescriptor.cs
- SoapElementAttribute.cs
- GridViewEditEventArgs.cs
- InternalPermissions.cs
- DataGridLinkButton.cs
- RenderOptions.cs
- Rect.cs
- OlePropertyStructs.cs
- UserPersonalizationStateInfo.cs
- AppDomainProtocolHandler.cs