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
- FixedSOMTableCell.cs
- AppDomainProtocolHandler.cs
- MediaCommands.cs
- HwndProxyElementProvider.cs
- _AutoWebProxyScriptHelper.cs
- ModuleElement.cs
- EncryptedXml.cs
- GridViewCellAutomationPeer.cs
- X509Certificate.cs
- Point3D.cs
- ColorTranslator.cs
- RandomNumberGenerator.cs
- BinaryUtilClasses.cs
- ObjectCloneHelper.cs
- TableItemProviderWrapper.cs
- DesignerVerbCollection.cs
- ModelTreeEnumerator.cs
- WindowProviderWrapper.cs
- RunClient.cs
- DataServiceStreamProviderWrapper.cs
- TemplateKeyConverter.cs
- PackagePart.cs
- LockingPersistenceProvider.cs
- TableRow.cs
- FormsIdentity.cs
- SafeArchiveContext.cs
- XmlSequenceWriter.cs
- WizardStepBase.cs
- TemplatedWizardStep.cs
- EmissiveMaterial.cs
- QueryableDataSourceEditData.cs
- DynamicResourceExtension.cs
- SamlAttributeStatement.cs
- Crc32Helper.cs
- StreamReader.cs
- EventProviderWriter.cs
- X509ClientCertificateAuthentication.cs
- ModuleBuilderData.cs
- DetailsViewInsertedEventArgs.cs
- EventManager.cs
- MailAddress.cs
- RequestStatusBarUpdateEventArgs.cs
- XmlNodeReader.cs
- FileSystemWatcher.cs
- RuleAttributes.cs
- OSEnvironmentHelper.cs
- BinaryObjectInfo.cs
- FormsIdentity.cs
- JavaScriptString.cs
- AssemblyResourceLoader.cs
- DataReceivedEventArgs.cs
- ConfigXmlCDataSection.cs
- TailPinnedEventArgs.cs
- RuleProcessor.cs
- ReturnValue.cs
- ButtonColumn.cs
- SqlUtil.cs
- RSAPKCS1SignatureDeformatter.cs
- DataException.cs
- ScriptResourceHandler.cs
- XmlSerializationGeneratedCode.cs
- ConfigPathUtility.cs
- ItemsChangedEventArgs.cs
- KeyValueInternalCollection.cs
- DesignerView.Commands.cs
- ReceiveContext.cs
- ContentPosition.cs
- ChildrenQuery.cs
- PrintPageEvent.cs
- TraceEventCache.cs
- MenuItem.cs
- VerbConverter.cs
- TableAdapterManagerMethodGenerator.cs
- XPathSelfQuery.cs
- DataControlExtensions.cs
- RuntimeIdentifierPropertyAttribute.cs
- BooleanToVisibilityConverter.cs
- DbUpdateCommandTree.cs
- ContainerAction.cs
- DiscoveryDocument.cs
- Rotation3DAnimationBase.cs
- ToolboxDataAttribute.cs
- ApplicationServiceHelper.cs
- XmlSchemaProviderAttribute.cs
- BatchParser.cs
- TerminatingOperationBehavior.cs
- SimpleWebHandlerParser.cs
- TextServicesCompartment.cs
- RawStylusInputCustomDataList.cs
- VideoDrawing.cs
- InputScopeNameConverter.cs
- SoundPlayer.cs
- TextServicesManager.cs
- SchemaImporterExtension.cs
- DataGridCellClipboardEventArgs.cs
- XmlTextAttribute.cs
- GroupBoxRenderer.cs
- IListConverters.cs
- LambdaCompiler.Expressions.cs
- XPathCompiler.cs