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
- DES.cs
- precedingsibling.cs
- ReferentialConstraint.cs
- ReferencedCollectionType.cs
- MouseEvent.cs
- Debug.cs
- Vector3DAnimation.cs
- ActivationArguments.cs
- FieldToken.cs
- DocumentSequence.cs
- SignatureToken.cs
- PeerPresenceInfo.cs
- AuthenticationModuleElementCollection.cs
- ProfilePropertyMetadata.cs
- WebPartUserCapability.cs
- CodeTypeDelegate.cs
- ChunkedMemoryStream.cs
- XPathBuilder.cs
- FixedPageAutomationPeer.cs
- WebBrowser.cs
- TargetControlTypeCache.cs
- OleDbStruct.cs
- clipboard.cs
- StreamingContext.cs
- PrimitiveSchema.cs
- TypeGeneratedEventArgs.cs
- DataBoundControl.cs
- BatchParser.cs
- FormViewUpdatedEventArgs.cs
- Part.cs
- MatrixCamera.cs
- MeasureItemEvent.cs
- BitmapInitialize.cs
- XPathNavigatorKeyComparer.cs
- OnOperation.cs
- CommandEventArgs.cs
- OrderedDictionary.cs
- NameValuePermission.cs
- EntityFrameworkVersions.cs
- ChannelSinkStacks.cs
- ConfigViewGenerator.cs
- IChannel.cs
- codemethodreferenceexpression.cs
- Base64Decoder.cs
- DataGridItemCollection.cs
- WpfKnownType.cs
- AffineTransform3D.cs
- _BasicClient.cs
- BindingExpressionUncommonField.cs
- PartEditor.cs
- DeadCharTextComposition.cs
- FileAuthorizationModule.cs
- DataKey.cs
- BaseCodeDomTreeGenerator.cs
- PreviewPageInfo.cs
- NavigatorOutput.cs
- QuerySettings.cs
- DocumentEventArgs.cs
- KeyConstraint.cs
- GenericTypeParameterBuilder.cs
- DataDocumentXPathNavigator.cs
- ProfileBuildProvider.cs
- ExportException.cs
- TrackingDataItem.cs
- ConfigurationValidatorAttribute.cs
- Odbc32.cs
- XhtmlBasicFormAdapter.cs
- DocumentOrderQuery.cs
- RuntimeCompatibilityAttribute.cs
- XmlTextEncoder.cs
- JournalNavigationScope.cs
- QilSortKey.cs
- HashHelper.cs
- PageHandlerFactory.cs
- RequestBringIntoViewEventArgs.cs
- Stream.cs
- DataGridrowEditEndingEventArgs.cs
- CodeRemoveEventStatement.cs
- DataObjectAttribute.cs
- ToolStripDropDownMenu.cs
- PrintControllerWithStatusDialog.cs
- WindowHideOrCloseTracker.cs
- CallbackValidator.cs
- WebPartEditorOkVerb.cs
- WindowsPen.cs
- RefType.cs
- AttributedMetaModel.cs
- TextEditorTables.cs
- AnnouncementInnerClient11.cs
- FaultDescriptionCollection.cs
- Glyph.cs
- StateRuntime.cs
- Pair.cs
- CompilerInfo.cs
- TraceSection.cs
- ClientOptions.cs
- CompatibleComparer.cs
- HitTestFilterBehavior.cs
- TextTreeObjectNode.cs
- PolyLineSegmentFigureLogic.cs