Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CommonUI / System / Drawing / ImageInfo.cs / 1 / ImageInfo.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing { using System.Threading; using System; using System.Diagnostics; using System.Drawing.Imaging; ////// Animates one or more images that have time-based frames. /// This file contains the nested ImageInfo class - See ImageAnimator.cs for the definition of the outer class. /// public sealed partial class ImageAnimator { ////// ImageAnimator nested helper class used to store extra image state info. /// private class ImageInfo { const int PropertyTagFrameDelay = 0x5100; Image image; int frame; int frameCount; bool frameDirty; bool animated; EventHandler onFrameChangedHandler; int[] frameDelay; int frameTimer; ////// public ImageInfo(Image image) { this.image = image; animated = ImageAnimator.CanAnimate(image); if (animated) { frameCount = image.GetFrameCount(FrameDimension.Time); PropertyItem frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay); // If the image does not have a frame delay, we just return 0. // if (frameDelayItem != null) { // Convert the frame delay from byte[] to int // byte[] values = frameDelayItem.Value; Debug.Assert(values.Length == 4 * FrameCount, "PropertyItem has invalid value byte array"); frameDelay = new int[FrameCount]; for (int i=0; i < FrameCount; ++i) { frameDelay[i] = values[i * 4] + 256 * values[i * 4 + 1] + 256 * 256 * values[i * 4 + 2] + 256 * 256 * 256 * values[i * 4 + 3]; } } } else { frameCount = 1; } if (frameDelay == null) { frameDelay = new int[FrameCount]; } } ////// Whether the image supports animation. /// public bool Animated { get { return animated; } } ////// The current frame. /// public int Frame { get { return frame; } set { if (frame != value) { if (value < 0 || value >= FrameCount) { throw new ArgumentException(SR.GetString(SR.InvalidFrame), "value"); } if (Animated) { frame = value; frameDirty = true; OnFrameChanged(EventArgs.Empty); } } } } ////// The current frame has not been updated. /// public bool FrameDirty { get { return frameDirty; } } ////// public EventHandler FrameChangedHandler { get { return onFrameChangedHandler; } set { onFrameChangedHandler = value; } } ////// The number of frames in the image. /// public int FrameCount { get { return frameCount; } } ////// The delay associated with the frame at the specified index. /// public int FrameDelay(int frame) { return frameDelay[frame]; } ////// internal int FrameTimer { get { return frameTimer; } set { frameTimer = value; } } ////// The image this object wraps. /// internal Image Image { get { return image; } } ////// Selects the current frame as the active frame in the image. /// internal void UpdateFrame() { if (frameDirty) { image.SelectActiveFrame(FrameDimension.Time, Frame); frameDirty = false; } } ////// Raises the FrameChanged event. /// protected void OnFrameChanged(EventArgs e) { if( this.onFrameChangedHandler != null ){ this.onFrameChangedHandler(image, e); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing { using System.Threading; using System; using System.Diagnostics; using System.Drawing.Imaging; ////// Animates one or more images that have time-based frames. /// This file contains the nested ImageInfo class - See ImageAnimator.cs for the definition of the outer class. /// public sealed partial class ImageAnimator { ////// ImageAnimator nested helper class used to store extra image state info. /// private class ImageInfo { const int PropertyTagFrameDelay = 0x5100; Image image; int frame; int frameCount; bool frameDirty; bool animated; EventHandler onFrameChangedHandler; int[] frameDelay; int frameTimer; ////// public ImageInfo(Image image) { this.image = image; animated = ImageAnimator.CanAnimate(image); if (animated) { frameCount = image.GetFrameCount(FrameDimension.Time); PropertyItem frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay); // If the image does not have a frame delay, we just return 0. // if (frameDelayItem != null) { // Convert the frame delay from byte[] to int // byte[] values = frameDelayItem.Value; Debug.Assert(values.Length == 4 * FrameCount, "PropertyItem has invalid value byte array"); frameDelay = new int[FrameCount]; for (int i=0; i < FrameCount; ++i) { frameDelay[i] = values[i * 4] + 256 * values[i * 4 + 1] + 256 * 256 * values[i * 4 + 2] + 256 * 256 * 256 * values[i * 4 + 3]; } } } else { frameCount = 1; } if (frameDelay == null) { frameDelay = new int[FrameCount]; } } ////// Whether the image supports animation. /// public bool Animated { get { return animated; } } ////// The current frame. /// public int Frame { get { return frame; } set { if (frame != value) { if (value < 0 || value >= FrameCount) { throw new ArgumentException(SR.GetString(SR.InvalidFrame), "value"); } if (Animated) { frame = value; frameDirty = true; OnFrameChanged(EventArgs.Empty); } } } } ////// The current frame has not been updated. /// public bool FrameDirty { get { return frameDirty; } } ////// public EventHandler FrameChangedHandler { get { return onFrameChangedHandler; } set { onFrameChangedHandler = value; } } ////// The number of frames in the image. /// public int FrameCount { get { return frameCount; } } ////// The delay associated with the frame at the specified index. /// public int FrameDelay(int frame) { return frameDelay[frame]; } ////// internal int FrameTimer { get { return frameTimer; } set { frameTimer = value; } } ////// The image this object wraps. /// internal Image Image { get { return image; } } ////// Selects the current frame as the active frame in the image. /// internal void UpdateFrame() { if (frameDirty) { image.SelectActiveFrame(FrameDimension.Time, Frame); frameDirty = false; } } ////// Raises the FrameChanged event. /// protected void OnFrameChanged(EventArgs e) { if( this.onFrameChangedHandler != null ){ this.onFrameChangedHandler(image, e); } } } } } // 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
- DelayedRegex.cs
- WebUtil.cs
- EntitySetRetriever.cs
- StaticFileHandler.cs
- AppSettingsReader.cs
- PlatformCulture.cs
- DataGridViewLinkColumn.cs
- XmlSecureResolver.cs
- Brushes.cs
- NavigationEventArgs.cs
- PartitionedStream.cs
- TextTreeNode.cs
- BrushConverter.cs
- MarkupCompilePass1.cs
- TextBlockAutomationPeer.cs
- StringFormat.cs
- StateRuntime.cs
- PeerResolverMode.cs
- RMPermissions.cs
- EncryptedPackage.cs
- SortKey.cs
- ContractHandle.cs
- TextEffectResolver.cs
- ProfilePropertySettingsCollection.cs
- PageThemeBuildProvider.cs
- MemberMaps.cs
- RuleSettings.cs
- DebugHandleTracker.cs
- ParameterToken.cs
- TableLayoutSettingsTypeConverter.cs
- ItemCollectionEditor.cs
- WebBrowserNavigatingEventHandler.cs
- FaultDescriptionCollection.cs
- AutoGeneratedFieldProperties.cs
- ValidationRule.cs
- EventLogPermissionEntry.cs
- XLinq.cs
- UpDownEvent.cs
- MemoryStream.cs
- CodeNamespaceImportCollection.cs
- RemotingConfiguration.cs
- IntegrationExceptionEventArgs.cs
- LayoutEditorPart.cs
- Missing.cs
- Propagator.JoinPropagator.cs
- QuaternionIndependentAnimationStorage.cs
- Baml2006SchemaContext.cs
- BitmapCodecInfo.cs
- XmlRawWriterWrapper.cs
- XmlUrlResolver.cs
- ControlCachePolicy.cs
- BaseTemplateCodeDomTreeGenerator.cs
- GridItemPattern.cs
- GraphicsContext.cs
- XPathConvert.cs
- SeparatorAutomationPeer.cs
- OutputCacheProfileCollection.cs
- XmlSchemaAttributeGroup.cs
- ExceptionList.cs
- XslCompiledTransform.cs
- FileDataSourceCache.cs
- HybridObjectCache.cs
- PtsPage.cs
- httpstaticobjectscollection.cs
- TypedTableBaseExtensions.cs
- UInt16Converter.cs
- Int32AnimationBase.cs
- HelpProvider.cs
- SessionStateUtil.cs
- TriState.cs
- XPathChildIterator.cs
- DependencyProperty.cs
- TextDecoration.cs
- GradientSpreadMethodValidation.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- WebPartEditVerb.cs
- HttpCapabilitiesBase.cs
- compensatingcollection.cs
- DelegateSerializationHolder.cs
- SelectionWordBreaker.cs
- ByteRangeDownloader.cs
- DataTransferEventArgs.cs
- SqlRewriteScalarSubqueries.cs
- OleDbErrorCollection.cs
- PropertyTab.cs
- Typeface.cs
- PcmConverter.cs
- ConfigurationFileMap.cs
- XmlAtomicValue.cs
- Solver.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- XsdSchemaFileEditor.cs
- DataGridViewDataErrorEventArgs.cs
- EventlogProvider.cs
- TrackingServices.cs
- ExtendedPropertyInfo.cs
- TransactionFlowProperty.cs
- BitmapSource.cs
- QueueException.cs
- ApplicationServiceManager.cs