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
- BitmapVisualManager.cs
- CompModSwitches.cs
- PageTrueTypeFont.cs
- LinkLabel.cs
- TextMessageEncodingElement.cs
- GridViewEditEventArgs.cs
- TextEditorLists.cs
- _StreamFramer.cs
- StringUtil.cs
- ListControl.cs
- MoveSizeWinEventHandler.cs
- StringValueSerializer.cs
- AvTrace.cs
- CryptoStream.cs
- ProxySimple.cs
- FormsAuthenticationModule.cs
- SQLDecimalStorage.cs
- CounterCreationDataCollection.cs
- wgx_exports.cs
- ClientEndpointLoader.cs
- ViewStateModeByIdAttribute.cs
- SchemaNames.cs
- BrushConverter.cs
- WebPartHeaderCloseVerb.cs
- ArraySubsetEnumerator.cs
- GroupQuery.cs
- FileSystemInfo.cs
- OleDbParameter.cs
- OciEnlistContext.cs
- XMLDiffLoader.cs
- templategroup.cs
- MD5HashHelper.cs
- UITypeEditor.cs
- MethodCallConverter.cs
- RichTextBoxConstants.cs
- DesignerAdapterUtil.cs
- AdPostCacheSubstitution.cs
- EntityCodeGenerator.cs
- Events.cs
- UpDownBase.cs
- WindowsEditBoxRange.cs
- DataGridViewLayoutData.cs
- NumberSubstitution.cs
- FocusManager.cs
- Quad.cs
- EventLevel.cs
- WinFormsUtils.cs
- DataServiceClientException.cs
- DbBuffer.cs
- TemplateControlCodeDomTreeGenerator.cs
- DataListCommandEventArgs.cs
- MemberListBinding.cs
- TrustSection.cs
- TokenizerHelper.cs
- KeyGestureConverter.cs
- TextEncodedRawTextWriter.cs
- ActivityTrace.cs
- RoleGroupCollection.cs
- Vector.cs
- EnvelopedSignatureTransform.cs
- IndicFontClient.cs
- WebPartVerbCollection.cs
- Path.cs
- SqlWebEventProvider.cs
- SqlDelegatedTransaction.cs
- SessionParameter.cs
- ReflectPropertyDescriptor.cs
- ButtonColumn.cs
- ImageAttributes.cs
- ButtonFieldBase.cs
- ProfileProvider.cs
- CopyAction.cs
- CornerRadiusConverter.cs
- TableRowGroup.cs
- AnimationClockResource.cs
- WSUtilitySpecificationVersion.cs
- PluralizationServiceUtil.cs
- CqlBlock.cs
- BitmapEffectGroup.cs
- DrawingGroup.cs
- Evidence.cs
- ParallelActivityDesigner.cs
- GrammarBuilderWildcard.cs
- VirtualPathProvider.cs
- MachinePropertyVariants.cs
- GridViewDeleteEventArgs.cs
- Latin1Encoding.cs
- ComPlusTypeLoader.cs
- Point3DIndependentAnimationStorage.cs
- SubMenuStyleCollection.cs
- EntityType.cs
- SafeNativeMethodsMilCoreApi.cs
- DictationGrammar.cs
- LinkButton.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- URI.cs
- PageBreakRecord.cs
- EncoderNLS.cs
- DatePickerTextBox.cs
- _SSPISessionCache.cs