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
- JobDuplex.cs
- DeadCharTextComposition.cs
- SatelliteContractVersionAttribute.cs
- DataSourceSelectArguments.cs
- DeclaredTypeValidatorAttribute.cs
- DocumentPageViewAutomationPeer.cs
- PocoEntityKeyStrategy.cs
- EntityProviderFactory.cs
- RegexCode.cs
- ProfileBuildProvider.cs
- CompModSwitches.cs
- DatePickerTextBox.cs
- CollectionViewSource.cs
- LogicalMethodInfo.cs
- InputProcessorProfiles.cs
- DataGridViewHeaderCell.cs
- DataGridCheckBoxColumn.cs
- BookmarkNameHelper.cs
- XmlSerializationGeneratedCode.cs
- AsyncCodeActivityContext.cs
- DataBinding.cs
- TableCellAutomationPeer.cs
- XmlSchemaAttribute.cs
- _ProxyChain.cs
- ReadOnlyHierarchicalDataSourceView.cs
- WSHttpSecurity.cs
- BitStack.cs
- FeedUtils.cs
- XamlReader.cs
- HelpEvent.cs
- RowType.cs
- CorrelationHandle.cs
- CompositeDataBoundControl.cs
- CreateParams.cs
- RichTextBox.cs
- PassportIdentity.cs
- Bidi.cs
- ConstructorNeedsTagAttribute.cs
- NumericUpDownAcceleration.cs
- ParameterCollection.cs
- basenumberconverter.cs
- BmpBitmapDecoder.cs
- DeleteMemberBinder.cs
- CorruptStoreException.cs
- SqlDataSourceSelectingEventArgs.cs
- StylusEditingBehavior.cs
- CompiledXpathExpr.cs
- SpeakInfo.cs
- DecoderFallback.cs
- XsltQilFactory.cs
- DomainUpDown.cs
- Dispatcher.cs
- ObjectComplexPropertyMapping.cs
- AppliesToBehaviorDecisionTable.cs
- BooleanFacetDescriptionElement.cs
- DefaultTraceListener.cs
- OracleInternalConnection.cs
- NumericUpDownAccelerationCollection.cs
- LinkedResource.cs
- CloseSequenceResponse.cs
- CodeDomLoader.cs
- ObjectHelper.cs
- InstanceDataCollection.cs
- DetailsViewDeleteEventArgs.cs
- ProtocolViolationException.cs
- DocumentStatusResources.cs
- WebPartZoneBase.cs
- DbMetaDataColumnNames.cs
- FreezableOperations.cs
- LongMinMaxAggregationOperator.cs
- VectorAnimationUsingKeyFrames.cs
- ReadOnlyDictionary.cs
- BooleanKeyFrameCollection.cs
- dbenumerator.cs
- Set.cs
- ISAPIWorkerRequest.cs
- ContentPosition.cs
- SaveFileDialog.cs
- RelationshipSet.cs
- SchemaManager.cs
- WhitespaceSignificantCollectionAttribute.cs
- GroupQuery.cs
- ComponentEditorPage.cs
- DataGridAutoFormat.cs
- WebContentFormatHelper.cs
- TextPatternIdentifiers.cs
- MethodAccessException.cs
- HttpInputStream.cs
- HtmlFormWrapper.cs
- PictureBoxDesigner.cs
- HealthMonitoringSection.cs
- SeekStoryboard.cs
- DeadCharTextComposition.cs
- RegexInterpreter.cs
- EventSetter.cs
- ProjectionCamera.cs
- XMLUtil.cs
- DataColumnMapping.cs
- CommandDesigner.cs
- SerialPort.cs