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
- IntellisenseTextBox.cs
- DispatcherOperation.cs
- DetailsViewCommandEventArgs.cs
- StateMachineDesignerPaint.cs
- PartialList.cs
- WebPartManager.cs
- SoapFault.cs
- ControlUtil.cs
- ReflectEventDescriptor.cs
- PropertyManager.cs
- Parallel.cs
- Debug.cs
- GroupItemAutomationPeer.cs
- DataRelationPropertyDescriptor.cs
- PrimitiveType.cs
- GraphicsState.cs
- WebBrowserProgressChangedEventHandler.cs
- SettingsBindableAttribute.cs
- ResourceExpression.cs
- BinaryFormatterWriter.cs
- CannotUnloadAppDomainException.cs
- COM2FontConverter.cs
- XAMLParseException.cs
- controlskin.cs
- MemberJoinTreeNode.cs
- ServicePointManagerElement.cs
- Attributes.cs
- SpoolingTask.cs
- Rule.cs
- Control.cs
- CompilerGlobalScopeAttribute.cs
- PolyBezierSegmentFigureLogic.cs
- ValidatorUtils.cs
- InstanceKeyView.cs
- ExtensionQuery.cs
- PersonalizableAttribute.cs
- PixelFormat.cs
- RuntimeTrackingProfile.cs
- FormsAuthenticationUser.cs
- DllNotFoundException.cs
- FixedSOMPageElement.cs
- MsmqTransportSecurityElement.cs
- Inflater.cs
- XmlChoiceIdentifierAttribute.cs
- ToolbarAUtomationPeer.cs
- RewritingPass.cs
- BitmapImage.cs
- ColumnWidthChangingEvent.cs
- Deserializer.cs
- DataPagerFieldItem.cs
- TypeForwardedToAttribute.cs
- XmlDsigSep2000.cs
- FragmentQuery.cs
- Win32KeyboardDevice.cs
- SliderAutomationPeer.cs
- ContractUtils.cs
- Label.cs
- SamlAssertion.cs
- StylusCaptureWithinProperty.cs
- AttributeSetAction.cs
- DataSourceCacheDurationConverter.cs
- SystemInfo.cs
- FormatConvertedBitmap.cs
- DataPagerCommandEventArgs.cs
- NetworkAddressChange.cs
- RegistryPermission.cs
- WebPartEditVerb.cs
- ChangePassword.cs
- EntityDataSourceUtil.cs
- ParseNumbers.cs
- KeyTime.cs
- TargetControlTypeCache.cs
- Vector3DCollectionConverter.cs
- StatusStrip.cs
- WindowsGrip.cs
- ParameterCollection.cs
- TableCellCollection.cs
- CurrentTimeZone.cs
- AssemblyBuilderData.cs
- WorkflowMarkupSerializerMapping.cs
- StructuredTypeInfo.cs
- SmtpAuthenticationManager.cs
- BamlLocalizationDictionary.cs
- Stacktrace.cs
- PropertyGeneratedEventArgs.cs
- HitTestFilterBehavior.cs
- DataBoundControlHelper.cs
- GradientStopCollection.cs
- FrameworkName.cs
- StylusCaptureWithinProperty.cs
- MessageQueueCriteria.cs
- DropShadowEffect.cs
- PageVisual.cs
- DataGridViewSelectedColumnCollection.cs
- Interlocked.cs
- ImpersonationContext.cs
- VectorCollection.cs
- DbQueryCommandTree.cs
- ProcessModelSection.cs
- ThumbAutomationPeer.cs