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
- Win32MouseDevice.cs
- EmbossBitmapEffect.cs
- FlowDocumentScrollViewer.cs
- BufferAllocator.cs
- SchemaObjectWriter.cs
- RowSpanVector.cs
- MimeTypeMapper.cs
- _AutoWebProxyScriptHelper.cs
- CaseStatement.cs
- CapabilitiesUse.cs
- HttpRawResponse.cs
- CompositeDispatchFormatter.cs
- ProgressiveCrcCalculatingStream.cs
- RijndaelManaged.cs
- TextEmbeddedObject.cs
- ElapsedEventArgs.cs
- DocumentApplication.cs
- Funcletizer.cs
- FixedBufferAttribute.cs
- CompleteWizardStep.cs
- BaseCollection.cs
- MouseButton.cs
- MaterialGroup.cs
- ConfigurationPropertyCollection.cs
- ListViewUpdateEventArgs.cs
- HtmlElementErrorEventArgs.cs
- TokenBasedSetEnumerator.cs
- CodeDelegateCreateExpression.cs
- ButtonChrome.cs
- ContentValidator.cs
- IRCollection.cs
- LogReservationCollection.cs
- WebPartManagerInternals.cs
- DoubleCollection.cs
- TransformCollection.cs
- UniqueIdentifierService.cs
- SqlMethodAttribute.cs
- TypeReference.cs
- StaticExtension.cs
- RsaSecurityTokenAuthenticator.cs
- StatusBarItemAutomationPeer.cs
- RegistryPermission.cs
- UnmanagedMarshal.cs
- CopyNodeSetAction.cs
- DesignTimeVisibleAttribute.cs
- ExclusiveHandleList.cs
- DeploymentSection.cs
- AutoResetEvent.cs
- MenuCommand.cs
- InfiniteIntConverter.cs
- GeometryDrawing.cs
- DesignerAttribute.cs
- indexingfiltermarshaler.cs
- datacache.cs
- ExtensionWindowHeader.cs
- ExpressionReplacer.cs
- TableLayoutColumnStyleCollection.cs
- WindowsScrollBar.cs
- DriveNotFoundException.cs
- FrameworkRichTextComposition.cs
- ToolStripContentPanel.cs
- Subtree.cs
- SecurityDocument.cs
- MachinePropertyVariants.cs
- Intellisense.cs
- followingsibling.cs
- DataControlField.cs
- IISUnsafeMethods.cs
- MetadataItemSerializer.cs
- EventLogWatcher.cs
- InternalRelationshipCollection.cs
- WSTrustFeb2005.cs
- ViewValidator.cs
- PagerSettings.cs
- KeyValuePairs.cs
- XPathDocumentBuilder.cs
- DuplicateWaitObjectException.cs
- SafeTokenHandle.cs
- XmlTextReader.cs
- TextBounds.cs
- CriticalExceptions.cs
- JpegBitmapDecoder.cs
- CatalogZone.cs
- DataGridViewCellValueEventArgs.cs
- MultiPropertyDescriptorGridEntry.cs
- WebPartPersonalization.cs
- RewritingPass.cs
- TextContainerHelper.cs
- StringReader.cs
- SafeIUnknown.cs
- VirtualizingStackPanel.cs
- Assembly.cs
- SearchForVirtualItemEventArgs.cs
- HttpProfileBase.cs
- TaskResultSetter.cs
- TypeToken.cs
- ReturnValue.cs
- XmlSchemaObject.cs
- QueryCacheEntry.cs
- UxThemeWrapper.cs