Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / Imaging / InplaceBitmapMetadataWriter.cs / 1305600 / InplaceBitmapMetadataWriter.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All Rights Reserved // // File: InPlaceBitmapMetadataWriter.cs // //----------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; using MS.Internal; using MS.Win32.PresentationCore; using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; using System.Xml; using System.IO; using System.Security; using System.Security.Permissions; using System.Windows.Media.Imaging; using System.Windows.Threading; using System.Text; using MS.Internal.PresentationCore; // SecurityHelper namespace System.Windows.Media.Imaging { #region InPlaceBitmapMetadataWriter ////// Metadata Class for BitmapImage. /// sealed public partial class InPlaceBitmapMetadataWriter : BitmapMetadata { #region Constructors ////// /// private InPlaceBitmapMetadataWriter() { } ////// /// ////// Critical - Accesses critical resources /// [SecurityCritical] internal InPlaceBitmapMetadataWriter( SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle, SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle, object syncObject ) : base(metadataHandle, false, false, syncObject) { _fmeHandle = fmeHandle; } ////// /// ////// Critical - Accesses unmanaged code /// TreatAsSafe - inputs are verified or safe /// [SecurityCritical, SecurityTreatAsSafe] static internal InPlaceBitmapMetadataWriter CreateFromFrameDecode(BitmapSourceSafeMILHandle frameHandle, object syncObject) { Invariant.Assert(frameHandle != null); SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle = null; SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = null; using (FactoryMaker factoryMaker = new FactoryMaker()) { lock (syncObject) { HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromFrameDecode( factoryMaker.ImagingFactoryPtr, frameHandle, out fmeHandle)); } } HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter( fmeHandle, out metadataHandle)); return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject); } ////// /// ////// Critical - Accesses unmanaged code /// TreatAsSafe - inputs are verified or safe /// [SecurityCritical, SecurityTreatAsSafe] static internal InPlaceBitmapMetadataWriter CreateFromDecoder(SafeMILHandle decoderHandle, object syncObject) { Invariant.Assert(decoderHandle != null); SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle = null; SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = null; using (FactoryMaker factoryMaker = new FactoryMaker()) { lock (syncObject) { HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromDecoder( factoryMaker.ImagingFactoryPtr, decoderHandle, out fmeHandle)); } } HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter( fmeHandle, out metadataHandle)); return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject); } ////// /// ////// Critical - Accesses unmanaged code /// PublicOK - inputs are verified or safe /// [SecurityCritical ] public bool TrySave() { int hr; Invariant.Assert(_fmeHandle != null); lock (SyncObject) { hr = UnsafeNativeMethods.WICFastMetadataEncoder.Commit(_fmeHandle); } return HRESULT.Succeeded(hr); } #endregion #region Freezable ////// Shadows inherited Copy() with a strongly typed /// version for convenience. /// public new InPlaceBitmapMetadataWriter Clone() { return (InPlaceBitmapMetadataWriter)base.Clone(); } ////// Implementation of ///Freezable.CreateInstanceCore . ///The new Freezable. protected override Freezable CreateInstanceCore() { throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy)); } ////// Implementation of protected override void CloneCore(Freezable sourceFreezable) { throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy)); } ///Freezable.CloneCore . ////// Implementation of protected override void CloneCurrentValueCore(Freezable sourceFreezable) { throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy)); } ///Freezable.CloneCurrentValueCore . ////// Implementation of protected override void GetAsFrozenCore(Freezable sourceFreezable) { throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy)); } ///Freezable.GetAsFrozenCore . ////// Implementation of protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy)); } #endregion ///Freezable.GetCurrentValueAsFrozenCore . ////// Critical - pointer to an unmanaged object that methods are called on. /// [SecurityCritical] private SafeMILHandle _fmeHandle; } #endregion } // 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
- Vector3DCollectionValueSerializer.cs
- ResXBuildProvider.cs
- ClientTarget.cs
- MulticastDelegate.cs
- LockedActivityGlyph.cs
- DataIdProcessor.cs
- ClientSideQueueItem.cs
- DetailsViewRowCollection.cs
- ContentDesigner.cs
- XmlQualifiedNameTest.cs
- CommandConverter.cs
- MimeMultiPart.cs
- TextRange.cs
- Verify.cs
- RuntimeConfigLKG.cs
- Rule.cs
- FixedSOMPageElement.cs
- DataGridColumnHeadersPresenter.cs
- CacheRequest.cs
- AsyncPostBackTrigger.cs
- HighlightComponent.cs
- Token.cs
- WindowHideOrCloseTracker.cs
- ScriptingJsonSerializationSection.cs
- SqlCaseSimplifier.cs
- ColorTranslator.cs
- DesignerActionUI.cs
- XPathMultyIterator.cs
- VarRemapper.cs
- SortQuery.cs
- X509IssuerSerialKeyIdentifierClause.cs
- GridViewColumn.cs
- IgnoreSection.cs
- LicenseProviderAttribute.cs
- DataSourceViewSchemaConverter.cs
- Operand.cs
- ForEachAction.cs
- _SslState.cs
- DecoderBestFitFallback.cs
- HttpCapabilitiesSectionHandler.cs
- UriSectionData.cs
- OleDbRowUpdatedEvent.cs
- JavaScriptString.cs
- ColumnCollection.cs
- EdmRelationshipRoleAttribute.cs
- WebRequestModulesSection.cs
- ListItemConverter.cs
- _NegoState.cs
- VisualTreeHelper.cs
- DragDropManager.cs
- RuleSettings.cs
- BeginStoryboard.cs
- CngKeyCreationParameters.cs
- TableLayoutCellPaintEventArgs.cs
- ThemeDirectoryCompiler.cs
- WpfKnownMemberInvoker.cs
- StdValidatorsAndConverters.cs
- Int32CAMarshaler.cs
- WebCategoryAttribute.cs
- ElementProxy.cs
- Tile.cs
- OperationCanceledException.cs
- InkCollectionBehavior.cs
- WinInet.cs
- Compilation.cs
- GetPolicyDetailsRequest.cs
- StructuredTypeEmitter.cs
- DeferredSelectedIndexReference.cs
- ExecutionEngineException.cs
- RTLAwareMessageBox.cs
- ManagedIStream.cs
- SmiRequestExecutor.cs
- TypeContext.cs
- HScrollBar.cs
- MD5.cs
- ModelFunctionTypeElement.cs
- URI.cs
- StateDesignerConnector.cs
- XmlAttributeOverrides.cs
- LayoutEngine.cs
- FocusWithinProperty.cs
- StyleBamlRecordReader.cs
- TdsValueSetter.cs
- CaseInsensitiveOrdinalStringComparer.cs
- CompleteWizardStep.cs
- ExpressionConverter.cs
- PingOptions.cs
- CommandBindingCollection.cs
- URIFormatException.cs
- dbenumerator.cs
- RegularExpressionValidator.cs
- Point.cs
- ToolTipAutomationPeer.cs
- Validator.cs
- XmlQueryTypeFactory.cs
- ShaderEffect.cs
- FormViewDesigner.cs
- DesignerTransaction.cs
- X509InitiatorCertificateServiceElement.cs
- CreateRefExpr.cs