Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media / Imaging / UnmanagedBitmapWrapper.cs / 1 / UnmanagedBitmapWrapper.cs
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation. All Rights Reserved.
//
// File: UnmanagedBitmapWrapper.cs
//
//-----------------------------------------------------------------------------
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using MS.Internal;
using MS.Win32.PresentationCore;
using System.Security;
using System.Security.Permissions;
using System.Diagnostics;
using System.Windows.Media;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using MS.Internal.PresentationCore;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.Imaging
{
internal sealed class UnmanagedBitmapWrapper : System.Windows.Media.Imaging.BitmapSource
{
///
/// Critical - calls critical code method BitmapSource.UpdateCachedSettings
/// TreatAsSafe - all inputs are checked
///
[SecurityCritical, SecurityTreatAsSafe]
public UnmanagedBitmapWrapper(BitmapSourceSafeMILHandle bitmapSource) :
base(true)
{
_bitmapInit.BeginInit();
bitmapSource.CalculateSize();
WicSourceHandle = bitmapSource;
_bitmapInit.EndInit();
UpdateCachedSettings();
}
#region Protected Methods
///
/// Critical - eventually access'es critical resources (_wicSource)
/// TreatAsSafe - all inputs are checked
///
[SecurityCritical, SecurityTreatAsSafe]
internal UnmanagedBitmapWrapper(bool initialize) :
base(true)
{
// Call BeginInit and EndInit if initialize is true.
if (initialize)
{
_bitmapInit.BeginInit();
_bitmapInit.EndInit();
}
}
///
/// Critical - calls critical code method BitmapSource.UpdateCachedSettings
/// TreatAsSafe - all inputs are checked
///
[SecurityCritical, SecurityTreatAsSafe]
internal void UpdateBitmapSource(BitmapSource bitmapSource, DUCE.Channel channel)
{
WicSourceHandle = bitmapSource.WicSourceHandle;
UpdateCachedSettings();
_needsUpdate = true;
UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ );
}
///
/// Implementation of Freezable.CreateInstanceCore .
///
protected override Freezable CreateInstanceCore()
{
return new UnmanagedBitmapWrapper(false);
}
private void CopyCommon(UnmanagedBitmapWrapper sourceBitmap)
{
_bitmapInit.BeginInit();
_bitmapInit.EndInit();
}
///
/// Implementation of Freezable.CloneCore .
///
protected override void CloneCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.CloneCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
///
/// Implementation of Freezable.CloneCurrentValueCore .
///
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.CloneCurrentValueCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
///
/// Implementation of Freezable.GetAsFrozenCore .
///
protected override void GetAsFrozenCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.GetAsFrozenCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
///
/// Implementation of Freezable.GetCurrentValueAsFrozenCore .
///
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.GetCurrentValueAsFrozenCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation. All Rights Reserved.
//
// File: UnmanagedBitmapWrapper.cs
//
//-----------------------------------------------------------------------------
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using MS.Internal;
using MS.Win32.PresentationCore;
using System.Security;
using System.Security.Permissions;
using System.Diagnostics;
using System.Windows.Media;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using MS.Internal.PresentationCore;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.Imaging
{
internal sealed class UnmanagedBitmapWrapper : System.Windows.Media.Imaging.BitmapSource
{
///
/// Critical - calls critical code method BitmapSource.UpdateCachedSettings
/// TreatAsSafe - all inputs are checked
///
[SecurityCritical, SecurityTreatAsSafe]
public UnmanagedBitmapWrapper(BitmapSourceSafeMILHandle bitmapSource) :
base(true)
{
_bitmapInit.BeginInit();
bitmapSource.CalculateSize();
WicSourceHandle = bitmapSource;
_bitmapInit.EndInit();
UpdateCachedSettings();
}
#region Protected Methods
///
/// Critical - eventually access'es critical resources (_wicSource)
/// TreatAsSafe - all inputs are checked
///
[SecurityCritical, SecurityTreatAsSafe]
internal UnmanagedBitmapWrapper(bool initialize) :
base(true)
{
// Call BeginInit and EndInit if initialize is true.
if (initialize)
{
_bitmapInit.BeginInit();
_bitmapInit.EndInit();
}
}
///
/// Critical - calls critical code method BitmapSource.UpdateCachedSettings
/// TreatAsSafe - all inputs are checked
///
[SecurityCritical, SecurityTreatAsSafe]
internal void UpdateBitmapSource(BitmapSource bitmapSource, DUCE.Channel channel)
{
WicSourceHandle = bitmapSource.WicSourceHandle;
UpdateCachedSettings();
_needsUpdate = true;
UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ );
}
///
/// Implementation of Freezable.CreateInstanceCore .
///
protected override Freezable CreateInstanceCore()
{
return new UnmanagedBitmapWrapper(false);
}
private void CopyCommon(UnmanagedBitmapWrapper sourceBitmap)
{
_bitmapInit.BeginInit();
_bitmapInit.EndInit();
}
///
/// Implementation of Freezable.CloneCore .
///
protected override void CloneCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.CloneCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
///
/// Implementation of Freezable.CloneCurrentValueCore .
///
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.CloneCurrentValueCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
///
/// Implementation of Freezable.GetAsFrozenCore .
///
protected override void GetAsFrozenCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.GetAsFrozenCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
///
/// Implementation of Freezable.GetCurrentValueAsFrozenCore .
///
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable;
base.GetCurrentValueAsFrozenCore(sourceFreezable);
CopyCommon(sourceBitmap);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InputLanguageProfileNotifySink.cs
- Vars.cs
- ImageCodecInfo.cs
- ComplexTypeEmitter.cs
- TextBoxAutomationPeer.cs
- Form.cs
- ColorBlend.cs
- XmlnsDictionary.cs
- UDPClient.cs
- WebPartConnectionsEventArgs.cs
- TypePropertyEditor.cs
- XamlRtfConverter.cs
- WebPartZoneCollection.cs
- KeyedCollection.cs
- OleStrCAMarshaler.cs
- SmiEventSink_DeferedProcessing.cs
- ExponentialEase.cs
- WorkflowMessageEventHandler.cs
- HashCodeCombiner.cs
- SchemaConstraints.cs
- SimpleExpression.cs
- EventSinkHelperWriter.cs
- RelationshipDetailsRow.cs
- XmlWriterSettings.cs
- Native.cs
- FigureParaClient.cs
- SystemBrushes.cs
- RenderData.cs
- MappingException.cs
- XmlIgnoreAttribute.cs
- HierarchicalDataBoundControl.cs
- BinaryReader.cs
- CardSpaceException.cs
- ErrorView.xaml.cs
- InkCanvasSelection.cs
- WindowPatternIdentifiers.cs
- TextServicesContext.cs
- _CommandStream.cs
- ElementNotAvailableException.cs
- TemplateBindingExpression.cs
- TableLayoutStyle.cs
- RemoteEndpointMessageProperty.cs
- ClientFormsAuthenticationMembershipProvider.cs
- ChangeProcessor.cs
- WebPartConnection.cs
- TextBoxBase.cs
- MergeFilterQuery.cs
- FunctionMappingTranslator.cs
- CodeGen.cs
- MailWebEventProvider.cs
- PKCS1MaskGenerationMethod.cs
- ThaiBuddhistCalendar.cs
- ClientScriptManagerWrapper.cs
- EventLogPermissionAttribute.cs
- CfgParser.cs
- AlignmentYValidation.cs
- Cloud.cs
- CompiledRegexRunnerFactory.cs
- TextBoxBase.cs
- base64Transforms.cs
- BitmapVisualManager.cs
- IOThreadScheduler.cs
- ImpersonateTokenRef.cs
- Membership.cs
- WorkflowRuntimeServiceElement.cs
- PropertyChangeTracker.cs
- SoundPlayerAction.cs
- DesignConnectionCollection.cs
- NumericPagerField.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- BamlRecordHelper.cs
- StreamInfo.cs
- DocumentViewerAutomationPeer.cs
- NavigatingCancelEventArgs.cs
- DrawingVisual.cs
- SapiInterop.cs
- dbenumerator.cs
- SubMenuStyleCollection.cs
- XmlSchemaInclude.cs
- LogArchiveSnapshot.cs
- EventRoute.cs
- SoapExtension.cs
- EnumerableWrapperWeakToStrong.cs
- Queue.cs
- ResourceReferenceKeyNotFoundException.cs
- WebUtil.cs
- SymbolMethod.cs
- SmiEventSink_Default.cs
- TextTreeNode.cs
- WorkflowEventArgs.cs
- HtmlControlPersistable.cs
- RequiredAttributeAttribute.cs
- FormsAuthenticationEventArgs.cs
- XpsColorContext.cs
- PathStreamGeometryContext.cs
- Connector.xaml.cs
- ButtonColumn.cs
- MembershipPasswordException.cs
- HttpListenerResponse.cs
- TranslateTransform.cs