コード例 #1
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));
		}
コード例 #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 TestAlloc()
            {
                ushort []  values = new ushort [] { 0, 0x00ff, 0xffff };
                GammaTable t      = new GammaTable(values);

                for (int i = 0; i < values.Length; i++)
                {
                    Assert.AreEqual(t[i], values [i]);
                }
            }
コード例 #4
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)));
     }
 }
コード例 #5
0
		protected override List <Cms.Profile> GenerateAdjustments ()
		{
			List <Cms.Profile> profiles = new List <Cms.Profile> ();
			Histogram hist = new Histogram (Input);
			tables = new GammaTable [3];

			for (int channel = 0; channel < tables.Length; channel++) {
				int high, low;
				hist.GetHighLow (channel, out high, out low);
				System.Console.WriteLine ("high = {0}, low = {1}", high, low);
				tables [channel] = StretchChannel (255, low / 255.0, high / 255.0); 
			}
			profiles.Add (new Cms.Profile (IccColorSpace.Rgb, tables));
			return profiles;
		}
コード例 #6
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);
		}
コード例 #7
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));
        }
コード例 #8
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
        }
コード例 #9
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)));
 }
コード例 #10
0
ファイル: Profile.cs プロジェクト: iainlane/f-spot
 public Profile(IccColorSpace color_space, GammaTable [] gamma)
 {
     handle = new HandleRef (this, NativeMethods.CmsCreateLinearizationDeviceLink (color_space, CopyHandles (gamma)));
 }
コード例 #11
0
ファイル: Profile.cs プロジェクト: iainlane/f-spot
        private static HandleRef[] CopyHandles(GammaTable [] gamma)
        {
            if (gamma == null)
                return null;

            HandleRef [] gamma_handles = new HandleRef [gamma.Length];
            for (int i = 0; i < gamma_handles.Length; i++)
                gamma_handles [i] = gamma [i].Handle;

            return gamma_handles;
        }
コード例 #12
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)));
        }
コード例 #13
0
ファイル: Profile.cs プロジェクト: iainlane/f-spot
        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
        }
コード例 #14
0
			public void TestAlloc ()
			{
				ushort [] values = new ushort [] { 0, 0x00ff, 0xffff };
				GammaTable t = new GammaTable (values);
				for (int i = 0; i < values.Length; i++) {
					Assert.AreEqual (t[i], values [i]);
				}
			} 
コード例 #15
0
			public void Linearize (string name)
			{
				GammaTable table = new GammaTable (new ushort [] { 0x0000, 0x0000, 0x0000, 0x0000 });
				Profile link = new Profile (IccColorSpace.Rgb, new GammaTable [] { table, table, table });

				string path = CreateFile (name, 32);
				using (FilterRequest req = new FilterRequest (path)) {
					ColorFilter filter = new ColorFilter ();
					filter.DeviceLink = link;
					Assert.IsTrue (filter.Convert (req), "Filter failed to operate");
					req.Preserve (req.Current);
					Assert.IsTrue (System.IO.File.Exists (req.Current.LocalPath),
						       "Error: Did not create " + req.Current);
					Assert.IsTrue (new FileInfo (req.Current.LocalPath).Length > 0,
						       "Error: " + req.Current + "is Zero length");
					using (ImageFile img = ImageFile.Create (req.Current)) {
						Pixbuf pixbuf = img.Load ();
						Assert.IsNotNull (pixbuf);
						// We linearized to all black so this should pass the gray test
						Assert.IsTrue (PixbufUtils.IsGray (pixbuf, 1), "failed to linearize" + req.Current);
					}
				}

			}
コード例 #16
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;
        }