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

Loading…
Cancel
Save