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
- SharedStream.cs
- CompiledRegexRunnerFactory.cs
- ConnectionManager.cs
- HttpHeaderCollection.cs
- PropertyInfoSet.cs
- FixedPageStructure.cs
- PermissionToken.cs
- AutomationElementIdentifiers.cs
- TreeSet.cs
- Vector3DAnimationUsingKeyFrames.cs
- DefaultEvaluationContext.cs
- HtmlMeta.cs
- CopyOnWriteList.cs
- baseaxisquery.cs
- EditorAttribute.cs
- SQLResource.cs
- AdjustableArrowCap.cs
- compensatingcollection.cs
- EventLogPermissionEntryCollection.cs
- LazyTextWriterCreator.cs
- WindowPattern.cs
- ExeConfigurationFileMap.cs
- RoleManagerSection.cs
- RegistryPermission.cs
- HtmlImage.cs
- RankException.cs
- Duration.cs
- DelegateHelpers.Generated.cs
- TemplateBaseAction.cs
- XmlSerializerAssemblyAttribute.cs
- PriorityBinding.cs
- storepermission.cs
- SimpleLine.cs
- GenerateTemporaryTargetAssembly.cs
- FocusChangedEventArgs.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ArgumentOutOfRangeException.cs
- ToolStripOverflowButton.cs
- MulticastIPAddressInformationCollection.cs
- DataComponentNameHandler.cs
- FloaterParagraph.cs
- InputDevice.cs
- DataGridColumnCollectionEditor.cs
- PeerNameRegistration.cs
- NamespaceCollection.cs
- BaseTemplateBuildProvider.cs
- CertificateManager.cs
- DBCommandBuilder.cs
- BindUriHelper.cs
- CompiledAction.cs
- DiagnosticsConfigurationHandler.cs
- XPathItem.cs
- CfgSemanticTag.cs
- MenuAutoFormat.cs
- shaperfactoryquerycacheentry.cs
- RangeBaseAutomationPeer.cs
- XmlDictionaryReader.cs
- TextEndOfLine.cs
- BackgroundFormatInfo.cs
- HMACSHA512.cs
- UserControlBuildProvider.cs
- XsltCompileContext.cs
- SmtpNegotiateAuthenticationModule.cs
- XmlUrlResolver.cs
- DropShadowEffect.cs
- TypeSystem.cs
- TemplateKeyConverter.cs
- ObjectViewListener.cs
- MouseCaptureWithinProperty.cs
- WaitHandleCannotBeOpenedException.cs
- keycontainerpermission.cs
- DataStreamFromComStream.cs
- SpecialNameAttribute.cs
- XmlAttributeProperties.cs
- SettingsPropertyValueCollection.cs
- AdornerPresentationContext.cs
- SqlMethods.cs
- FileRecordSequenceHelper.cs
- ColorPalette.cs
- ServicePoint.cs
- Freezable.cs
- TimeZone.cs
- Int32CollectionConverter.cs
- ComponentSerializationService.cs
- AvTrace.cs
- TargetParameterCountException.cs
- Vector3D.cs
- DataServiceHost.cs
- XmlnsCache.cs
- QilStrConcatenator.cs
- XmlHierarchicalEnumerable.cs
- DataGridViewDataErrorEventArgs.cs
- EmptyReadOnlyDictionaryInternal.cs
- ExpanderAutomationPeer.cs
- OleDbRowUpdatedEvent.cs
- SpStreamWrapper.cs
- TextTreeTextBlock.cs
- EntityDataSourceContextDisposingEventArgs.cs
- Certificate.cs
- UnsafeNativeMethods.cs