Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / Imaging / UnmanagedBitmapWrapper.cs / 1305600 / 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 : BitmapSource
{
///
/// Critical - calls critical code method BitmapSource.UpdateCachedSettings
/// TreatAsSafe - all inputs are checked
///
[SecurityCritical, SecurityTreatAsSafe]
public UnmanagedBitmapWrapper(BitmapSourceSafeMILHandle bitmapSource) :
base(true)
{
_bitmapInit.BeginInit();
//
// This constructor is used by BitmapDecoder and BitmapFrameDecode for thumbnails and
// previews. The bitmapSource parameter comes from BitmapSource.CreateCachedBitmap
// which already calculated memory pressure, so there's no need to do it here.
//
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();
}
}
///
/// 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
- WebResourceUtil.cs
- Main.cs
- IntellisenseTextBox.cs
- ListenerServiceInstallComponent.cs
- FileIOPermission.cs
- HealthMonitoringSectionHelper.cs
- InfoCardTrace.cs
- glyphs.cs
- TextCompositionManager.cs
- RowsCopiedEventArgs.cs
- FormatConvertedBitmap.cs
- RawContentTypeMapper.cs
- Validator.cs
- DispatcherOperation.cs
- HttpApplicationFactory.cs
- DecimalKeyFrameCollection.cs
- PenCursorManager.cs
- TagMapInfo.cs
- AppLevelCompilationSectionCache.cs
- ExpressionBindings.cs
- _UncName.cs
- BigInt.cs
- CheckPair.cs
- SoapIncludeAttribute.cs
- DetailsViewRowCollection.cs
- Site.cs
- EditorAttribute.cs
- TransformerInfoCollection.cs
- MiniAssembly.cs
- DashStyle.cs
- Transaction.cs
- DictionaryBase.cs
- CryptoProvider.cs
- UpdatePanelControlTrigger.cs
- ValueProviderWrapper.cs
- SiteMapProvider.cs
- DeclarationUpdate.cs
- ReaderOutput.cs
- MouseCaptureWithinProperty.cs
- Graph.cs
- DataObjectPastingEventArgs.cs
- AnimatedTypeHelpers.cs
- UIElementHelper.cs
- AnimationLayer.cs
- DesignerCommandSet.cs
- UserControlFileEditor.cs
- HotSpotCollection.cs
- DbProviderFactories.cs
- SecurityVersion.cs
- DateTimeFormatInfoScanner.cs
- MembershipValidatePasswordEventArgs.cs
- ObjectStateEntry.cs
- ImageBrush.cs
- WebHttpBindingCollectionElement.cs
- RepeaterItem.cs
- HttpContext.cs
- FixedSOMPageConstructor.cs
- InnerItemCollectionView.cs
- LocalizationCodeDomSerializer.cs
- WebPartZone.cs
- IPipelineRuntime.cs
- WsdlServiceChannelBuilder.cs
- QilValidationVisitor.cs
- LoginView.cs
- DoubleKeyFrameCollection.cs
- ProcessProtocolHandler.cs
- HtmlLiteralTextAdapter.cs
- ContractMapping.cs
- FormViewUpdatedEventArgs.cs
- DecimalStorage.cs
- X509ChainElement.cs
- UInt32Converter.cs
- TableCellsCollectionEditor.cs
- EntityDataSourceState.cs
- ConstraintConverter.cs
- ProfilePropertyNameValidator.cs
- PenThreadPool.cs
- EventLogInternal.cs
- DataGridViewComboBoxEditingControl.cs
- LabelLiteral.cs
- DescendantOverDescendantQuery.cs
- SelectorItemAutomationPeer.cs
- System.Data.OracleClient_BID.cs
- XsdDateTime.cs
- ToolStripGrip.cs
- SingletonInstanceContextProvider.cs
- QuaternionConverter.cs
- TrackingServices.cs
- IsolatedStorage.cs
- IndexExpression.cs
- CleanUpVirtualizedItemEventArgs.cs
- ReverseInheritProperty.cs
- SelectedGridItemChangedEvent.cs
- Slider.cs
- CodeCastExpression.cs
- AuthenticateEventArgs.cs
- SystemBrushes.cs
- Rotation3DAnimationBase.cs
- Misc.cs
- SelectQueryOperator.cs