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
- Trace.cs
- PropertyRecord.cs
- SafeHandles.cs
- CodeTypeParameter.cs
- EqualityComparer.cs
- Message.cs
- RSAOAEPKeyExchangeFormatter.cs
- OleDbFactory.cs
- Html32TextWriter.cs
- PanelStyle.cs
- ReferentialConstraintRoleElement.cs
- CompiledQuery.cs
- SpanIndex.cs
- PropertyPathWorker.cs
- DebugController.cs
- ReversePositionQuery.cs
- WindowsListViewItemStartMenu.cs
- IndentedTextWriter.cs
- RepeatInfo.cs
- CursorConverter.cs
- ThousandthOfEmRealPoints.cs
- ToolStripItemRenderEventArgs.cs
- ScheduleChanges.cs
- GetParentChain.cs
- ElementNotAvailableException.cs
- XamlPointCollectionSerializer.cs
- DEREncoding.cs
- WhereQueryOperator.cs
- BehaviorEditorPart.cs
- SplineKeyFrames.cs
- CustomCredentialPolicy.cs
- IPPacketInformation.cs
- VectorAnimationUsingKeyFrames.cs
- Matrix.cs
- DescendantBaseQuery.cs
- RectangleConverter.cs
- GenericEnumConverter.cs
- CodeDomDecompiler.cs
- IntegrationExceptionEventArgs.cs
- Effect.cs
- FileDialogCustomPlacesCollection.cs
- CookieParameter.cs
- RNGCryptoServiceProvider.cs
- CategoryAttribute.cs
- ConstraintCollection.cs
- QilUnary.cs
- SmiSettersStream.cs
- XDeferredAxisSource.cs
- DesignerGeometryHelper.cs
- ValueSerializer.cs
- InternalConfigHost.cs
- OleStrCAMarshaler.cs
- SoapCommonClasses.cs
- ImageMapEventArgs.cs
- ContextQuery.cs
- Win32.cs
- RuleElement.cs
- Renderer.cs
- _NtlmClient.cs
- TableLayoutColumnStyleCollection.cs
- FormatterServices.cs
- OracleException.cs
- DesignerDataParameter.cs
- GridViewRow.cs
- WebEventTraceProvider.cs
- URLMembershipCondition.cs
- OutputScope.cs
- SafeArrayRankMismatchException.cs
- Group.cs
- GeneralTransformGroup.cs
- XsltSettings.cs
- DragSelectionMessageFilter.cs
- NativeWindow.cs
- _SslState.cs
- ElementNotAvailableException.cs
- UniqueIdentifierService.cs
- ResourceReferenceExpression.cs
- CommentEmitter.cs
- SrgsRuleRef.cs
- MultiSelector.cs
- DateTime.cs
- RotationValidation.cs
- RuleEngine.cs
- BitmapEffectState.cs
- NaturalLanguageHyphenator.cs
- XmlQueryCardinality.cs
- CreateUserWizardDesigner.cs
- SmiEventStream.cs
- CorrelationManager.cs
- UriParserTemplates.cs
- HwndSubclass.cs
- XmlSubtreeReader.cs
- BuildProviderUtils.cs
- FrameworkPropertyMetadata.cs
- ClientConvert.cs
- QilStrConcat.cs
- FileNotFoundException.cs
- ProcessingInstructionAction.cs
- BinaryObjectReader.cs
- SignedInfo.cs