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
- TypeSemantics.cs
- HMACSHA1.cs
- ConsoleCancelEventArgs.cs
- RelationshipFixer.cs
- InputProcessorProfilesLoader.cs
- ClientData.cs
- RequestCachePolicyConverter.cs
- oledbconnectionstring.cs
- EditorZoneBase.cs
- DynamicUpdateCommand.cs
- ProfessionalColorTable.cs
- DebugTraceHelper.cs
- AssertUtility.cs
- DBParameter.cs
- InvalidAsynchronousStateException.cs
- ActivationArguments.cs
- EntitySqlQueryCacheKey.cs
- DataSourceHelper.cs
- CardSpaceException.cs
- VectorKeyFrameCollection.cs
- Internal.cs
- UTF7Encoding.cs
- FormClosedEvent.cs
- VirtualDirectoryMapping.cs
- DataGridViewIntLinkedList.cs
- CompilerInfo.cs
- EntityException.cs
- AttachedPropertyBrowsableAttribute.cs
- ServicePerformanceCounters.cs
- WebSysDefaultValueAttribute.cs
- EndpointDiscoveryMetadata11.cs
- ChangePassword.cs
- WebConfigurationHost.cs
- InputProviderSite.cs
- UIElement3D.cs
- ReachVisualSerializer.cs
- DataSourceSerializationException.cs
- XmlSignificantWhitespace.cs
- FilterQuery.cs
- TextEndOfSegment.cs
- TextParagraphView.cs
- DeflateStreamAsyncResult.cs
- PageTheme.cs
- codemethodreferenceexpression.cs
- Parser.cs
- RuntimeWrappedException.cs
- ReceiveReply.cs
- TypeElementCollection.cs
- RemotingException.cs
- XmlSchemaType.cs
- listitem.cs
- ListCommandEventArgs.cs
- LinqDataSourceInsertEventArgs.cs
- PriorityQueue.cs
- DependencyProperty.cs
- WebBrowserProgressChangedEventHandler.cs
- BufferAllocator.cs
- MultiByteCodec.cs
- ScriptReferenceEventArgs.cs
- UrlMappingCollection.cs
- RegistrationServices.cs
- ReliableInputConnection.cs
- GregorianCalendar.cs
- ParenthesizePropertyNameAttribute.cs
- BoolExpression.cs
- DropShadowBitmapEffect.cs
- TraceInternal.cs
- CmsInterop.cs
- QilStrConcat.cs
- BitmapEffectDrawingContextWalker.cs
- SystemInformation.cs
- CreatingCookieEventArgs.cs
- SQLStringStorage.cs
- ThicknessAnimationBase.cs
- MobileContainerDesigner.cs
- BitmapInitialize.cs
- DoubleLink.cs
- UDPClient.cs
- SmtpCommands.cs
- MeasureItemEvent.cs
- BrowserCapabilitiesFactory.cs
- MenuEventArgs.cs
- UnsafeNativeMethods.cs
- ProxyHelper.cs
- ToolStripContextMenu.cs
- SqlTypeConverter.cs
- TemplateBindingExpression.cs
- TextMarkerSource.cs
- FormClosingEvent.cs
- InstancePersistenceException.cs
- JapaneseLunisolarCalendar.cs
- DbConvert.cs
- DataGrid.cs
- Int16AnimationBase.cs
- LinkClickEvent.cs
- Cursors.cs
- RowParagraph.cs
- FileUpload.cs
- Parameter.cs
- Transform.cs