示例#1
0
            public void TestTempTable1000()
            {
                ColorCIExyY wp = WhitePointFromTemperature(1000);

                Assert.AreEqual(0.652756059, wp.x);
                Assert.AreEqual(0.344456906, wp.y);
            }
示例#2
0
        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))));
        }
示例#3
0
            public void TestTempTable10000()
            {
                ColorCIExyY wp = WhitePointFromTemperature(10000);

                Assert.AreEqual(0.280635904, wp.x);
                Assert.AreEqual(0.288290916, wp.y);
            }
示例#4
0
        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));
		}
示例#6
0
 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);
示例#7
0
 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);
		}
示例#9
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));

            GammaTable g = new GammaTable(4096, 2.2);

            GammaTable [] gamma = new GammaTable [] { g, g, g, g };

            return(new Profile(wp, primaries, gamma));
        }
示例#10
0
        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;
			}			
		}
示例#12
0
		static extern IntPtr cmsCreateLabProfile (out ColorCIExyY WhitePoint);
示例#13
0
		public ColorCIELab ToLab (ColorCIExyY wp)
		{
			return ToLab (wp.ToXYZ ());
		}
示例#14
0
		public ColorCIExyYTriple (ColorCIExyY red, ColorCIExyY green, ColorCIExyY blue)
		{
			Red = red;
			Green = green;
			Blue = blue;
		}
示例#15
0
 public static Profile CreateLab(ColorCIExyY wp)
 {
     return(new Profile(cmsCreateLabProfile(out wp)));
 }
示例#16
0
文件: Profile.cs 项目: hbons/f-spot
 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));
 }
示例#17
0
		static extern bool cmsWhitePointFromTemp(int TempSrc,  out ColorCIExyY white_point);
示例#18
0
 public static extern IntPtr CmsCreateLabProfile(out ColorCIExyY WhitePoint);
示例#19
0
		public static Profile CreateLab (ColorCIExyY wp)
		{
			return new Profile (cmsCreateLabProfile (out wp));
		}			
示例#20
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);
示例#21
0
 public ColorCIELab ToLab(ColorCIExyY wp)
 {
     return(this.ToXYZ().ToLab(wp));
 }
示例#22
0
 public static Profile CreateLab(ColorCIExyY wp)
 {
     return(new Profile(NativeMethods.CmsCreateLabProfile(out wp)));
 }
示例#23
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;
        }
示例#24
0
 public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, GammaTable [] gamma)
 {
     handle = new HandleRef(this, NativeMethods.CmsCreateRGBProfile(out whitepoint, out primaries, CopyHandles(gamma)));
 }
示例#25
0
 public ColorCIExyYTriple(ColorCIExyY red, ColorCIExyY green, ColorCIExyY blue)
 {
     Red   = red;
     Green = green;
     Blue  = blue;
 }
示例#26
0
		static extern IntPtr cmsCreateGrayProfile (ref ColorCIExyY white_point,
							   HandleRef transfer_function);
示例#27
0
 public static extern void CmsxyY2XYZ(out ColorCIEXYZ dest, ref ColorCIExyY src);
示例#28
0
		static extern IntPtr cmsCreateRGBProfile (out ColorCIExyY whitepoint, 
						          out ColorCIExyYTriple primaries,
							  HandleRef [] gamma_table);
示例#29
0
 public static extern IntPtr CmsCreateGrayProfile(ref ColorCIExyY white_point,
                                                  HandleRef transfer_function);
示例#30
0
 public ColorCIELab ToLab(ColorCIExyY wp)
 {
     return(ToLab(wp.ToXYZ()));
 }
示例#31
0
 public static Profile CreateLab(ColorCIExyY wp)
 {
     return new Profile (NativeMethods.CmsCreateLabProfile (out wp));
 }
示例#32
0
 public static extern IntPtr CmsCreateRGBProfile(out ColorCIExyY whitepoint,
                                                 out ColorCIExyYTriple primaries,
                                                 HandleRef [] gamma_table);
示例#33
0
		static extern void cmsXYZ2xyY (out ColorCIExyY dest, ref ColorCIEXYZ source);
示例#34
0
 public static extern bool CmsWhitePointFromTemp(int TempSrc, out ColorCIExyY white_point);
示例#35
0
文件: Profile.cs 项目: hbons/f-spot
        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);
        }
示例#36
0
 public static extern void CmsXYZ2xyY(out ColorCIExyY dest, ref ColorCIEXYZ source);
示例#37
0
		static extern void cmsxyY2XYZ (out ColorCIEXYZ dest, ref ColorCIExyY src);
示例#38
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)));
        }
示例#39
0
		public ColorCIELab ToLab (ColorCIExyY wp)
		{
			return this.ToXYZ ().ToLab (wp);
		}
示例#40
0
 public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, GammaTable [] gamma)
 {
     handle = new HandleRef (this, NativeMethods.CmsCreateRGBProfile (out whitepoint, out primaries, CopyHandles (gamma)));
 }
示例#41
0
        public static extern IntPtr CmsCreateRGBProfile(out ColorCIExyY whitepoint, 
						          out ColorCIExyYTriple primaries,
							  HandleRef [] transfer_function);