mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-21 16:12:18 -05:00
35 lines
904 B
C#
35 lines
904 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LittleCms
|
|
{
|
|
public static class CmsExtension
|
|
{
|
|
|
|
public static CIExyY ToCIExyY(this CIEXYZ xyz)
|
|
{
|
|
return new CIExyY { x = xyz.X / (xyz.X + xyz.Y + xyz.Z), y = xyz.Y / (xyz.X + xyz.Y + xyz.Z), Y = xyz.Y };
|
|
}
|
|
public static CIExyY ToXY(this CIEXYZ xyz)
|
|
{
|
|
var sum = xyz.X + xyz.Y + xyz.Z;
|
|
return new() { x = xyz.X / sum, y = xyz.Y / sum, Y = 1 };
|
|
}
|
|
|
|
public static CIEXYZ ToXYZ(this CIExyY xyY)
|
|
{
|
|
return new() { X = xyY.x * xyY.Y / xyY.y, Y = xyY.Y, Z = (1 - xyY.x - xyY.y) * xyY.Y / xyY.y };
|
|
}
|
|
|
|
public static int GetChannelCount(this ColorSpaceSignature sig)
|
|
{
|
|
return (int)CmsNative.cmsChannelsOf(sig);
|
|
}
|
|
|
|
|
|
}
|
|
}
|