Browse Source

Pass metadata directly to WriteComments to avoid unnessary codegen.

af/merge-core
Jason Nelson 8 years ago
parent
commit
3acd97cdfe
  1. 12
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs

12
src/ImageSharp/Formats/Gif/GifEncoderCore.cs

@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
this.WriteLogicalScreenDescriptor(image, stream, index);
// Write the first frame.
this.WriteComments(image, stream);
this.WriteComments(image.MetaData, stream);
// Write additional frames.
if (image.Frames.Count > 1)
@ -212,18 +212,16 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary>
/// Writes the image comments to the stream.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="image">The <see cref="ImageFrame{TPixel}"/> to be encoded.</param>
/// <param name="metadata">The metadata to be extract the comment data.</param>
/// <param name="stream">The stream to write to.</param>
private void WriteComments<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel>
private void WriteComments(ImageMetaData metadata, Stream stream)
{
if (this.ignoreMetadata)
{
return;
}
ImageProperty property = image.MetaData.Properties.FirstOrDefault(p => p.Name == GifConstants.Comments);
ImageProperty property = metadata.Properties.FirstOrDefault(p => p.Name == GifConstants.Comments);
if (property == null || string.IsNullOrEmpty(property.Value))
{
return;

Loading…
Cancel
Save