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
- MapPathBasedVirtualPathProvider.cs
 - SecurityUniqueId.cs
 - ImageBrush.cs
 - DbConnectionPoolGroup.cs
 - StyleTypedPropertyAttribute.cs
 - Bits.cs
 - Pipe.cs
 - SignedInfo.cs
 - BindMarkupExtensionSerializer.cs
 - PipelineComponent.cs
 - OperationExecutionFault.cs
 - UriTemplateTable.cs
 - DataGridViewTextBoxCell.cs
 - UITypeEditors.cs
 - GeometryConverter.cs
 - CatalogPartDesigner.cs
 - CustomGrammar.cs
 - AppearanceEditorPart.cs
 - HTTPNotFoundHandler.cs
 - mda.cs
 - BamlVersionHeader.cs
 - ipaddressinformationcollection.cs
 - Translator.cs
 - ToolboxItemLoader.cs
 - WebServiceClientProxyGenerator.cs
 - CommandBindingCollection.cs
 - CompensatableSequenceActivity.cs
 - SqlDataSourceView.cs
 - GuidConverter.cs
 - EntitySet.cs
 - WebFormDesignerActionService.cs
 - SqlParameterizer.cs
 - DataGridViewButtonCell.cs
 - HtmlTableCell.cs
 - Preprocessor.cs
 - XmlDictionaryReaderQuotas.cs
 - System.Data_BID.cs
 - COM2ExtendedBrowsingHandler.cs
 - KeyValueConfigurationElement.cs
 - ContainerVisual.cs
 - UTF7Encoding.cs
 - FileSecurity.cs
 - ReceiveActivityDesignerTheme.cs
 - IncrementalCompileAnalyzer.cs
 - CalloutQueueItem.cs
 - baseaxisquery.cs
 - TemplateControlBuildProvider.cs
 - CapabilitiesRule.cs
 - WizardPanel.cs
 - ActiveXContainer.cs
 - TrackPoint.cs
 - XmlUrlEditor.cs
 - DataGridItemAutomationPeer.cs
 - ValidatingReaderNodeData.cs
 - ListControlDesigner.cs
 - FaultCode.cs
 - DesignTimeTemplateParser.cs
 - SoapAttributes.cs
 - URLIdentityPermission.cs
 - SerializationUtilities.cs
 - SpellerStatusTable.cs
 - HttpListenerPrefixCollection.cs
 - BrushConverter.cs
 - Animatable.cs
 - RequestQueue.cs
 - ResourceDescriptionAttribute.cs
 - WorkflowRuntimeEndpoint.cs
 - PersistenceTypeAttribute.cs
 - BaseResourcesBuildProvider.cs
 - DesignerAttribute.cs
 - ProcessProtocolHandler.cs
 - InstanceDescriptor.cs
 - Line.cs
 - NonSerializedAttribute.cs
 - FunctionImportMapping.ReturnTypeRenameMapping.cs
 - XmlCharType.cs
 - ClientUrlResolverWrapper.cs
 - TextRenderer.cs
 - MouseEventArgs.cs
 - HtmlGenericControl.cs
 - RichTextBox.cs
 - Util.cs
 - SymLanguageVendor.cs
 - Profiler.cs
 - TimeStampChecker.cs
 - Propagator.cs
 - XmlSignatureProperties.cs
 - UnsafeNativeMethods.cs
 - CopyNamespacesAction.cs
 - DataFieldConverter.cs
 - PartManifestEntry.cs
 - SqlBinder.cs
 - entitydatasourceentitysetnameconverter.cs
 - HtmlInputHidden.cs
 - PluralizationServiceUtil.cs
 - RemoteWebConfigurationHost.cs
 - AddInBase.cs
 - LogEntryHeaderDeserializer.cs
 - HtmlLink.cs
 - ManifestBasedResourceGroveler.cs