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
- FontConverter.cs
- ComboBox.cs
- BaseCollection.cs
- TextEditorContextMenu.cs
- PathSegment.cs
- RequestUriProcessor.cs
- TraceHelpers.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- OdbcConnectionPoolProviderInfo.cs
- SimpleWorkerRequest.cs
- EastAsianLunisolarCalendar.cs
- Viewport3DAutomationPeer.cs
- Rect.cs
- cookiecontainer.cs
- DesignerTransaction.cs
- SerialPort.cs
- DocumentCollection.cs
- PaintEvent.cs
- CompressedStack.cs
- ListSurrogate.cs
- HttpListenerPrefixCollection.cs
- FolderBrowserDialog.cs
- xmlformatgeneratorstatics.cs
- ListViewInsertEventArgs.cs
- ControlPaint.cs
- ComponentEvent.cs
- PartBasedPackageProperties.cs
- BinaryNode.cs
- Icon.cs
- GACIdentityPermission.cs
- EmulateRecognizeCompletedEventArgs.cs
- DateTimeFormatInfo.cs
- IdnElement.cs
- securitycriticaldataformultiplegetandset.cs
- MimeTypeAttribute.cs
- EmptyImpersonationContext.cs
- MethodCallConverter.cs
- GregorianCalendarHelper.cs
- AuthorizationSection.cs
- StringExpressionSet.cs
- ExecutionEngineException.cs
- SecurityElement.cs
- Rotation3D.cs
- DbDataRecord.cs
- StringFreezingAttribute.cs
- GraphicsState.cs
- ByteArrayHelperWithString.cs
- RealizedColumnsBlock.cs
- GiveFeedbackEvent.cs
- SplitContainer.cs
- ControlAdapter.cs
- Soap.cs
- PluggableProtocol.cs
- XmlQualifiedName.cs
- InvalidProgramException.cs
- Utils.cs
- PolyQuadraticBezierSegment.cs
- HtmlEmptyTagControlBuilder.cs
- LinkLabel.cs
- SkinBuilder.cs
- FigureHelper.cs
- Compiler.cs
- MarkupWriter.cs
- ExceptionHandler.cs
- LongValidator.cs
- SqlUserDefinedAggregateAttribute.cs
- metrodevice.cs
- MemberRestriction.cs
- AssemblyCollection.cs
- DocumentViewer.cs
- DataGridItemEventArgs.cs
- Currency.cs
- DataGridColumnCollectionEditor.cs
- WsdlParser.cs
- WsiProfilesElementCollection.cs
- HtmlInputButton.cs
- ChildChangedEventArgs.cs
- TextTreeDeleteContentUndoUnit.cs
- SizeAnimationClockResource.cs
- UnsafeNativeMethodsPenimc.cs
- CommandID.cs
- formatter.cs
- StringFunctions.cs
- MediaElement.cs
- TransactionScope.cs
- Point3DCollection.cs
- DataStreamFromComStream.cs
- BufferAllocator.cs
- UshortList2.cs
- ActiveXSite.cs
- TextDpi.cs
- HttpSocketManager.cs
- AuthenticationException.cs
- LineInfo.cs
- HtmlInputRadioButton.cs
- LabelTarget.cs
- WebPartZoneBase.cs
- ConnectivityStatus.cs
- DeclaredTypeValidator.cs
- StackOverflowException.cs