mirror of https://github.com/SixLabors/ImageSharp
committed by
GitHub
10 changed files with 113 additions and 31 deletions
@ -0,0 +1,20 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Processing.Processors |
|||
{ |
|||
/// <summary>
|
|||
/// The base class for all transform processors. Any processor that changes the dimensions of the image should inherit from this.
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
|||
internal abstract class TransformProcessorBase<TPixel> : CloningImageProcessor<TPixel> |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
/// <inheritdoc/>
|
|||
protected override void AfterImageApply(Image<TPixel> source, Image<TPixel> destination, Rectangle sourceRectangle) |
|||
=> TransformHelpers.UpdateDimensionalMetData(destination); |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData.Profiles.Exif; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
|||
{ |
|||
public class TransformsHelpersTest |
|||
{ |
|||
[Fact] |
|||
public void HelperCanChangeExifDataType() |
|||
{ |
|||
int xy = 1; |
|||
|
|||
using (var img = new Image<Alpha8>(xy, xy)) |
|||
{ |
|||
var profile = new ExifProfile(); |
|||
img.MetaData.ExifProfile = profile; |
|||
profile.SetValue(ExifTag.PixelXDimension, (uint)xy); |
|||
profile.SetValue(ExifTag.PixelYDimension, (uint)xy); |
|||
|
|||
Assert.Equal(ExifDataType.Long, profile.GetValue(ExifTag.PixelXDimension).DataType); |
|||
Assert.Equal(ExifDataType.Long, profile.GetValue(ExifTag.PixelYDimension).DataType); |
|||
|
|||
TransformHelpers.UpdateDimensionalMetData(img); |
|||
|
|||
Assert.Equal(ExifDataType.Short, profile.GetValue(ExifTag.PixelXDimension).DataType); |
|||
Assert.Equal(ExifDataType.Short, profile.GetValue(ExifTag.PixelYDimension).DataType); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue