timelapsenow/TimelapseExtensions/ClockExtension/Rgb.cs

45 lines
1.3 KiB
C#
Raw Permalink Normal View History

2022-05-21 15:37:43 +00:00
using TimelapseApi;
using Eto.Forms;
using System;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Fonts;
namespace ClockExtension
{
public class Rgb
{
public byte Red {get;set;}
public byte Green {get;set;}
public byte Blue {get;set;}
public static implicit operator Rgb24(Rgb color)
{
return new Rgb24(color.Red,color.Green,color.Blue);
}
public static implicit operator Rgb(Color c)
{
return c.ToPixel<Rgb24>();
}
public static implicit operator Color(Rgb color)
{
return new Color(color);
}
public static implicit operator Rgb(Rgb24 color)
{
return new Rgb {Red=color.R,Green=color.G,Blue = color.B};
}
public static implicit operator Eto.Drawing.Color(Rgb color)
{
return new Eto.Drawing.Color((float)(color.Red/255.0),(float)(color.Green/255.0),(float)(color.Blue/255.0));
}
public static implicit operator Rgb(Eto.Drawing.Color color)
{
byte r=(byte)(color.R * 255);
byte g=(byte)(color.G * 255);
byte b=(byte)(color.B * 255);
return new Rgb{Red=r,Green=g,Blue=b};
}
}
}