public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, ToneCurve [] gamma) { Handle = new HandleRef (this, NativeMethods.CmsCreateRGBProfile (out whitepoint, out primaries, CopyHandles (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)); ToneCurve tc = new ToneCurve (2.2); ToneCurve [] tcs = new ToneCurve [] { tc, tc, tc, tc}; return new Profile (wp, primaries, tcs); }
public Cms.Profile GetProfile () { Cms.ColorCIExyY whitepoint = new Cms.ColorCIExyY (0, 0, 0); Cms.ColorCIExyYTriple primaries = new Cms.ColorCIExyYTriple (whitepoint, whitepoint, whitepoint); Cms.GammaTable [] transfer = null; int bits_per_sample = 8; double gamma = 2.2; foreach (DirectoryEntry e in entries) { switch (e.Id) { case TagId.InterColorProfile: try { return new Cms.Profile (e.RawData); } catch (System.Exception ex) { System.Console.WriteLine (ex); } break; case TagId.ColorSpace: switch ((ColorSpace)e.ValueAsLong [0]) { case ColorSpace.StandardRGB: return Cms.Profile.CreateStandardRgb (); case ColorSpace.AdobeRGB: return Cms.Profile.CreateAlternateRgb (); case ColorSpace.Uncalibrated: System.Console.WriteLine ("Uncalibrated colorspace"); break; } break; case TagId.WhitePoint: Rational [] white = e.RationalValue; whitepoint.x = white [0].Value; whitepoint.y = white [1].Value; whitepoint.Y = 1.0; break; case TagId.PrimaryChromaticities: Rational [] colors = e.RationalValue; primaries.Red.x = colors [0].Value; primaries.Red.y = colors [1].Value; primaries.Red.Y = 1.0; primaries.Green.x = colors [2].Value; primaries.Green.y = colors [3].Value; primaries.Green.Y = 1.0; primaries.Blue.x = colors [4].Value; primaries.Blue.y = colors [5].Value; primaries.Blue.Y = 1.0; break; case TagId.TransferFunction: ushort [] trns = e.ShortValue; ushort gamma_count = (ushort) (1 << bits_per_sample); Cms.GammaTable [] tables = new Cms.GammaTable [3]; System.Console.WriteLine ("Parsing transfer function: count = {0}", trns.Length); // FIXME we should use the TransferRange here // FIXME we should use bits per sample here for (int c = 0; c < 3; c++) { tables [c] = new Cms.GammaTable (trns, c * gamma_count, gamma_count); } transfer = tables; break; case TagId.ExifIfdPointer: SubdirectoryEntry exif = (SubdirectoryEntry) e; DirectoryEntry ee = exif.Directory [0].Lookup ((int)TagId.Gamma); if (ee == null) break; Rational rgamma = ee.RationalValue [0]; gamma = rgamma.Value; break; } } if (transfer == null) { Cms.GammaTable basic = new Cms.GammaTable (1 << bits_per_sample, gamma); transfer = new Cms.GammaTable [] { basic, basic, basic }; } // if we didn't get a white point or primaries, give up if (whitepoint.Y != 1.0 || primaries.Red.Y != 1.0) return null; return new Cms.Profile (whitepoint, primaries, transfer); }
public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, ToneCurve[] 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);