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
- newitemfactory.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- RightsManagementPermission.cs
- EntityException.cs
- TakeQueryOptionExpression.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- BidOverLoads.cs
- VoiceSynthesis.cs
- ToolStripSplitStackLayout.cs
- ListBox.cs
- QueryExpression.cs
- ServiceRoute.cs
- DiagnosticsConfiguration.cs
- SpnEndpointIdentityExtension.cs
- VarInfo.cs
- SparseMemoryStream.cs
- ListControlBoundActionList.cs
- Int32AnimationUsingKeyFrames.cs
- COM2FontConverter.cs
- BufferBuilder.cs
- VisualBrush.cs
- DependencyObjectProvider.cs
- MobileListItem.cs
- NavigatingCancelEventArgs.cs
- XmlBoundElement.cs
- ConfigurationManagerInternalFactory.cs
- DataGridViewLinkColumn.cs
- FtpWebResponse.cs
- WorkflowInstanceAbortedRecord.cs
- RenderData.cs
- EndpointAddressMessageFilter.cs
- ReferenceEqualityComparer.cs
- Matrix3D.cs
- MsmqIntegrationBinding.cs
- xamlnodes.cs
- arc.cs
- ColumnClickEvent.cs
- ExpressionPrinter.cs
- SchemaTableOptionalColumn.cs
- xml.cs
- IntegerCollectionEditor.cs
- BrowserCapabilitiesFactory.cs
- OptimizedTemplateContent.cs
- TextDecorationCollectionConverter.cs
- CopyEncoder.cs
- KeyManager.cs
- CodeTypeParameter.cs
- Operator.cs
- TraceContextRecord.cs
- DataListCommandEventArgs.cs
- Win32PrintDialog.cs
- UnmanagedBitmapWrapper.cs
- Resources.Designer.cs
- XmlNamespaceManager.cs
- EFDataModelProvider.cs
- UnhandledExceptionEventArgs.cs
- PeerHelpers.cs
- AsyncDataRequest.cs
- InkCanvasSelection.cs
- TreeViewItemAutomationPeer.cs
- ItemMap.cs
- CommandHelpers.cs
- TextSpanModifier.cs
- DependentList.cs
- EntityDataSourceValidationException.cs
- FileRegion.cs
- InternalPermissions.cs
- XamlDesignerSerializationManager.cs
- Effect.cs
- AssociationTypeEmitter.cs
- Span.cs
- EmptyCollection.cs
- TemplateField.cs
- AutomationPattern.cs
- InputReportEventArgs.cs
- TextAdaptor.cs
- InvalidDataException.cs
- XmlnsCache.cs
- Comparer.cs
- SqlDataSourceStatusEventArgs.cs
- MasterPageCodeDomTreeGenerator.cs
- MappingModelBuildProvider.cs
- LightweightCodeGenerator.cs
- HintTextMaxWidthConverter.cs
- CompositeControl.cs
- AdornedElementPlaceholder.cs
- ResolveMatchesApril2005.cs
- WindowsRichEditRange.cs
- ProcessRequestArgs.cs
- XmlSequenceWriter.cs
- HttpCapabilitiesSectionHandler.cs
- ItemAutomationPeer.cs
- ProcessHostMapPath.cs
- ToolStripEditorManager.cs
- PersonalizationStateInfo.cs
- Simplifier.cs
- FilterQuery.cs
- SecurityRequiresReviewAttribute.cs
- ContextQuery.cs
- CatchBlock.cs