mirror of https://github.com/SixLabors/ImageSharp
9 changed files with 74 additions and 7 deletions
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp |
|||
{ |
|||
public struct Color |
|||
{ |
|||
private Rgba64 data; |
|||
|
|||
public Color(Rgba64 pixel) |
|||
{ |
|||
this.data = pixel; |
|||
} |
|||
|
|||
public Color(Rgba32 pixel) |
|||
{ |
|||
this.data = default; |
|||
this.data.FromRgba32(pixel); |
|||
} |
|||
|
|||
public Color(Vector4 vector) |
|||
{ |
|||
this.data = default; |
|||
this.data.FromVector4(vector); |
|||
} |
|||
|
|||
public static Color FromRgba(byte r, byte g, byte b, byte a) => new Color(new Rgba32(r, g, b, a)); |
|||
public static Color FromRgba(ushort r, ushort g, ushort b, ushort a) => new Color(new Rgba64(r, g, b, a)); |
|||
|
|||
public TPixel ToPixel<TPixel>() |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
TPixel pixel = default; |
|||
pixel.FromRgba64(this.data); |
|||
return pixel; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Tests |
|||
{ |
|||
public class ColorTests |
|||
{ |
|||
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue