Browse Source

Added method to copy the properties of an image.

Former-commit-id: 126b2f90afc19b367669116a5610fcbd3c252726
Former-commit-id: f2820929b2c9f92b7cb2ced52b674367f70eeba9
Former-commit-id: 988552a23146160a96a521b56b0016fb32dbc0e1
pull/1/head
dirk 10 years ago
parent
commit
2e330649fa
  1. 31
      src/ImageProcessorCore/Image/Image.cs
  2. 15
      src/ImageProcessorCore/Image/ImageBase.cs
  3. 15
      src/ImageProcessorCore/Image/ImageExtensions.cs

31
src/ImageProcessorCore/Image/Image.cs

@ -87,15 +87,7 @@ namespace ImageProcessorCore
} }
} }
this.RepeatCount = other.RepeatCount; this.CopyProperties(other);
this.HorizontalResolution = other.HorizontalResolution;
this.VerticalResolution = other.VerticalResolution;
this.CurrentImageFormat = other.CurrentImageFormat;
if (other.ExifProfile != null)
{
this.ExifProfile = new ExifProfile(other.ExifProfile);
}
} }
/// <summary> /// <summary>
@ -251,6 +243,27 @@ namespace ImageProcessorCore
} }
} }
/// <summary>
/// Copies the properties from the other <see cref="Image{T,TP}"/>.
/// </summary>
/// <param name="other">
/// The other <see cref="Image{T,TP}"/> to copy the properties from.
/// </param>
internal void CopyProperties(Image<T, TP> other)
{
base.CopyProperties(other);
this.HorizontalResolution = other.HorizontalResolution;
this.VerticalResolution = other.VerticalResolution;
this.CurrentImageFormat = other.CurrentImageFormat;
this.RepeatCount = other.RepeatCount;
if (other.ExifProfile != null)
{
this.ExifProfile = new ExifProfile(other.ExifProfile);
}
}
/// <summary> /// <summary>
/// Loads the image from the given stream. /// Loads the image from the given stream.
/// </summary> /// </summary>

15
src/ImageProcessorCore/Image/ImageBase.cs

@ -59,8 +59,7 @@ namespace ImageProcessorCore
this.Width = other.Width; this.Width = other.Width;
this.Height = other.Height; this.Height = other.Height;
this.Quality = other.Quality; this.CopyProperties(other);
this.FrameDelay = other.FrameDelay;
// Copy the pixels. // Copy the pixels.
this.Pixels = new T[this.Width * this.Height]; this.Pixels = new T[this.Width * this.Height];
@ -145,5 +144,17 @@ namespace ImageProcessorCore
/// <inheritdoc/> /// <inheritdoc/>
public abstract IPixelAccessor<T, TP> Lock(); public abstract IPixelAccessor<T, TP> Lock();
/// <summary>
/// Copies the properties from the other <see cref="ImageBase{T,TP}"/>.
/// </summary>
/// <param name="other">
/// The other <see cref="ImageBase{T,TP}"/> to copy the properties from.
/// </param>
protected void CopyProperties(ImageBase<T, TP> other)
{
this.Quality = other.Quality;
this.FrameDelay = other.FrameDelay;
}
} }
} }

15
src/ImageProcessorCore/Image/ImageExtensions.cs

@ -171,16 +171,11 @@ namespace ImageProcessorCore
{ {
Image<T, TP> transformedImage = clone Image<T, TP> transformedImage = clone
? new Image<T, TP>(source) ? new Image<T, TP>(source)
: new Image<T, TP> : new Image<T, TP>();
{
// Several properties require copying // Several properties still require copying
FrameDelay = source.FrameDelay, if (!clone)
Quality = source.Quality, transformedImage.CopyProperties(source);
HorizontalResolution = source.HorizontalResolution,
VerticalResolution = source.VerticalResolution,
CurrentImageFormat = source.CurrentImageFormat,
RepeatCount = source.RepeatCount
};
action(source, transformedImage); action(source, transformedImage);

Loading…
Cancel
Save