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 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;
			}			
		}
Beispiel #4
0
		static extern IntPtr cmsCreateGrayProfile (ref ColorCIExyY white_point,
							   HandleRef transfer_function);
Beispiel #5
0
		public static Profile CreateLab (ColorCIExyY wp)
		{
			return new Profile (cmsCreateLabProfile (out wp));
		}			
Beispiel #6
0
		static extern IntPtr cmsCreateLabProfile (out ColorCIExyY WhitePoint);
Beispiel #7
0
		public ColorCIExyYTriple (ColorCIExyY red, ColorCIExyY green, ColorCIExyY blue)
		{
			Red = red;
			Green = green;
			Blue = blue;
		}
Beispiel #8
0
 public static Profile CreateLab(ColorCIExyY wp)
 {
     return new Profile (NativeMethods.CmsCreateLabProfile (out wp));
 }
Beispiel #9
0
		static extern bool cmsWhitePointFromTemp(int TempSrc,  out ColorCIExyY white_point);
Beispiel #10
0
		static extern void cmsxyY2XYZ (out ColorCIEXYZ dest, ref ColorCIExyY src);
Beispiel #11
0
        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;
        }
Beispiel #12
0
 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));
 }
Beispiel #13
0
        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);
        }
Beispiel #14
0
		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);
Beispiel #15
0
		public ColorCIELab ToLab (ColorCIExyY wp)
		{
			return this.ToXYZ ().ToLab (wp);
		}
Beispiel #16
0
		static extern IntPtr cmsCreateRGBProfile (out ColorCIExyY whitepoint, 
						          out ColorCIExyYTriple primaries,
							  HandleRef [] gamma_table);
Beispiel #17
0
		static extern void cmsXYZ2xyY (out ColorCIExyY dest, ref ColorCIEXYZ source);
Beispiel #18
0
        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)));
        }
Beispiel #19
0
		public ColorCIELab ToLab (ColorCIExyY wp)
		{
			return ToLab (wp.ToXYZ ());
		}
Beispiel #20
0
 public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, GammaTable [] gamma)
 {
     handle = new HandleRef (this, NativeMethods.CmsCreateRGBProfile (out whitepoint, out primaries, CopyHandles (gamma)));
 }
Beispiel #21
0
        public static extern IntPtr CmsCreateRGBProfile(out ColorCIExyY whitepoint, 
						          out ColorCIExyYTriple primaries,
							  HandleRef [] transfer_function);