mirror of https://github.com/SixLabors/ImageSharp
46 changed files with 598 additions and 381 deletions
@ -1,32 +0,0 @@ |
|||||
// Copyright (c) Six Labors.
|
|
||||
// Licensed under the Six Labors Split License.
|
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats; |
|
||||
|
|
||||
internal class AnimatedImageFrameMetadata |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Gets or sets the frame color table.
|
|
||||
/// </summary>
|
|
||||
public ReadOnlyMemory<Color>? ColorTable { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the frame color table mode.
|
|
||||
/// </summary>
|
|
||||
public FrameColorTableMode ColorTableMode { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the duration of the frame.
|
|
||||
/// </summary>
|
|
||||
public TimeSpan Duration { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the frame alpha blending mode.
|
|
||||
/// </summary>
|
|
||||
public FrameBlendMode BlendMode { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the frame disposal mode.
|
|
||||
/// </summary>
|
|
||||
public FrameDisposalMode DisposalMode { get; set; } |
|
||||
} |
|
||||
@ -1,33 +0,0 @@ |
|||||
// Copyright (c) Six Labors.
|
|
||||
// Licensed under the Six Labors Split License.
|
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats; |
|
||||
|
|
||||
internal class AnimatedImageMetadata |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Gets or sets the shared color table.
|
|
||||
/// </summary>
|
|
||||
public ReadOnlyMemory<Color>? ColorTable { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the shared color table mode.
|
|
||||
/// </summary>
|
|
||||
public FrameColorTableMode ColorTableMode { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the default background color of the canvas when animating.
|
|
||||
/// This color may be used to fill the unused space on the canvas around the frames,
|
|
||||
/// as well as the transparent pixels of the first frame.
|
|
||||
/// The background color is also used when the disposal mode is <see cref="FrameDisposalMode.RestoreToBackground"/>.
|
|
||||
/// </summary>
|
|
||||
public Color BackgroundColor { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the number of times any animation is repeated.
|
|
||||
/// <remarks>
|
|
||||
/// 0 means to repeat indefinitely, count is set as repeat n-1 times. Defaults to 1.
|
|
||||
/// </remarks>
|
|
||||
/// </summary>
|
|
||||
public ushort RepeatCount { get; set; } |
|
||||
} |
|
||||
@ -1,39 +0,0 @@ |
|||||
// Copyright (c) Six Labors.
|
|
||||
// Licensed under the Six Labors Split License.
|
|
||||
|
|
||||
using SixLabors.ImageSharp.Metadata.Profiles.Exif; |
|
||||
using SixLabors.ImageSharp.PixelFormats; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing.Processors.Transforms; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Contains helper methods for working with transforms.
|
|
||||
/// </summary>
|
|
||||
internal static class TransformProcessorHelpers |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Updates the dimensional metadata of a transformed image
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
|
||||
/// <param name="image">The image to update</param>
|
|
||||
public static void UpdateDimensionalMetadata<TPixel>(Image<TPixel> image) |
|
||||
where TPixel : unmanaged, IPixel<TPixel> |
|
||||
{ |
|
||||
ExifProfile? profile = image.Metadata.ExifProfile; |
|
||||
if (profile is null) |
|
||||
{ |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
// Only set the value if it already exists.
|
|
||||
if (profile.TryGetValue(ExifTag.PixelXDimension, out _)) |
|
||||
{ |
|
||||
profile.SetValue(ExifTag.PixelXDimension, image.Width); |
|
||||
} |
|
||||
|
|
||||
if (profile.TryGetValue(ExifTag.PixelYDimension, out _)) |
|
||||
{ |
|
||||
profile.SetValue(ExifTag.PixelYDimension, image.Height); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,35 +0,0 @@ |
|||||
// Copyright (c) Six Labors.
|
|
||||
// Licensed under the Six Labors Split License.
|
|
||||
|
|
||||
using SixLabors.ImageSharp.Metadata.Profiles.Exif; |
|
||||
using SixLabors.ImageSharp.PixelFormats; |
|
||||
using SixLabors.ImageSharp.Processing.Processors.Transforms; |
|
||||
using SixLabors.ImageSharp.Tests.TestUtilities; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Tests.Processing.Transforms; |
|
||||
|
|
||||
[Trait("Category", "Processors")] |
|
||||
public class TransformsHelpersTest |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void HelperCanChangeExifDataType() |
|
||||
{ |
|
||||
int xy = 1; |
|
||||
|
|
||||
using (var img = new Image<A8>(xy, xy)) |
|
||||
{ |
|
||||
var profile = new ExifProfile(); |
|
||||
img.Metadata.ExifProfile = profile; |
|
||||
profile.SetValue(ExifTag.PixelXDimension, xy + ushort.MaxValue); |
|
||||
profile.SetValue(ExifTag.PixelYDimension, xy + ushort.MaxValue); |
|
||||
|
|
||||
Assert.Equal(ExifDataType.Long, profile.GetValue(ExifTag.PixelXDimension).DataType); |
|
||||
Assert.Equal(ExifDataType.Long, profile.GetValue(ExifTag.PixelYDimension).DataType); |
|
||||
|
|
||||
TransformProcessorHelpers.UpdateDimensionalMetadata(img); |
|
||||
|
|
||||
Assert.Equal(ExifDataType.Short, profile.GetValue(ExifTag.PixelXDimension).DataType); |
|
||||
Assert.Equal(ExifDataType.Short, profile.GetValue(ExifTag.PixelYDimension).DataType); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue