mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
// <copyright file="GenericFactory.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace ImageSharp.Tests
|
|
{
|
|
using System;
|
|
|
|
using ImageSharp.PixelFormats;
|
|
|
|
/// <summary>
|
|
/// TODO: Non-generic 'Image' class has been removed. We no longer need the factory pattern here!
|
|
///
|
|
/// Utility class to create specialized subclasses of generic classes (eg. <see cref="Image"/>)
|
|
/// Used as parameter for <see cref="WithMemberFactoryAttribute"/> -based factory methods
|
|
/// </summary>
|
|
public class GenericFactory<TPixel>
|
|
where TPixel : struct, IPixel<TPixel>
|
|
{
|
|
public virtual Image<TPixel> CreateImage(int width, int height)
|
|
{
|
|
return new Image<TPixel>(width, height);
|
|
}
|
|
|
|
public virtual Image<TPixel> CreateImage(byte[] bytes)
|
|
{
|
|
return Image.Load<TPixel>(bytes);
|
|
}
|
|
|
|
public virtual Image<TPixel> CreateImage(Image<TPixel> other)
|
|
{
|
|
return other.Clone();
|
|
}
|
|
}
|
|
}
|