mirror of https://github.com/SixLabors/ImageSharp
31 changed files with 399 additions and 325 deletions
@ -1,25 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Bmp |
|||
{ |
|||
/// <summary>
|
|||
/// Contains information about the bmp including dimensions, pixel type information and additional metadata.
|
|||
/// </summary>
|
|||
public class BmpInfo : ImageInfo |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="BmpInfo" /> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelType">The image pixel type information.</param>
|
|||
/// <param name="size">The size of the image in pixels.</param>
|
|||
/// <param name="metaData">The images metadata.</param>
|
|||
internal BmpInfo(PixelTypeInfo pixelType, Size size, ImageMetaData metaData) |
|||
: base(pixelType, size, metaData) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Gif |
|||
{ |
|||
/// <summary>
|
|||
/// Provides Gif specific metadata information for the image frame.
|
|||
/// </summary>
|
|||
public class GifFrameMetaData |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the length of the color table for paletted images.
|
|||
/// If not 0, then this field indicates the maximum number of colors to use when quantizing the
|
|||
/// image frame.
|
|||
/// </summary>
|
|||
public int ColorTableLength { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the frame delay for animated images.
|
|||
/// If not 0, when utilized in Gif animation, this field specifies the number of hundredths (1/100) of a second to
|
|||
/// wait before continuing with the processing of the Data Stream.
|
|||
/// The clock starts ticking immediately after the graphic is rendered.
|
|||
/// </summary>
|
|||
public int FrameDelay { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the disposal method for animated images.
|
|||
/// Primarily used in Gif animation, this field indicates the way in which the graphic is to
|
|||
/// be treated after being displayed.
|
|||
/// </summary>
|
|||
public GifDisposalMethod DisposalMethod { get; set; } |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Gif |
|||
{ |
|||
/// <summary>
|
|||
/// Contains information about the bmp including dimensions, pixel type information and additional metadata.
|
|||
/// </summary>
|
|||
public class GifInfo : ImageInfo |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="GifInfo" /> class.
|
|||
/// </summary>
|
|||
/// <param name="colorTableMode">The color table mode.</param>
|
|||
/// <param name="pixelType">The image pixel type information.</param>
|
|||
/// <param name="size">The size of the image in pixels.</param>
|
|||
/// <param name="metaData">The images metadata.</param>
|
|||
internal GifInfo( |
|||
GifColorTableMode colorTableMode, |
|||
PixelTypeInfo pixelType, |
|||
Size size, |
|||
ImageMetaData metaData) |
|||
: base(pixelType, size, metaData) => this.ColorTableMode = colorTableMode; |
|||
|
|||
/// <summary>
|
|||
/// Gets the color table mode.
|
|||
/// </summary>
|
|||
public GifColorTableMode ColorTableMode { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Gif |
|||
{ |
|||
/// <summary>
|
|||
/// Provides Gif specific metadata information for the image.
|
|||
/// </summary>
|
|||
public class GifMetaData |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the number of times any animation is repeated.
|
|||
/// <remarks>
|
|||
/// 0 means to repeat indefinitely, count is set as play n + 1 times
|
|||
/// </remarks>
|
|||
/// </summary>
|
|||
public ushort RepeatCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the color table mode.
|
|||
/// </summary>
|
|||
public GifColorTableMode ColorTableMode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the length of the global color table if present.
|
|||
/// </summary>
|
|||
public int GlobalColorTableLength { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Gif |
|||
{ |
|||
/// <summary>
|
|||
/// Extension methods for storing meta data specific to Gif images.
|
|||
/// </summary>
|
|||
public static class GifMetaDataExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Adds or updates the Gif specific meta data to the image.
|
|||
/// </summary>
|
|||
/// <param name="meta">The image meta data.</param>
|
|||
/// <param name="value">The gif meta data.</param>
|
|||
public static void AddOrUpdateGifMetaData(this ImageMetaData meta, GifMetaData value) => meta.AddOrUpdateMetaData(GifConstants.MetaDataKey, value); |
|||
|
|||
/// <summary>
|
|||
/// Gets the Gif format specific meta data from the image.
|
|||
/// </summary>
|
|||
/// <param name="meta">The image meta data.</param>
|
|||
/// <returns>The <see cref="GifMetaData"/> or null.</returns>
|
|||
public static GifMetaData GetGifMetaData(this ImageMetaData meta) |
|||
{ |
|||
meta.TryGetMetaData(GifConstants.MetaDataKey, out GifMetaData value); |
|||
return value; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Adds or updates the Gif specific meta data to the image frame.
|
|||
/// </summary>
|
|||
/// <param name="meta">The image meta data.</param>
|
|||
/// <param name="value">The gif meta data.</param>
|
|||
public static void AddOrUpdateGifFrameMetaData(this ImageFrameMetaData meta, GifFrameMetaData value) => meta.AddOrUpdateMetaData(GifConstants.MetaDataKey, value); |
|||
|
|||
/// <summary>
|
|||
/// Gets the Gif format specific meta data from the image frame.
|
|||
/// </summary>
|
|||
/// <param name="meta">The image meta data.</param>
|
|||
/// <returns>The <see cref="GifMetaData"/> or null.</returns>
|
|||
public static GifFrameMetaData GetGifFrameMetaData(this ImageFrameMetaData meta) |
|||
{ |
|||
meta.TryGetMetaData(GifConstants.MetaDataKey, out GifFrameMetaData value); |
|||
return value; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Buffers.Binary; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Gif |
|||
{ |
|||
internal readonly struct GifNetscapeLoopingApplicationExtension : IGifExtension |
|||
{ |
|||
public GifNetscapeLoopingApplicationExtension(ushort repeatCount) => this.RepeatCount = repeatCount; |
|||
|
|||
public byte Label => GifConstants.ApplicationExtensionLabel; |
|||
|
|||
/// <summary>
|
|||
/// Gets the repeat count.
|
|||
/// 0 means loop indefinitely. Count is set as play n + 1 times.
|
|||
/// </summary>
|
|||
public ushort RepeatCount { get; } |
|||
|
|||
public static GifNetscapeLoopingApplicationExtension Parse(ReadOnlySpan<byte> buffer) |
|||
{ |
|||
ushort repeatCount = BinaryPrimitives.ReadUInt16LittleEndian(buffer.Slice(0, 2)); |
|||
return new GifNetscapeLoopingApplicationExtension(repeatCount); |
|||
} |
|||
|
|||
public int WriteTo(Span<byte> buffer) |
|||
{ |
|||
buffer[0] = GifConstants.ApplicationBlockSize; |
|||
|
|||
// Write NETSCAPE2.0
|
|||
GifConstants.NetscapeApplicationIdentificationBytes.AsSpan().CopyTo(buffer.Slice(1, 11)); |
|||
|
|||
// Application Data ----
|
|||
buffer[12] = 3; // Application block length (always 3)
|
|||
buffer[13] = 1; // Data sub-block indentity (always 1)
|
|||
|
|||
// 0 means loop indefinitely. Count is set as play n + 1 times.
|
|||
BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(14, 2), this.RepeatCount); |
|||
|
|||
return 16; // Length - Introducer + Label + Terminator.
|
|||
} |
|||
} |
|||
} |
|||
@ -1,25 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg |
|||
{ |
|||
/// <summary>
|
|||
/// Contains information about the bmp including dimensions, pixel type information and additional metadata.
|
|||
/// </summary>
|
|||
public class JpegInfo : ImageInfo |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="JpegInfo" /> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelType">The image pixel type information.</param>
|
|||
/// <param name="size">The size of the image in pixels.</param>
|
|||
/// <param name="metaData">The images metadata.</param>
|
|||
internal JpegInfo(PixelTypeInfo pixelType, Size size, ImageMetaData metaData) |
|||
: base(pixelType, size, metaData) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -1,25 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
using SixLabors.Primitives; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Png |
|||
{ |
|||
/// <summary>
|
|||
/// Contains information about the bmp including dimensions, pixel type information and additional metadata.
|
|||
/// </summary>
|
|||
public class PngInfo : ImageInfo |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PngInfo" /> class.
|
|||
/// </summary>
|
|||
/// <param name="pixelType">The image pixel type information.</param>
|
|||
/// <param name="size">The size of the image in pixels.</param>
|
|||
/// <param name="metaData">The images metadata.</param>
|
|||
internal PngInfo(PixelTypeInfo pixelType, Size size, ImageMetaData metaData) |
|||
: base(pixelType, size, metaData) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -1,7 +1,7 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Gif |
|||
namespace SixLabors.ImageSharp.MetaData |
|||
{ |
|||
/// <summary>
|
|||
/// Enumerated frame process modes to apply to multi-frame images.
|
|||
Loading…
Reference in new issue