f-spot r3960 - in trunk/src: . Cms
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r3960 - in trunk/src: . Cms
- Date: Wed, 21 May 2008 07:15:03 +0000 (UTC)
Author: sdelcroix
Date: Wed May 21 07:15:02 2008
New Revision: 3960
URL: http://svn.gnome.org/viewvc/f-spot?rev=3960&view=rev
Log:
splitting Cms.cs in multiple files
Added:
trunk/src/Cms/ColorCIELCh.cs
trunk/src/Cms/ColorCIELab.cs
trunk/src/Cms/ColorCIEXYZ.cs
trunk/src/Cms/ColorCIExyY.cs
trunk/src/Cms/Format.cs
trunk/src/Cms/GammaTable.cs
trunk/src/Cms/IccColorSpace.cs
trunk/src/Cms/Intent.cs
trunk/src/Cms/Profile.cs
- copied, changed from r3958, /trunk/src/Cms/Cms.cs
trunk/src/Cms/Transform.cs
Removed:
trunk/src/Cms/Cms.cs
Modified:
trunk/src/Makefile.am
Added: trunk/src/Cms/ColorCIELCh.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/ColorCIELCh.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,31 @@
+/*
+ * Cms.ColorCIELCh.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Cms {
+ public struct ColorCIELCh {
+ public double L;
+ public double C;
+ public double h;
+
+ public ColorCIELab ToLab ()
+ {
+ ColorCIELab lab;
+ NativeMethods.CmsLCh2Lab (out lab, ref this);
+
+ return lab;
+ }
+ }
+}
Added: trunk/src/Cms/ColorCIELab.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/ColorCIELab.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,44 @@
+/*
+ * Cms.ColorCIELab.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Cms {
+ public struct ColorCIELab {
+ public double L;
+ public double a;
+ public double b;
+
+ public ColorCIELCh ToLCh ()
+ {
+ ColorCIELCh lch;
+ NativeMethods.CmsLab2LCh (out lch, ref this);
+
+ return lch;
+ }
+
+ public ColorCIEXYZ ToXYZ (ColorCIEXYZ wp)
+ {
+ ColorCIEXYZ xyz;
+ NativeMethods.CmsLab2XYZ (ref wp, out xyz, ref this);
+
+ return xyz;
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("(L={0}, a={1}, b={2})", L, a, b);
+ }
+ }
+}
Added: trunk/src/Cms/ColorCIEXYZ.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/ColorCIEXYZ.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,76 @@
+/*
+ * Cms.ColorCIEXYZ.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Cms {
+ public struct ColorCIEXYZ {
+ public double x;
+ public double y;
+ public double z;
+
+ public ColorCIEXYZ (double x, double y, double z)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public ColorCIExyY ToxyY ()
+ {
+ ColorCIExyY dest;
+ NativeMethods.CmsXYZ2xyY (out dest, ref this);
+
+ return dest;
+ }
+
+ public ColorCIELab ToLab (ColorCIEXYZ wp)
+ {
+ ColorCIELab lab;
+ NativeMethods.CmsXYZ2Lab (ref wp, out lab, ref this);
+
+ return lab;
+ }
+
+ public static ColorCIEXYZ D50 {
+ get {
+ IntPtr ptr = NativeMethods.CmsD50XYZ ();
+ return (ColorCIEXYZ) Marshal.PtrToStructure (ptr, typeof (ColorCIEXYZ));
+ }
+ }
+
+ public ColorCIELab ToLab (ColorCIExyY wp)
+ {
+ return ToLab (wp.ToXYZ ());
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("(x={0}, y={1}, z={2})", x, y, z);
+ }
+ }
+
+ public struct ColorCIEXYZTriple {
+ public ColorCIEXYZ Red;
+ public ColorCIEXYZ Blue;
+ public ColorCIEXYZ Green;
+
+ ColorCIEXYZTriple (ColorCIEXYZ red, ColorCIEXYZ green, ColorCIEXYZ blue)
+ {
+ Red = red;
+ Blue = blue;
+ Green = green;
+ }
+ }
+}
Added: trunk/src/Cms/ColorCIExyY.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/ColorCIExyY.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,112 @@
+/*
+ * Cms.ColorCIExyY.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Cms {
+ public struct ColorCIExyY {
+ public double x;
+ public double y;
+ public double Y;
+
+ public ColorCIExyY (double x, double y, double Y)
+ {
+ this.x = x;
+ this.y = y;
+ this.Y = Y;
+ }
+
+ public static ColorCIExyY WhitePointFromTemperature (int temp)
+ {
+ double x, y;
+ CctTable.GetXY (temp, out x, out y);
+ return new ColorCIExyY (x, y, 1.0);
+ }
+
+ public static ColorCIExyY WhitePointFromTemperatureCIE (int temp)
+ {
+ ColorCIExyY wp;
+ NativeMethods.CmsWhitePointFromTemp (temp, out wp);
+ return wp;
+ }
+
+ 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;
+ }
+ }
+
+ public ColorCIEXYZ ToXYZ ()
+ {
+ ColorCIEXYZ dest;
+ NativeMethods.CmsxyY2XYZ (out dest, ref this);
+
+ return dest;
+ }
+
+ public static ColorCIExyY D50 {
+ get {
+ IntPtr ptr = NativeMethods.CmsD50xyY ();
+ return (ColorCIExyY) Marshal.PtrToStructure (ptr, typeof (ColorCIExyY));
+ }
+ }
+
+ public ColorCIELab ToLab (ColorCIExyY wp)
+ {
+ return this.ToXYZ ().ToLab (wp);
+ }
+
+ public ColorCIELab ToLab (ColorCIEXYZ wp)
+ {
+ return this.ToXYZ ().ToLab (wp);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("(x={0}, y={1}, Y={2})", x, y, Y);
+ }
+ }
+
+ public struct ColorCIExyYTriple {
+ public ColorCIExyY Red;
+ public ColorCIExyY Green;
+ public ColorCIExyY Blue;
+
+ public ColorCIExyYTriple (ColorCIExyY red, ColorCIExyY green, ColorCIExyY blue)
+ {
+ Red = red;
+ Green = green;
+ Blue = blue;
+ }
+ }
+}
Added: trunk/src/Cms/Format.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/Format.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,26 @@
+/*
+ * Cms.Format.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace Cms {
+ public enum Format : uint {
+ Rgb8 = 262169,
+ Rgba8 = 262297,
+ Rgba8Planar = 266393,
+ Gbr8 = 263193,
+ Rgb16 = 262170,
+ Rgb16Planar = 266266,
+ Rgba16 = 262298,
+ Rgba16se = 264436,
+ Rgb16se = 264218,
+ Lab8 = 655385,
+ Lab16 = 655386,
+ Xyz16 = 589858,
+ Yxy16 = 917530
+ }
+}
Added: trunk/src/Cms/GammaTable.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/GammaTable.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,146 @@
+/*
+ * Cms.GammaTable.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Cms {
+ public class GammaTable : IDisposable {
+ private HandleRef handle;
+ public HandleRef Handle {
+ get {
+ return handle;
+ }
+ }
+
+// internal struct GammaTableStruct {
+// public int Count;
+// public ushort StartOfData; // ushort array Count entries long
+// }
+
+ public GammaTable (int count, double gamma)
+ {
+ handle = new HandleRef (this, NativeMethods.CmsBuildGamma (count, gamma));
+ }
+
+ /*
+ Does build a parametric curve based on parameters.
+ Params[] does contain Gamma, a, b, c, d, e, f
+
+ Type 1 :
+ X = Y ^ Gamma | Gamma = Params[0]
+
+ Type 2 :
+ CIE 122-1966
+ Y = (aX + b)^Gamma | X >= -b/a
+ Y = 0 | else
+ Type 3:
+
+ IEC 61966-3
+ Y = (aX + b)^Gamma | X <= -b/a
+ Y = c | else
+
+ Type 4:
+ IEC 61966-2.1 (sRGB)
+ Y = (aX + b)^Gamma | X >= d
+ Y = cX | X < d
+
+ Type 5:
+
+ Y = (aX + b)^Gamma + e | X <= d
+ Y = cX + f | else
+
+ Giving negative values for Type does result in reversed curve.
+ */
+
+ // FIXME type should be an enum
+ public GammaTable (int entry_count, int type, double [] values)
+ {
+ handle = new HandleRef (this, NativeMethods.CmsBuildParametricGamma (entry_count, type, values));
+ }
+
+
+ public GammaTable (ushort [] values) : this (values, 0, values.Length)
+ {
+ }
+
+ public int Count {
+ get {
+ return NativeMethods.FCmsGammaTableGetCount (handle);
+ }
+ }
+
+ public IntPtr Values {
+ get {
+ return NativeMethods.FCmsGammaTableGetValues (handle);
+ }
+ }
+
+ public ushort this [int index] {
+ get {
+ unsafe {
+ if (handle.Handle == (IntPtr)0)
+ throw new Exception ();
+
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException (String.Format ("index {0} outside of count {1} for {2}", index, Count, handle.Handle));
+
+ ushort *data = (ushort *)Values;
+ return data [index];
+ }
+ }
+ set {
+ unsafe {
+ if (handle.Handle == (IntPtr)0)
+ throw new Exception ();
+
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException (String.Format ("index {0} outside of count {1} for handle {2}", index, Count, handle.Handle));
+
+
+ ushort *data = (ushort *)Values;
+ data [index] = value;
+ }
+ }
+ }
+
+ public GammaTable (ushort [] values, int start_offset, int length)
+ {
+#if true
+ handle = new HandleRef (this, NativeMethods.FCmsGammaTableNew (values, start_offset, length));
+ //System.Console.WriteLine ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXhandle = {0}", handle.Handle);
+#else
+ handle = new HandleRef (this, cmsAllocGamma (length));
+ //System.Console.WriteLine ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXhandle = {0}", handle.Handle);
+ for (int i = 0; i < length; i++)
+ this [i] = values [start_offset + i];
+#endif
+ }
+
+ protected virtual void Cleanup ()
+ {
+ NativeMethods.CmsFreeGamma (handle);
+ }
+
+ public void Dispose ()
+ {
+ Cleanup ();
+ System.GC.SuppressFinalize (this);
+ }
+
+ ~GammaTable ()
+ {
+ Cleanup ();
+ }
+ }
+}
Added: trunk/src/Cms/IccColorSpace.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/IccColorSpace.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,38 @@
+/*
+ * Cms.IccColorSpace.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace Cms {
+ public enum IccColorSpace : uint {
+ XYZ = 0x58595A20, /* 'XYZ ' */
+ Lab = 0x4C616220, /* 'Lab ' */
+ Luv = 0x4C757620, /* 'Luv ' */
+ YCbCr = 0x59436272, /* 'YCbr' */
+ Yxy = 0x59787920, /* 'Yxy ' */
+ Rgb = 0x52474220, /* 'RGB ' */
+ Gray = 0x47524159, /* 'GRAY' */
+ Hsv = 0x48535620, /* 'HSV ' */
+ Hls = 0x484C5320, /* 'HLS ' */
+ Cmyk = 0x434D594B, /* 'CMYK' */
+ Cmy = 0x434D5920, /* 'CMY ' */
+ Color2 = 0x32434C52, /* '2CLR' */
+ Color3 = 0x33434C52, /* '3CLR' */
+ Color4 = 0x34434C52, /* '4CLR' */
+ Color5 = 0x35434C52, /* '5CLR' */
+ Color6 = 0x36434C52, /* '6CLR' */
+ Color7 = 0x37434C52, /* '7CLR' */
+ Color8 = 0x38434C52, /* '8CLR' */
+ Color9 = 0x39434C52, /* '9CLR' */
+ Color10 = 0x41434C52, /* 'ACLR' */
+ Color11 = 0x42434C52, /* 'BCLR' */
+ Color12 = 0x43434C52, /* 'CCLR' */
+ Color13 = 0x44434C52, /* 'DCLR' */
+ Color14 = 0x45434C52, /* 'ECLR' */
+ Color15 = 0x46434C52, /* 'FCLR' */
+ }
+}
Added: trunk/src/Cms/Intent.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/Intent.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,17 @@
+/*
+ * Cms.Intent.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace Cms {
+ public enum Intent {
+ Perceptual = 0,
+ RelativeColorimetric = 1,
+ Saturation = 2,
+ AbsoluteColorimetric = 3
+ }
+}
Copied: trunk/src/Cms/Profile.cs (from r3958, /trunk/src/Cms/Cms.cs)
==============================================================================
--- /trunk/src/Cms/Cms.cs (original)
+++ trunk/src/Cms/Profile.cs Wed May 21 07:15:02 2008
@@ -1,6 +1,11 @@
-//
-// A very incomplete wrapper for lcms
-//
+/*
+ * Cms.Profile.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
using System;
using System.IO;
@@ -10,440 +15,6 @@
using System.Runtime.Serialization;
namespace Cms {
- public enum Format : uint {
- Rgb8 = 262169,
- Rgba8 = 262297,
- Rgba8Planar = 266393,
- Gbr8 = 263193,
- Rgb16 = 262170,
- Rgb16Planar = 266266,
- Rgba16 = 262298,
- Rgba16se = 264436,
- Rgb16se = 264218,
- Lab8 = 655385,
- Lab16 = 655386,
- Xyz16 = 589858,
- Yxy16 = 917530
- }
-
- public enum IccColorSpace : uint {
- XYZ = 0x58595A20, /* 'XYZ ' */
- Lab = 0x4C616220, /* 'Lab ' */
- Luv = 0x4C757620, /* 'Luv ' */
- YCbCr = 0x59436272, /* 'YCbr' */
- Yxy = 0x59787920, /* 'Yxy ' */
- Rgb = 0x52474220, /* 'RGB ' */
- Gray = 0x47524159, /* 'GRAY' */
- Hsv = 0x48535620, /* 'HSV ' */
- Hls = 0x484C5320, /* 'HLS ' */
- Cmyk = 0x434D594B, /* 'CMYK' */
- Cmy = 0x434D5920, /* 'CMY ' */
- Color2 = 0x32434C52, /* '2CLR' */
- Color3 = 0x33434C52, /* '3CLR' */
- Color4 = 0x34434C52, /* '4CLR' */
- Color5 = 0x35434C52, /* '5CLR' */
- Color6 = 0x36434C52, /* '6CLR' */
- Color7 = 0x37434C52, /* '7CLR' */
- Color8 = 0x38434C52, /* '8CLR' */
- Color9 = 0x39434C52, /* '9CLR' */
- Color10 = 0x41434C52, /* 'ACLR' */
- Color11 = 0x42434C52, /* 'BCLR' */
- Color12 = 0x43434C52, /* 'CCLR' */
- Color13 = 0x44434C52, /* 'DCLR' */
- Color14 = 0x45434C52, /* 'ECLR' */
- Color15 = 0x46434C52, /* 'FCLR' */
- }
-
- public enum Intent {
- Perceptual = 0,
- RelativeColorimetric = 1,
- Saturation = 2,
- AbsoluteColorimetric = 3
- }
-
- public struct ColorCIExyY {
- public double x;
- public double y;
- public double Y;
-
- public ColorCIExyY (double x, double y, double Y)
- {
- this.x = x;
- this.y = y;
- this.Y = Y;
- }
-
- public static ColorCIExyY WhitePointFromTemperature (int temp)
- {
- double x, y;
- CctTable.GetXY (temp, out x, out y);
- return new ColorCIExyY (x, y, 1.0);
- }
-
- public static ColorCIExyY WhitePointFromTemperatureCIE (int temp)
- {
- ColorCIExyY wp;
- NativeMethods.CmsWhitePointFromTemp (temp, out wp);
- return wp;
- }
-
- 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;
- }
- }
-
- public ColorCIEXYZ ToXYZ ()
- {
- ColorCIEXYZ dest;
- NativeMethods.CmsxyY2XYZ (out dest, ref this);
-
- return dest;
- }
-
- public static ColorCIExyY D50 {
- get {
- IntPtr ptr = NativeMethods.CmsD50xyY ();
- return (ColorCIExyY) Marshal.PtrToStructure (ptr, typeof (ColorCIExyY));
- }
- }
-
- public ColorCIELab ToLab (ColorCIExyY wp)
- {
- return this.ToXYZ ().ToLab (wp);
- }
-
- public ColorCIELab ToLab (ColorCIEXYZ wp)
- {
- return this.ToXYZ ().ToLab (wp);
- }
-
- public override string ToString ()
- {
- return String.Format ("(x={0}, y={1}, Y={2})", x, y, Y);
- }
- }
-
- public struct ColorCIEXYZ {
- public double x;
- public double y;
- public double z;
-
- public ColorCIEXYZ (double x, double y, double z)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public ColorCIExyY ToxyY ()
- {
- ColorCIExyY dest;
- NativeMethods.CmsXYZ2xyY (out dest, ref this);
-
- return dest;
- }
-
- public ColorCIELab ToLab (ColorCIEXYZ wp)
- {
- ColorCIELab lab;
- NativeMethods.CmsXYZ2Lab (ref wp, out lab, ref this);
-
- return lab;
- }
-
- public static ColorCIEXYZ D50 {
- get {
- IntPtr ptr = NativeMethods.CmsD50XYZ ();
- return (ColorCIEXYZ) Marshal.PtrToStructure (ptr, typeof (ColorCIEXYZ));
- }
- }
-
- public ColorCIELab ToLab (ColorCIExyY wp)
- {
- return ToLab (wp.ToXYZ ());
- }
-
- public override string ToString ()
- {
- return String.Format ("(x={0}, y={1}, z={2})", x, y, z);
- }
-
-
- }
-
- public struct ColorCIELab {
- public double L;
- public double a;
- public double b;
-
- public ColorCIELCh ToLCh ()
- {
- ColorCIELCh lch;
- NativeMethods.CmsLab2LCh (out lch, ref this);
-
- return lch;
- }
-
- public ColorCIEXYZ ToXYZ (ColorCIEXYZ wp)
- {
- ColorCIEXYZ xyz;
- NativeMethods.CmsLab2XYZ (ref wp, out xyz, ref this);
-
- return xyz;
- }
-
- public override string ToString ()
- {
- return String.Format ("(L={0}, a={1}, b={2})", L, a, b);
- }
- }
-
- public struct ColorCIELCh {
- public double L;
- public double C;
- public double h;
-
- public ColorCIELab ToLab ()
- {
- ColorCIELab lab;
- NativeMethods.CmsLCh2Lab (out lab, ref this);
-
- return lab;
- }
- }
-
- public struct ColorCIExyYTriple {
- public ColorCIExyY Red;
- public ColorCIExyY Green;
- public ColorCIExyY Blue;
-
- public ColorCIExyYTriple (ColorCIExyY red, ColorCIExyY green, ColorCIExyY blue)
- {
- Red = red;
- Green = green;
- Blue = blue;
- }
- }
-
- public struct ColorCIEXYZTriple {
- public ColorCIEXYZ Red;
- public ColorCIEXYZ Blue;
- public ColorCIEXYZ Green;
-
- ColorCIEXYZTriple (ColorCIEXYZ red, ColorCIEXYZ green, ColorCIEXYZ blue)
- {
- Red = red;
- Blue = blue;
- Green = green;
- }
- }
-
- public class GammaTable : IDisposable {
- private HandleRef handle;
- public HandleRef Handle {
- get {
- return handle;
- }
- }
-
-// internal struct GammaTableStruct {
-// public int Count;
-// public ushort StartOfData; // ushort array Count entries long
-// }
-
- public GammaTable (int count, double gamma)
- {
- handle = new HandleRef (this, NativeMethods.CmsBuildGamma (count, gamma));
- }
-
- /*
- Does build a parametric curve based on parameters.
- Params[] does contain Gamma, a, b, c, d, e, f
-
- Type 1 :
- X = Y ^ Gamma | Gamma = Params[0]
-
- Type 2 :
- CIE 122-1966
- Y = (aX + b)^Gamma | X >= -b/a
- Y = 0 | else
- Type 3:
-
- IEC 61966-3
- Y = (aX + b)^Gamma | X <= -b/a
- Y = c | else
-
- Type 4:
- IEC 61966-2.1 (sRGB)
- Y = (aX + b)^Gamma | X >= d
- Y = cX | X < d
-
- Type 5:
-
- Y = (aX + b)^Gamma + e | X <= d
- Y = cX + f | else
-
- Giving negative values for Type does result in reversed curve.
- */
-
- // FIXME type should be an enum
- public GammaTable (int entry_count, int type, double [] values)
- {
- handle = new HandleRef (this, NativeMethods.CmsBuildParametricGamma (entry_count, type, values));
- }
-
-
- public GammaTable (ushort [] values) : this (values, 0, values.Length)
- {
- }
-
- public int Count {
- get {
- return NativeMethods.FCmsGammaTableGetCount (handle);
- }
- }
-
- public IntPtr Values {
- get {
- return NativeMethods.FCmsGammaTableGetValues (handle);
- }
- }
-
- public ushort this [int index] {
- get {
- unsafe {
- if (handle.Handle == (IntPtr)0)
- throw new Exception ();
-
- if (index < 0 || index >= Count)
- throw new ArgumentOutOfRangeException (String.Format ("index {0} outside of count {1} for {2}", index, Count, handle.Handle));
-
- ushort *data = (ushort *)Values;
- return data [index];
- }
- }
- set {
- unsafe {
- if (handle.Handle == (IntPtr)0)
- throw new Exception ();
-
- if (index < 0 || index >= Count)
- throw new ArgumentOutOfRangeException (String.Format ("index {0} outside of count {1} for handle {2}", index, Count, handle.Handle));
-
-
- ushort *data = (ushort *)Values;
- data [index] = value;
- }
- }
- }
-
- public GammaTable (ushort [] values, int start_offset, int length)
- {
-#if true
- handle = new HandleRef (this, NativeMethods.FCmsGammaTableNew (values, start_offset, length));
- //System.Console.WriteLine ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXhandle = {0}", handle.Handle);
-#else
- handle = new HandleRef (this, cmsAllocGamma (length));
- //System.Console.WriteLine ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXhandle = {0}", handle.Handle);
- for (int i = 0; i < length; i++)
- this [i] = values [start_offset + i];
-#endif
- }
-
- protected virtual void Cleanup ()
- {
- NativeMethods.CmsFreeGamma (handle);
- }
-
- public void Dispose ()
- {
- Cleanup ();
- System.GC.SuppressFinalize (this);
- }
-
- ~GammaTable ()
- {
- Cleanup ();
- }
- }
-
- public class Transform : IDisposable {
- private HandleRef handle;
- public HandleRef Handle {
- get {
- return handle;
- }
- }
-
- public Transform (Profile [] profiles,
- Format input_format,
- Format output_format,
- Intent intent, uint flags)
- {
- HandleRef [] handles = new HandleRef [profiles.Length];
- for (int i = 0; i < profiles.Length; i++) {
- handles [i] = profiles [i].Handle;
- }
-
- this.handle = new HandleRef (this, NativeMethods.CmsCreateMultiprofileTransform (handles, handles.Length,
- input_format,
- output_format,
- (int)intent, flags));
- }
-
- public Transform (Profile input, Format input_format,
- Profile output, Format output_format,
- Intent intent, uint flags)
- {
- this.handle = new HandleRef (this, NativeMethods.CmsCreateTransform (input.Handle, input_format,
- output.Handle, output_format,
- (int)intent, flags));
- }
-
- // Fixme this should probably be more type stafe
- public void Apply (IntPtr input, IntPtr output, uint size)
- {
- NativeMethods.CmsDoTransform (Handle, input, output, size);
- }
-
- public void Dispose ()
- {
- Cleanup ();
- System.GC.SuppressFinalize (this);
- }
-
- protected virtual void Cleanup ()
- {
- NativeMethods.CmsDeleteTransform (this.handle);
- }
-
- ~Transform ()
- {
- Cleanup ();
- }
-
- }
-
public class Profile : IDisposable {
static Profile srgb = new Profile (NativeMethods.CmsCreateSRGBProfile());
Added: trunk/src/Cms/Transform.cs
==============================================================================
--- (empty file)
+++ trunk/src/Cms/Transform.cs Wed May 21 07:15:02 2008
@@ -0,0 +1,73 @@
+/*
+ * Cms.Transform.cs A very incomplete wrapper for lcms
+ *
+ * Author(s):
+ * Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Cms {
+ public class Transform : IDisposable {
+ private HandleRef handle;
+ public HandleRef Handle {
+ get {
+ return handle;
+ }
+ }
+
+ public Transform (Profile [] profiles,
+ Format input_format,
+ Format output_format,
+ Intent intent, uint flags)
+ {
+ HandleRef [] handles = new HandleRef [profiles.Length];
+ for (int i = 0; i < profiles.Length; i++) {
+ handles [i] = profiles [i].Handle;
+ }
+
+ this.handle = new HandleRef (this, NativeMethods.CmsCreateMultiprofileTransform (handles, handles.Length,
+ input_format,
+ output_format,
+ (int)intent, flags));
+ }
+
+ public Transform (Profile input, Format input_format,
+ Profile output, Format output_format,
+ Intent intent, uint flags)
+ {
+ this.handle = new HandleRef (this, NativeMethods.CmsCreateTransform (input.Handle, input_format,
+ output.Handle, output_format,
+ (int)intent, flags));
+ }
+
+ // Fixme this should probably be more type stafe
+ public void Apply (IntPtr input, IntPtr output, uint size)
+ {
+ NativeMethods.CmsDoTransform (Handle, input, output, size);
+ }
+
+ public void Dispose ()
+ {
+ Cleanup ();
+ System.GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Cleanup ()
+ {
+ NativeMethods.CmsDeleteTransform (this.handle);
+ }
+
+ ~Transform ()
+ {
+ Cleanup ();
+ }
+ }
+}
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed May 21 07:15:02 2008
@@ -4,9 +4,18 @@
EXTRAFLAGS = -d:TEST_METADATA -d:BROKEN_RSVG $(NUNIT_DEFINES) $(BEAGLE_DEFINES) $(CSC_DEFINES)
CMS_CSDISTFILES = \
- $(srcdir)/Cms/Cms.cs \
$(srcdir)/Cms/CctTable.cs \
- $(srcdir)/Cms/NativeMethods.cs
+ $(srcdir)/Cms/ColorCIELab.cs \
+ $(srcdir)/Cms/ColorCIELCh.cs \
+ $(srcdir)/Cms/ColorCIExyY.cs \
+ $(srcdir)/Cms/ColorCIEXYZ.cs \
+ $(srcdir)/Cms/Format.cs \
+ $(srcdir)/Cms/GammaTable.cs \
+ $(srcdir)/Cms/IccColorSpace.cs \
+ $(srcdir)/Cms/Intent.cs \
+ $(srcdir)/Cms/NativeMethods.cs \
+ $(srcdir)/Cms/Profile.cs \
+ $(srcdir)/Cms/Transform.cs
CORE_CSDISTFILES = \
$(srcdir)/Core/Animator.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]