public void TestTempTable1000() { ColorCIExyY wp = WhitePointFromTemperature(1000); Assert.AreEqual(0.652756059, wp.x); Assert.AreEqual(0.344456906, wp.y); }
public static Profile CreateAbstract(int nLUTPoints, double Exposure, double Bright, double Contrast, double Hue, double Saturation, GammaTable [] tables, ColorCIExyY src_wp, ColorCIExyY dest_wp) { if (tables == null) { GammaTable gamma = new GammaTable(1024, Math.Pow(10, -Bright / 100)); GammaTable line = new GammaTable(1024, 1.0); tables = new GammaTable [] { gamma, line, line }; } /* * System.Console.WriteLine ("e {0}", Exposure); * System.Console.WriteLine ("b {0}", Bright); * System.Console.WriteLine ("c {0}", Contrast); * System.Console.WriteLine ("h {0}", Hue); * System.Console.WriteLine ("s {0} {1} {2}", Saturation, src_wp, dest_wp); */ return(new Profile(NativeMethods.FCmsCreateBCHSWabstractProfile(nLUTPoints, Exposure, 0.0, //Bright, Contrast, Hue, Saturation, ref src_wp, ref dest_wp, CopyHandles(tables)))); }
public void TestTempTable10000() { ColorCIExyY wp = WhitePointFromTemperature(10000); Assert.AreEqual(0.280635904, wp.x); Assert.AreEqual(0.288290916, wp.y); }
public static ColorCIExyY WhitePointFromTemperatureResource(int temp, string name) { ColorCIExyY wp; //const int line_size = 0x1e; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name)) { StreamReader reader = new StreamReader(stream, System.Text.Encoding.ASCII); string line = null; for (int i = 0; i <= temp - 1000; i++) { line = reader.ReadLine(); } //System.Console.WriteLine (line); string [] subs = line.Split('\t'); int ptemp = int.Parse(subs [0]); if (ptemp != temp) { throw new CmsException(String.Format("{0} != {1}", ptemp, temp)); } double x = double.Parse(subs [1]); double y = double.Parse(subs [2]); wp = new ColorCIExyY(x, y, 1.0); return(wp); } }
public static Profile CreateGray (ColorCIExyY white_point, GammaTable transfer) { if (transfer == null) return new Profile (NativeMethods.CmsCreateGrayProfile (ref white_point, new GammaTable (4096, 2.2).Handle)); else return new Profile (NativeMethods.CmsCreateGrayProfile (ref white_point, transfer.Handle)); }
public static extern IntPtr FCmsCreateBCHSWabstractProfile(int nLUTPoints, double Exposure, double Bright, double Contrast, double Hue, double Saturation, ref ColorCIExyY src_wp, ref ColorCIExyY dest_wp, HandleRef [] tables);
public static Profile CreateGray(ColorCIExyY white_point, GammaTable transfer) { if (transfer == null) { return(new Profile(NativeMethods.CmsCreateGrayProfile(ref white_point, new GammaTable(4096, 2.2).Handle))); } else { return(new Profile(NativeMethods.CmsCreateGrayProfile(ref white_point, transfer.Handle))); } }
public static Profile CreateAlternateRgb () { // FIXME I'm basing this off the values set in the camera // exif data when the adobe profile is selected. They could // easily be off ColorCIExyY wp = new ColorCIExyY (.3127, .329, 1.0); ColorCIExyYTriple primaries = new ColorCIExyYTriple ( new ColorCIExyY (.64, .33, 1.0), new ColorCIExyY (.21, .71, 1.0), new ColorCIExyY (.15, .06, 1.0)); GammaTable g = new GammaTable (4096, 2.2); GammaTable [] gamma = new GammaTable [] { g, g, g, g}; return new Profile (wp, primaries, gamma); }
public static Profile CreateAlternateRgb() { // FIXME I'm basing this off the values set in the camera // exif data when the adobe profile is selected. They could // easily be off ColorCIExyY wp = new ColorCIExyY(.3127, .329, 1.0); ColorCIExyYTriple primaries = new ColorCIExyYTriple( new ColorCIExyY(.64, .33, 1.0), new ColorCIExyY(.21, .71, 1.0), new ColorCIExyY(.15, .06, 1.0)); GammaTable g = new GammaTable(4096, 2.2); GammaTable [] gamma = new GammaTable [] { g, g, g, g }; return(new Profile(wp, primaries, gamma)); }
public static Profile CreateAbstract(int nLUTPoints, double Exposure, double Bright, double Contrast, double Hue, double Saturation, int TempSrc, int TempDest) { #if true GammaTable gamma = new GammaTable(1024, Math.Pow(10, -Bright / 100)); GammaTable line = new GammaTable(1024, 1.0); GammaTable [] tables = new GammaTable [] { gamma, line, line }; return(CreateAbstract(nLUTPoints, Exposure, 0.0, Contrast, Hue, Saturation, tables, ColorCIExyY.WhitePointFromTemperature(TempSrc), ColorCIExyY.WhitePointFromTemperature(TempDest))); #else GammaTable [] tables = null; return(CreateAbstract(nLUTPoints, Exposure, Bright, Contrast, Hue, Saturation, tables, ColorCIExyY.WhitePointFromTemperature(TempSrc), ColorCIExyY.WhitePointFromTemperature(TempDest))); #endif }
public static ColorCIExyY WhitePointFromTemperatureResource (int temp, string name) { ColorCIExyY wp; //const int line_size = 0x1e; using (Stream stream = Assembly.GetExecutingAssembly ().GetManifestResourceStream (name)) { StreamReader reader = new StreamReader (stream, System.Text.Encoding.ASCII); string line = null; for (int i = 0; i <= temp - 1000; i++) { line = reader.ReadLine (); } //System.Console.WriteLine (line); string [] subs = line.Split ('\t'); int ptemp = int.Parse (subs [0]); if (ptemp != temp) throw new System.Exception (String.Format ("{0} != {1}", ptemp, temp)); double x = double.Parse (subs [1]); double y = double.Parse (subs [2]); wp = new ColorCIExyY (x, y, 1.0); return wp; } }
static extern IntPtr cmsCreateLabProfile (out ColorCIExyY WhitePoint);
public ColorCIELab ToLab (ColorCIExyY wp) { return ToLab (wp.ToXYZ ()); }
public ColorCIExyYTriple (ColorCIExyY red, ColorCIExyY green, ColorCIExyY blue) { Red = red; Green = green; Blue = blue; }
public static Profile CreateLab(ColorCIExyY wp) { return(new Profile(cmsCreateLabProfile(out wp))); }
public static Profile CreateGray(ColorCIExyY whitePoint, ToneCurve transfer) { if (transfer == null) return new Profile (NativeMethods.CmsCreateGrayProfile (ref whitePoint, new ToneCurve (2.2).Handle)); else return new Profile (NativeMethods.CmsCreateGrayProfile (ref whitePoint, transfer.Handle)); }
static extern bool cmsWhitePointFromTemp(int TempSrc, out ColorCIExyY white_point);
public static extern IntPtr CmsCreateLabProfile(out ColorCIExyY WhitePoint);
public static Profile CreateLab (ColorCIExyY wp) { return new Profile (cmsCreateLabProfile (out wp)); }
static extern IntPtr f_cmsCreateBCHSWabstractProfile(int nLUTPoints, double Exposure, double Bright, double Contrast, double Hue, double Saturation, ref ColorCIExyY src_wp, ref ColorCIExyY dest_wp, HandleRef [] tables);
public ColorCIELab ToLab(ColorCIExyY wp) { return(this.ToXYZ().ToLab(wp)); }
public static Profile CreateLab(ColorCIExyY wp) { return(new Profile(NativeMethods.CmsCreateLabProfile(out wp))); }
public override Cms.Profile GetProfile() { ColorChunk color = null; IccpChunk icc = null; GammaChunk gamma = null; StandardRgbChunk srgb = null; double gamma_value = 2.2; ColorCIExyY red = new ColorCIExyY (0.64, 0.33, 1.0); ColorCIExyY green = new ColorCIExyY (0.3, 0.6, 1.0); ColorCIExyY blue = new ColorCIExyY (0.15, 0.06, 1.0); ColorCIExyY whitepoint = new ColorCIExyY (0.3127, 0.329, 1.0); ColorCIExyYTriple chroma = new ColorCIExyYTriple (red, green, blue); //System.Console.WriteLine ("Trying to get profile"); foreach (Chunk chunk in Chunks) { if (color == null) color = chunk as ColorChunk; if (icc == null) icc = chunk as IccpChunk; if (srgb == null) srgb = chunk as StandardRgbChunk; if (gamma == null) gamma = chunk as GammaChunk; } //System.Console.WriteLine ("color: {0} icc: {1} srgb: {2} gamma: {3}", color, icc, srgb, gamma); if (icc != null) { try { return new Profile (icc.Profile); } catch (System.Exception ex) { System.Console.WriteLine ("Error trying to decode embedded profile" + ex.ToString ()); } } if (srgb != null) return Profile.CreateStandardRgb (); if (gamma != null) gamma_value = 1 / gamma.Gamma; if (color != null) { whitepoint = new ColorCIExyY (color.WhiteX.Value, color.WhiteY.Value, 1.0); red = new ColorCIExyY (color.RedX.Value, color.RedY.Value, 1.0); green = new ColorCIExyY (color.GreenX.Value, color.GreenY.Value, 1.0); blue = new ColorCIExyY (color.BlueX.Value, color.BlueY.Value, 1.0); chroma = new ColorCIExyYTriple (red, green, blue); } if (color != null || gamma != null) { GammaTable table = new GammaTable (1024, gamma_value); return new Profile (whitepoint, chroma, new GammaTable [] {table, table, table}); } return null; }
public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, GammaTable [] gamma) { handle = new HandleRef(this, NativeMethods.CmsCreateRGBProfile(out whitepoint, out primaries, CopyHandles(gamma))); }
public ColorCIExyYTriple(ColorCIExyY red, ColorCIExyY green, ColorCIExyY blue) { Red = red; Green = green; Blue = blue; }
static extern IntPtr cmsCreateGrayProfile (ref ColorCIExyY white_point, HandleRef transfer_function);
public static extern void CmsxyY2XYZ(out ColorCIEXYZ dest, ref ColorCIExyY src);
static extern IntPtr cmsCreateRGBProfile (out ColorCIExyY whitepoint, out ColorCIExyYTriple primaries, HandleRef [] gamma_table);
public static extern IntPtr CmsCreateGrayProfile(ref ColorCIExyY white_point, HandleRef transfer_function);
public ColorCIELab ToLab(ColorCIExyY wp) { return(ToLab(wp.ToXYZ())); }
public static Profile CreateLab(ColorCIExyY wp) { return new Profile (NativeMethods.CmsCreateLabProfile (out wp)); }
public static extern IntPtr CmsCreateRGBProfile(out ColorCIExyY whitepoint, out ColorCIExyYTriple primaries, HandleRef [] gamma_table);
static extern void cmsXYZ2xyY (out ColorCIExyY dest, ref ColorCIEXYZ source);
public static extern bool CmsWhitePointFromTemp(int TempSrc, out ColorCIExyY white_point);
public static Profile CreateAlternateRgb() { // FIXME I'm basing this off the values set in the camera // exif data when the adobe profile is selected. They could // easily be off ColorCIExyY wp = new ColorCIExyY (.3127, .329, 1.0); ColorCIExyYTriple primaries = new ColorCIExyYTriple ( new ColorCIExyY (.64, .33, 1.0), new ColorCIExyY (.21, .71, 1.0), new ColorCIExyY (.15, .06, 1.0)); ToneCurve tc = new ToneCurve (2.2); ToneCurve [] tcs = new ToneCurve [] { tc, tc, tc, tc}; return new Profile (wp, primaries, tcs); }
public static extern void CmsXYZ2xyY(out ColorCIExyY dest, ref ColorCIEXYZ source);
static extern void cmsxyY2XYZ (out ColorCIEXYZ dest, ref ColorCIExyY src);
public static Profile CreateAbstract(int nLUTPoints, double Exposure, double Bright, double Contrast, double Hue, double Saturation, GammaTable [] tables, ColorCIExyY srcWp, ColorCIExyY destWp) { if (tables == null) { GammaTable gamma = new GammaTable (1024, Math.Pow (10, -Bright/100)); GammaTable line = new GammaTable (1024, 1.0); tables = new GammaTable [] { gamma, line, line }; } /* System.Console.WriteLine ("e {0}", Exposure); System.Console.WriteLine ("b {0}", Bright); System.Console.WriteLine ("c {0}", Contrast); System.Console.WriteLine ("h {0}", Hue); System.Console.WriteLine ("s {0} {1} {2}", Saturation, srcWp, destWp); */ return new Profile (NativeMethods.FCmsCreateBCHSWabstractProfile (nLUTPoints, Exposure, 0.0, //Bright, Contrast, Hue, Saturation, ref srcWp, ref destWp, CopyHandles (tables))); }
public ColorCIELab ToLab (ColorCIExyY wp) { return this.ToXYZ ().ToLab (wp); }
public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, GammaTable [] gamma) { handle = new HandleRef (this, NativeMethods.CmsCreateRGBProfile (out whitepoint, out primaries, CopyHandles (gamma))); }
public static extern IntPtr CmsCreateRGBProfile(out ColorCIExyY whitepoint, out ColorCIExyYTriple primaries, HandleRef [] transfer_function);