Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- translator.cs
- Section.cs
- TextEditorContextMenu.cs
- ProcessHostServerConfig.cs
- RowUpdatedEventArgs.cs
- SoapObjectReader.cs
- BamlRecordWriter.cs
- StylusEditingBehavior.cs
- GlyphRunDrawing.cs
- TreeNodeBindingDepthConverter.cs
- ExpandableObjectConverter.cs
- QueryIntervalOp.cs
- TableDetailsCollection.cs
- TextElementEnumerator.cs
- CreateUserWizardStep.cs
- RepeatBehavior.cs
- Point4DConverter.cs
- AnnotationAuthorChangedEventArgs.cs
- PartialClassGenerationTask.cs
- Gdiplus.cs
- InkPresenterAutomationPeer.cs
- UIHelper.cs
- FlowDocumentReaderAutomationPeer.cs
- SchemaElementDecl.cs
- CircleEase.cs
- Mutex.cs
- ConstructorNeedsTagAttribute.cs
- PointLightBase.cs
- SlipBehavior.cs
- ThaiBuddhistCalendar.cs
- MultiView.cs
- IInstanceContextProvider.cs
- TraceHandler.cs
- DataControlFieldHeaderCell.cs
- DatePickerTextBox.cs
- QuotedPairReader.cs
- SymDocumentType.cs
- SchemaNamespaceManager.cs
- WebAdminConfigurationHelper.cs
- XmlAttributes.cs
- RuleProcessor.cs
- DropTarget.cs
- ParallelTimeline.cs
- ToggleButton.cs
- Parser.cs
- EdmProviderManifest.cs
- ContextQuery.cs
- WindowsFormsHelpers.cs
- DayRenderEvent.cs
- CultureTableRecord.cs
- DataGridViewColumnCollection.cs
- __TransparentProxy.cs
- WebMessageBodyStyleHelper.cs
- TraceInternal.cs
- ObjectQuery_EntitySqlExtensions.cs
- DataSourceSelectArguments.cs
- ConstructorBuilder.cs
- ActivityXRefConverter.cs
- TableHeaderCell.cs
- CommandManager.cs
- HttpConfigurationSystem.cs
- Invariant.cs
- ConditionalAttribute.cs
- MaterialGroup.cs
- TypeConverterHelper.cs
- ActivityExecutionFilter.cs
- ApplicationSecurityInfo.cs
- ScrollData.cs
- ReflectionTypeLoadException.cs
- Environment.cs
- shaperfactory.cs
- DesignerHelpers.cs
- FrameworkContentElement.cs
- QuaternionIndependentAnimationStorage.cs
- ConfigXmlSignificantWhitespace.cs
- TypeCollectionDesigner.xaml.cs
- ArcSegment.cs
- ExceptionValidationRule.cs
- CacheOutputQuery.cs
- SelectionList.cs
- DateTimeParse.cs
- ConditionalWeakTable.cs
- MonitorWrapper.cs
- ConstraintManager.cs
- WebPartExportVerb.cs
- GeometryCombineModeValidation.cs
- CircleHotSpot.cs
- ArglessEventHandlerProxy.cs
- EntityCommandExecutionException.cs
- GrammarBuilder.cs
- Int32Animation.cs
- SrgsElementList.cs
- TreeNodeCollection.cs
- CollectionViewProxy.cs
- ColorConvertedBitmapExtension.cs
- ShapingEngine.cs
- SqlUdtInfo.cs
- versioninfo.cs
- InOutArgument.cs
- Msmq4SubqueuePoisonHandler.cs