mirror of https://github.com/SixLabors/ImageSharp
11 changed files with 229 additions and 24 deletions
@ -0,0 +1,18 @@ |
|||||
|
// <copyright file="IImageFrame.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Encapsulates the basic properties and methods required to manipulate images.
|
||||
|
/// </summary>
|
||||
|
internal interface IImageFrame : IImageBase |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the meta data of the image.
|
||||
|
/// </summary>
|
||||
|
ImageFrameMetaData MetaData { get; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
// <copyright file="IMetaData.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Encapsulates the metadata of an image frame.
|
||||
|
/// </summary>
|
||||
|
internal interface IMetaData |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets or sets the frame delay for animated images.
|
||||
|
/// If not 0, this field specifies the number of hundredths (1/100) of a second to
|
||||
|
/// wait before continuing with the processing of the Data Stream.
|
||||
|
/// The clock starts ticking immediately after the graphic is rendered.
|
||||
|
/// </summary>
|
||||
|
int FrameDelay { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
// <copyright file="ImageFrameMetaData.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp |
||||
|
{ |
||||
|
using System.Diagnostics; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Encapsulates the metadata of an image frame.
|
||||
|
/// </summary>
|
||||
|
public sealed class ImageFrameMetaData : IMetaData |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="ImageFrameMetaData"/> class.
|
||||
|
/// </summary>
|
||||
|
internal ImageFrameMetaData() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="ImageFrameMetaData"/> class
|
||||
|
/// by making a copy from other metadata.
|
||||
|
/// </summary>
|
||||
|
/// <param name="other">
|
||||
|
/// The other <see cref="ImageFrameMetaData"/> to create this instance from.
|
||||
|
/// </param>
|
||||
|
internal ImageFrameMetaData(ImageFrameMetaData other) |
||||
|
{ |
||||
|
Debug.Assert(other != null); |
||||
|
|
||||
|
this.FrameDelay = other.FrameDelay; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the frame delay for animated images.
|
||||
|
/// If not 0, this field specifies the number of hundredths (1/100) of a second to
|
||||
|
/// wait before continuing with the processing of the Data Stream.
|
||||
|
/// The clock starts ticking immediately after the graphic is rendered.
|
||||
|
/// </summary>
|
||||
|
public int FrameDelay { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
// <copyright file="ImageFrameMetaDataTests.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Tests |
||||
|
{ |
||||
|
using Xunit; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Tests the <see cref="ImageFrameMetaDataTests"/> class.
|
||||
|
/// </summary>
|
||||
|
public class ImageFrameMetaDataTests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void ConstructorImageFrameMetaData() |
||||
|
{ |
||||
|
ImageFrameMetaData metaData = new ImageFrameMetaData(); |
||||
|
metaData.FrameDelay = 42; |
||||
|
|
||||
|
ImageFrameMetaData clone = new ImageFrameMetaData(metaData); |
||||
|
|
||||
|
Assert.Equal(42, clone.FrameDelay); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
// <copyright file="ImageMetaDataTests.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Tests |
||||
|
{ |
||||
|
using Xunit; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Tests the <see cref="ImageMetaData"/> class.
|
||||
|
/// </summary>
|
||||
|
public class ImageMetaDataTests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void ConstructorImageMetaData() |
||||
|
{ |
||||
|
ImageMetaData metaData = new ImageMetaData(); |
||||
|
|
||||
|
ExifProfile exifProfile = new ExifProfile(); |
||||
|
ImageProperty imageProperty = new ImageProperty("name", "value"); |
||||
|
|
||||
|
metaData.ExifProfile = exifProfile; |
||||
|
metaData.FrameDelay = 42; |
||||
|
metaData.HorizontalResolution = 4; |
||||
|
metaData.VerticalResolution = 2; |
||||
|
metaData.Properties.Add(imageProperty); |
||||
|
metaData.Quality = 24; |
||||
|
metaData.RepeatCount = 1; |
||||
|
|
||||
|
ImageMetaData clone = new ImageMetaData(metaData); |
||||
|
|
||||
|
Assert.Equal(exifProfile.ToByteArray(), clone.ExifProfile.ToByteArray()); |
||||
|
Assert.Equal(42, clone.FrameDelay); |
||||
|
Assert.Equal(4, clone.HorizontalResolution); |
||||
|
Assert.Equal(2, clone.VerticalResolution); |
||||
|
Assert.Equal(imageProperty, clone.Properties[0]); |
||||
|
Assert.Equal(24, clone.Quality); |
||||
|
Assert.Equal(1, clone.RepeatCount); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue