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
- BufferedGraphicsManager.cs
- PlainXmlWriter.cs
- EarlyBoundInfo.cs
- HttpWebRequest.cs
- UInt64Storage.cs
- PackageRelationshipSelector.cs
- DataColumnMappingCollection.cs
- ProfilePropertySettingsCollection.cs
- DesignOnlyAttribute.cs
- JulianCalendar.cs
- CapabilitiesRule.cs
- SqlDelegatedTransaction.cs
- DesignTimeVisibleAttribute.cs
- ListMarkerLine.cs
- AspNetCacheProfileAttribute.cs
- BinaryOperationBinder.cs
- Internal.cs
- PolicyChain.cs
- XmlSchemaDatatype.cs
- ItemCheckEvent.cs
- XmlBuffer.cs
- PropertyEmitter.cs
- MenuBindingsEditorForm.cs
- BindingMAnagerBase.cs
- AutomationElementCollection.cs
- CodeAccessSecurityEngine.cs
- AliasGenerator.cs
- cookie.cs
- FillErrorEventArgs.cs
- CodeDelegateCreateExpression.cs
- SystemIcmpV4Statistics.cs
- DoWorkEventArgs.cs
- ConfigurationElement.cs
- _TLSstream.cs
- WindowsListViewItemCheckBox.cs
- unsafeIndexingFilterStream.cs
- remotingproxy.cs
- TimeSpanValidator.cs
- RangeValuePatternIdentifiers.cs
- Rect.cs
- Tracking.cs
- RewritingProcessor.cs
- DataServiceRequest.cs
- AttributeTableBuilder.cs
- WebException.cs
- DelimitedListTraceListener.cs
- DaylightTime.cs
- DomNameTable.cs
- Triangle.cs
- BinaryMessageEncodingElement.cs
- InkCollectionBehavior.cs
- SQLBinaryStorage.cs
- SizeConverter.cs
- SafeHandle.cs
- CompositionAdorner.cs
- DataGridViewColumnCollection.cs
- RequestUriProcessor.cs
- MsmqUri.cs
- SafeNativeMemoryHandle.cs
- SpecialNameAttribute.cs
- ComplexBindingPropertiesAttribute.cs
- StringPropertyBuilder.cs
- PtsHost.cs
- SchemaImporterExtensionsSection.cs
- ComplexObject.cs
- FontDialog.cs
- SatelliteContractVersionAttribute.cs
- Stylesheet.cs
- EndpointAddress.cs
- PolyLineSegment.cs
- AsymmetricSignatureDeformatter.cs
- ResourceProperty.cs
- PasswordBoxAutomationPeer.cs
- ProfileService.cs
- DesignerVerbCollection.cs
- Token.cs
- XLinq.cs
- MenuTracker.cs
- Documentation.cs
- SettingsSavedEventArgs.cs
- diagnosticsswitches.cs
- ProxyGenerationError.cs
- WindowClosedEventArgs.cs
- MissingMethodException.cs
- SqlMetaData.cs
- LookupBindingPropertiesAttribute.cs
- ButtonRenderer.cs
- SelectedDatesCollection.cs
- PersonalizationProviderCollection.cs
- FixedHyperLink.cs
- RectAnimationUsingKeyFrames.cs
- Events.cs
- Reference.cs
- InspectionWorker.cs
- COMException.cs
- RemotingAttributes.cs
- XmlSchemaType.cs
- HostingEnvironmentException.cs
- CompositeControl.cs
- XmlDataSource.cs