mirror of https://github.com/SixLabors/ImageSharp
37 changed files with 221 additions and 198 deletions
@ -0,0 +1,15 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Bmp |
|||
{ |
|||
/// <summary>
|
|||
/// Provides Bmp specific metadata information for the image.
|
|||
/// </summary>
|
|||
public class BmpMetaData : IImageFormatMetaData |
|||
{ |
|||
// TODO: Analyse what properties we would like to preserve.
|
|||
} |
|||
} |
|||
@ -1,49 +0,0 @@ |
|||
// 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,38 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats |
|||
{ |
|||
/// <summary>
|
|||
/// The base class for all image formats.
|
|||
/// Inheriting classes should implement the singleton pattern by creating a private constructor.
|
|||
/// </summary>
|
|||
/// <typeparam name="T">The type of image format.</typeparam>
|
|||
public abstract class ImageFormatBase<T> : IImageFormat |
|||
where T : class, IImageFormat |
|||
{ |
|||
private static readonly Lazy<T> Lazy = new Lazy<T>(CreateInstance); |
|||
|
|||
/// <summary>
|
|||
/// Gets the current instance.
|
|||
/// </summary>
|
|||
public static T Instance => Lazy.Value; |
|||
|
|||
/// <inheritdoc/>
|
|||
public abstract string Name { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public abstract string DefaultMimeType { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public abstract IEnumerable<string> MimeTypes { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public abstract IEnumerable<string> FileExtensions { get; } |
|||
|
|||
private static T CreateInstance() => (T)Activator.CreateInstance(typeof(T), true); |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jpeg |
|||
{ |
|||
/// <summary>
|
|||
/// Provides Jpeg specific metadata information for the image.
|
|||
/// </summary>
|
|||
public class JpegMetaData : IImageFormatMetaData |
|||
{ |
|||
// TODO: Analyse what properties we would like to preserve.
|
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.MetaData; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Png |
|||
{ |
|||
/// <summary>
|
|||
/// Provides Png specific metadata information for the image.
|
|||
/// </summary>
|
|||
public class PngMetaData : IImageFormatMetaData |
|||
{ |
|||
// TODO: Analyse what properties we would like to preserve.
|
|||
} |
|||
} |
|||
@ -1,37 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using SixLabors.ImageSharp.Formats; |
|||
using SixLabors.ImageSharp.Formats.Bmp; |
|||
using SixLabors.ImageSharp.Formats.Gif; |
|||
using SixLabors.ImageSharp.Formats.Jpeg; |
|||
using SixLabors.ImageSharp.Formats.Png; |
|||
|
|||
namespace SixLabors.ImageSharp |
|||
{ |
|||
/// <summary>
|
|||
/// The static collection of all the default image formats
|
|||
/// </summary>
|
|||
public static class ImageFormats |
|||
{ |
|||
/// <summary>
|
|||
/// The format details for the jpegs.
|
|||
/// </summary>
|
|||
public static readonly IImageFormat Jpeg = new JpegFormat(); |
|||
|
|||
/// <summary>
|
|||
/// The format details for the pngs.
|
|||
/// </summary>
|
|||
public static readonly IImageFormat Png = new PngFormat(); |
|||
|
|||
/// <summary>
|
|||
/// The format details for the gifs.
|
|||
/// </summary>
|
|||
public static readonly IImageFormat Gif = new GifFormat(); |
|||
|
|||
/// <summary>
|
|||
/// The format details for the bitmaps.
|
|||
/// </summary>
|
|||
public static readonly IImageFormat Bmp = new BmpFormat(); |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.MetaData |
|||
{ |
|||
/// <summary>
|
|||
/// Encapsulates the format specific metadata of an image frame.
|
|||
/// This interface exists to allow type saftey and avoid the performance overhead of parsing attributes.
|
|||
/// </summary>
|
|||
public interface IImageFormatFrameMetaData |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.MetaData |
|||
{ |
|||
/// <summary>
|
|||
/// Encapsulates the format specific metadata of an image.
|
|||
/// This interface exists to allow type saftey and avoid the performance overhead of parsing attributes.
|
|||
/// </summary>
|
|||
public interface IImageFormatMetaData |
|||
{ |
|||
} |
|||
} |
|||
Loading…
Reference in new issue