Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / InterOp / Imaging.cs / 2 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XsltOutput.cs
- TypeConstant.cs
- IncrementalCompileAnalyzer.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- ManifestResourceInfo.cs
- RuntimeVariablesExpression.cs
- New.cs
- SafeWaitHandle.cs
- ColorContext.cs
- MergeFailedEvent.cs
- AssemblyNameUtility.cs
- TypeSystemProvider.cs
- RewritingPass.cs
- XamlParser.cs
- XmlDigitalSignatureProcessor.cs
- SdlChannelSink.cs
- ClientOptions.cs
- ClientRuntimeConfig.cs
- ContainerAction.cs
- StateBag.cs
- TimeSpanMinutesConverter.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- Lease.cs
- ObfuscationAttribute.cs
- XsltQilFactory.cs
- Rule.cs
- LocationSectionRecord.cs
- Roles.cs
- PrinterResolution.cs
- InputReportEventArgs.cs
- DbMetaDataColumnNames.cs
- Win32PrintDialog.cs
- WebPartMenu.cs
- XmlAnyAttributeAttribute.cs
- ClickablePoint.cs
- CopyNamespacesAction.cs
- OperationAbortedException.cs
- IItemProperties.cs
- PresentationAppDomainManager.cs
- StringReader.cs
- ProxyGenerator.cs
- XamlFigureLengthSerializer.cs
- TextTreeRootNode.cs
- DependencyObjectValidator.cs
- MenuItemStyleCollectionEditor.cs
- LocatorGroup.cs
- ChannelBase.cs
- COM2ComponentEditor.cs
- ActivityExecutor.cs
- XXXInfos.cs
- InternalTransaction.cs
- SafeLibraryHandle.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- ScriptIgnoreAttribute.cs
- X509Utils.cs
- DbProviderFactory.cs
- CodeTypeParameterCollection.cs
- OdbcParameter.cs
- DataTableClearEvent.cs
- ZoneMembershipCondition.cs
- FixedDocumentSequencePaginator.cs
- FeatureManager.cs
- IFormattable.cs
- FilterElement.cs
- ConfigXmlComment.cs
- ZoneMembershipCondition.cs
- MultiSelector.cs
- PageParser.cs
- HyperLinkColumn.cs
- ApplicationActivator.cs
- Clock.cs
- XmlHierarchyData.cs
- CodeSnippetCompileUnit.cs
- TimelineGroup.cs
- __Filters.cs
- DefinitionUpdate.cs
- ExceptionHelpers.cs
- SplashScreenNativeMethods.cs
- TrustSection.cs
- Stopwatch.cs
- BufferedWebEventProvider.cs
- XmlWriterTraceListener.cs
- DataSourceDesigner.cs
- SurrogateSelector.cs
- DataObjectPastingEventArgs.cs
- ContentTextAutomationPeer.cs
- Rijndael.cs
- SimplePropertyEntry.cs
- CurrencyManager.cs
- CaretElement.cs
- TemplateControl.cs
- SEHException.cs
- XmlEncoding.cs
- OleDbReferenceCollection.cs
- VisualStateManager.cs
- GetPageNumberCompletedEventArgs.cs
- DrawingContextFlattener.cs
- TypeHelper.cs
- AutomationFocusChangedEventArgs.cs
- LineServices.cs