コード例 #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
ファイル: ColorCIExyY.cs プロジェクト: neuroradiology/f-spot
        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);
            }
        }
コード例 #5
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));
		}
コード例 #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)));
     }
 }
コード例 #8
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);
		}
コード例 #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
        }
コード例 #11
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 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
ファイル: ColorCIExyY.cs プロジェクト: neuroradiology/f-spot
 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
ファイル: PngFile.cs プロジェクト: iainlane/f-spot
        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
ファイル: ColorCIExyY.cs プロジェクト: neuroradiology/f-spot
 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
ファイル: Profile.cs プロジェクト: iainlane/f-spot
 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
ファイル: Profile.cs プロジェクト: iainlane/f-spot
        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
ファイル: Profile.cs プロジェクト: iainlane/f-spot
 public Profile(ColorCIExyY whitepoint, ColorCIExyYTriple primaries, GammaTable [] gamma)
 {
     handle = new HandleRef (this, NativeMethods.CmsCreateRGBProfile (out whitepoint, out primaries, CopyHandles (gamma)));
 }
コード例 #41
0
ファイル: NativeMethods.cs プロジェクト: hbons/f-spot
        public static extern IntPtr CmsCreateRGBProfile(out ColorCIExyY whitepoint, 
						          out ColorCIExyYTriple primaries,
							  HandleRef [] transfer_function);