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
- PeerValidationBehavior.cs
- BaseParaClient.cs
- EmptyStringExpandableObjectConverter.cs
- LocalFileSettingsProvider.cs
- BitmapSizeOptions.cs
- ReadOnlyDataSourceView.cs
- DesignerValidatorAdapter.cs
- FrameworkTemplate.cs
- safelinkcollection.cs
- NumberFunctions.cs
- ColumnHeader.cs
- ViewPort3D.cs
- KeyValueConfigurationElement.cs
- SmtpFailedRecipientsException.cs
- CodeAccessSecurityEngine.cs
- DBParameter.cs
- errorpatternmatcher.cs
- MetadataCollection.cs
- IteratorFilter.cs
- RuntimeHelpers.cs
- FullTextBreakpoint.cs
- ApplicationBuildProvider.cs
- SelectorAutomationPeer.cs
- TabPage.cs
- HijriCalendar.cs
- Deflater.cs
- FixedDSBuilder.cs
- MethodBuilderInstantiation.cs
- ResourceExpressionBuilder.cs
- StrokeNodeEnumerator.cs
- CompositionDesigner.cs
- baseaxisquery.cs
- VectorAnimationBase.cs
- BooleanConverter.cs
- NameValueSectionHandler.cs
- WebColorConverter.cs
- ColumnMap.cs
- TraceListeners.cs
- PersonalizationProvider.cs
- DrawingContextWalker.cs
- _AuthenticationState.cs
- DocumentReference.cs
- WindowsListViewItemCheckBox.cs
- CollectionView.cs
- XmlQualifiedName.cs
- IconBitmapDecoder.cs
- OdbcConnectionPoolProviderInfo.cs
- ClockGroup.cs
- SubclassTypeValidator.cs
- CallbackDebugElement.cs
- PopupRootAutomationPeer.cs
- ActivityExecutionContextCollection.cs
- MessagingActivityHelper.cs
- AppSettingsReader.cs
- VerticalAlignConverter.cs
- ScopeElement.cs
- Evidence.cs
- SqlBulkCopyColumnMapping.cs
- GenericUI.cs
- EntityObject.cs
- PackageRelationship.cs
- WebHeaderCollection.cs
- MenuCommands.cs
- TailPinnedEventArgs.cs
- PreviewPageInfo.cs
- WebBaseEventKeyComparer.cs
- TextTreeDeleteContentUndoUnit.cs
- RoutedEventValueSerializer.cs
- BrushMappingModeValidation.cs
- DataServiceBuildProvider.cs
- BindingsCollection.cs
- MexTcpBindingCollectionElement.cs
- FunctionDefinition.cs
- DirectoryRedirect.cs
- DispatcherSynchronizationContext.cs
- SelectorItemAutomationPeer.cs
- ManipulationLogic.cs
- RayMeshGeometry3DHitTestResult.cs
- DetailsViewPagerRow.cs
- DesignerDataConnection.cs
- EntitySqlQueryState.cs
- WorkflowOperationErrorHandler.cs
- SchemaAttDef.cs
- RelatedImageListAttribute.cs
- BridgeDataReader.cs
- ScrollPattern.cs
- InterleavedZipPartStream.cs
- Sql8ConformanceChecker.cs
- ClientConfigurationSystem.cs
- ItemMap.cs
- ForceCopyBuildProvider.cs
- XmlExceptionHelper.cs
- ApplicationSettingsBase.cs
- SchemaImporterExtensionsSection.cs
- HtmlEmptyTagControlBuilder.cs
- SimpleRecyclingCache.cs
- EditorPart.cs
- EditorZoneDesigner.cs
- sitestring.cs
- PathSegment.cs