mirror of https://github.com/SixLabors/ImageSharp
13 changed files with 31 additions and 95 deletions
@ -1,36 +0,0 @@ |
|||||
// <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(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,24 +0,0 @@ |
|||||
// <copyright file="ImageFactory.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 ImageSharp.PixelFormats; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// TODO: Non-generic 'Image' class has been removed. We no longer need the factory pattern here!
|
|
||||
/// </summary>
|
|
||||
public class ImageFactory : GenericFactory<Rgba32> |
|
||||
{ |
|
||||
public override Image<Rgba32> CreateImage(byte[] bytes) => Image.Load<Rgba32>(bytes); |
|
||||
|
|
||||
public override Image<Rgba32> CreateImage(int width, int height) => new Image<Rgba32>(width, height); |
|
||||
|
|
||||
public override Image<Rgba32> CreateImage(Image<Rgba32> other) |
|
||||
{ |
|
||||
return other.Clone(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue