Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / InterOp / Imaging.cs / 1 / 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: dwaynen (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: dwaynen (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
- EventLogHandle.cs
- FontInfo.cs
- HttpCapabilitiesBase.cs
- PageThemeCodeDomTreeGenerator.cs
- TextSelectionHighlightLayer.cs
- Hash.cs
- CultureTableRecord.cs
- ContentFileHelper.cs
- RunInstallerAttribute.cs
- EventBookmark.cs
- ObjectQueryState.cs
- ObjectNotFoundException.cs
- TextParagraph.cs
- WebBrowserDocumentCompletedEventHandler.cs
- BoundingRectTracker.cs
- DataGridViewColumnEventArgs.cs
- ParameterRefs.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- ImageEditor.cs
- TextSelectionHelper.cs
- GridEntryCollection.cs
- ValidatorAttribute.cs
- GeneralTransformGroup.cs
- WebPartConnectionsEventArgs.cs
- RequestQueue.cs
- SQLMoneyStorage.cs
- DocumentPage.cs
- DataGridView.cs
- MarshalDirectiveException.cs
- ToolStripSplitStackLayout.cs
- DataGridViewCellParsingEventArgs.cs
- DtdParser.cs
- PenContext.cs
- XmlTextEncoder.cs
- TemplatedMailWebEventProvider.cs
- EncodingInfo.cs
- SymmetricKey.cs
- ArithmeticException.cs
- AutomationPatternInfo.cs
- CompilerTypeWithParams.cs
- ListViewItemSelectionChangedEvent.cs
- WebControlsSection.cs
- CFStream.cs
- TransportOutputChannel.cs
- GridViewRowCollection.cs
- TypeToken.cs
- FastEncoderWindow.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- PrintSchema.cs
- Light.cs
- SmtpLoginAuthenticationModule.cs
- IPEndPoint.cs
- ExpressionLexer.cs
- PointAnimationBase.cs
- TimerElapsedEvenArgs.cs
- ResourceAttributes.cs
- VirtualDirectoryMapping.cs
- CrossSiteScriptingValidation.cs
- MessageSmuggler.cs
- OleStrCAMarshaler.cs
- EntryWrittenEventArgs.cs
- ContentDefinition.cs
- UnsafeNativeMethods.cs
- FormViewInsertEventArgs.cs
- RequestCachePolicy.cs
- NavigationFailedEventArgs.cs
- ClaimComparer.cs
- DataTableReaderListener.cs
- PolicyStatement.cs
- ControlCachePolicy.cs
- SmiEventSink_Default.cs
- MasterPageBuildProvider.cs
- EntityViewContainer.cs
- InvalidDataContractException.cs
- Exception.cs
- TraceHandlerErrorFormatter.cs
- Rectangle.cs
- WebPartConnectionsCloseVerb.cs
- compensatingcollection.cs
- ItemDragEvent.cs
- CultureInfoConverter.cs
- ContextStaticAttribute.cs
- BitArray.cs
- AutomationProperty.cs
- ResXResourceReader.cs
- CharacterString.cs
- ExtensionSimplifierMarkupObject.cs
- Stopwatch.cs
- LayoutManager.cs
- VersionedStreamOwner.cs
- ToolboxDataAttribute.cs
- TrackingRecord.cs
- FrameworkContentElement.cs
- TreeBuilder.cs
- ExpressionPrefixAttribute.cs
- RegionIterator.cs
- MediaEntryAttribute.cs
- WebPartDeleteVerb.cs
- FactoryMaker.cs
- SimpleModelProvider.cs