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
- NamespaceList.cs
- SystemKeyConverter.cs
- PEFileEvidenceFactory.cs
- FilterQuery.cs
- ColorTranslator.cs
- CurrencyWrapper.cs
- ListViewTableCell.cs
- SiteOfOriginContainer.cs
- NameValuePermission.cs
- Subtree.cs
- ClientSponsor.cs
- KeyGestureConverter.cs
- XmlChildNodes.cs
- OutputCacheProfile.cs
- Crc32Helper.cs
- XmlSchemaNotation.cs
- BufferedGraphicsManager.cs
- ToggleButton.cs
- XpsResourcePolicy.cs
- BoolLiteral.cs
- Visual3D.cs
- XmlWriterSettings.cs
- RegexWorker.cs
- ComboBoxHelper.cs
- SqlGenericUtil.cs
- GraphicsContainer.cs
- BitmapEffectRenderDataResource.cs
- TreeNodeSelectionProcessor.cs
- SetterTriggerConditionValueConverter.cs
- GenericIdentity.cs
- WriteStateInfoBase.cs
- BinaryUtilClasses.cs
- SiteMapDataSourceView.cs
- XmlStringTable.cs
- AppSettingsExpressionBuilder.cs
- BindingParameterCollection.cs
- CollectionBuilder.cs
- StreamUpdate.cs
- LassoSelectionBehavior.cs
- TextRangeProviderWrapper.cs
- SystemUdpStatistics.cs
- NetworkInformationPermission.cs
- ImageListUtils.cs
- SBCSCodePageEncoding.cs
- ToolStripDropTargetManager.cs
- SqlColumnizer.cs
- TextBox.cs
- DescendantOverDescendantQuery.cs
- PageSetupDialog.cs
- ArgumentFixer.cs
- XmlSchemaSimpleContent.cs
- GridViewCommandEventArgs.cs
- UnauthorizedAccessException.cs
- FloaterBaseParaClient.cs
- TemplateBaseAction.cs
- ContentType.cs
- ScriptResourceHandler.cs
- RemotingConfiguration.cs
- TypeConverterHelper.cs
- DbProviderServices.cs
- DataTemplateSelector.cs
- XmlAttributeCollection.cs
- ContextMenuStrip.cs
- Directory.cs
- NativeObjectSecurity.cs
- XmlFormatExtensionAttribute.cs
- ChannelManagerBase.cs
- ExecutionScope.cs
- TableLayoutCellPaintEventArgs.cs
- TypeConverterValueSerializer.cs
- UriExt.cs
- RuleSettingsCollection.cs
- ValidatorUtils.cs
- Membership.cs
- FilterQuery.cs
- ExtendedPropertyDescriptor.cs
- IconBitmapDecoder.cs
- Task.cs
- DashStyles.cs
- DeferredBinaryDeserializerExtension.cs
- HMACSHA1.cs
- UpdateManifestForBrowserApplication.cs
- ClientTargetCollection.cs
- XmlNullResolver.cs
- ReflectEventDescriptor.cs
- AuthenticationManager.cs
- SqlDataSource.cs
- RegexTree.cs
- PropertyCondition.cs
- SerializationAttributes.cs
- AudioSignalProblemOccurredEventArgs.cs
- CodeAttachEventStatement.cs
- SymbolMethod.cs
- AttributeQuery.cs
- XmlWrappingWriter.cs
- SafeArrayRankMismatchException.cs
- ImageField.cs
- Font.cs
- SizeConverter.cs
- BodyWriter.cs