Ejemplo n.º 1
0
		/// <summary> Factory method for getting a 32 bit lut from a given curve.</summary>
		/// <param name="curve"> the data
		/// </param>
		/// <param name="dwNumInput">the size of the lut 
		/// </param>
		/// <param name="dwMaxOutput">max output value of the lut
		/// </param>
		/// <returns> the lookup table
		/// </returns>
		public static LookUpTable32 createInstance(ICCCurveType curve, int dwNumInput, int dwMaxOutput)
		{
			if (curve.count == 1)
				return new LookUpTable32Gamma(curve, dwNumInput, dwMaxOutput);
			else
				return new LookUpTable32Interp(curve, dwNumInput, dwMaxOutput);
		}
Ejemplo n.º 2
0
        /// <summary> Construct the lut from the curve data</summary>
        /// <oaram>   curve the data </oaram>
        /// <oaram>   dwNumInput the lut size </oaram>
        public LookUpTableFPInterp(ICCCurveType curve, int dwNumInput) : base(curve, dwNumInput)
        {
            int    dwLowIndex, dwHighIndex; // Indices of interpolation points
            double dfLowIndex, dfHighIndex; // FP indices of interpolation points
            double dfTargetIndex;           // Target index into interpolation table
            double dfRatio;                 // Ratio of LUT input points to curve values
            double dfLow, dfHigh;           // Interpolation values

            dfRatio = (double)(curve.nEntries - 1) / (double)(dwNumInput - 1);

            for (int i = 0; i < dwNumInput; i++)
            {
                dfTargetIndex = (double)i * dfRatio;
                dfLowIndex    = System.Math.Floor(dfTargetIndex);
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                dwLowIndex  = (int)dfLowIndex;
                dfHighIndex = System.Math.Ceiling(dfTargetIndex);
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                dwHighIndex = (int)dfHighIndex;
                if (dwLowIndex == dwHighIndex)
                {
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    lut[i] = (float)ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
                }
                else
                {
                    dfLow  = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
                    dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    lut[i] = (float)(dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex));
                }
            }
        }
Ejemplo n.º 3
0
		/// <summary> Construct the lut from the curve data</summary>
		/// <oaram>   curve the data </oaram>
		/// <oaram>   dwNumInput the lut size </oaram>
		/// <oaram>   dwMaxOutput the lut max value </oaram>
		public LookUpTable32Interp(ICCCurveType curve, int dwNumInput, int dwMaxOutput):base(curve, dwNumInput, dwMaxOutput)
		{
			
			int dwLowIndex, dwHighIndex; // Indices of interpolation points
			double dfLowIndex, dfHighIndex; // FP indices of interpolation points
			double dfTargetIndex; // Target index into interpolation table
			double dfRatio; // Ratio of LUT input points to curve values
			double dfLow, dfHigh; // Interpolation values
			double dfOut; // Output LUT value
			
			dfRatio = (double) (curve.count - 1) / (double) (dwNumInput - 1);
			
			for (int i = 0; i < dwNumInput; i++)
			{
				dfTargetIndex = (double) i * dfRatio;
				dfLowIndex = System.Math.Floor(dfTargetIndex);
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				dwLowIndex = (int) dfLowIndex;
				dfHighIndex = System.Math.Ceiling(dfTargetIndex);
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				dwHighIndex = (int) dfHighIndex;
				
				if (dwLowIndex == dwHighIndex)
					dfOut = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
				else
				{
					dfLow = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
					dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
					dfOut = dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex);
				}
				
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				lut[i] = (int) System.Math.Floor(dfOut * dwMaxOutput + 0.5);
			}
		}
Ejemplo n.º 4
0
        /// <summary> Parse this ICCProfile into a RestrictedICCProfile
        /// which is appropriate to the data in this profile.
        /// Either a MonochromeInputRestrictedProfile or
        /// MatrixBasedRestrictedProfile is returned
        /// </summary>
        /// <returns> RestrictedICCProfile
        /// </returns>
        /// <exception cref="ICCProfileInvalidException">no curve data
        /// </exception>
        public virtual RestrictedICCProfile parse()
        {
            // The next step is to determine which Restricted ICC type is used by this profile.
            // Unfortunately, the only way to do this is to look through the tag table for
            // the tags required by the two types.

            // First look for the gray TRC tag. If the profile is indeed an input profile, and this
            // tag exists, then the profile is a Monochrome Input profile

            ICCCurveType grayTag = (ICCCurveType)tags[(System.Int32)kdwGrayTRCTag];

            if (grayTag != null)
            {
                return(RestrictedICCProfile.createInstance(grayTag));
            }

            // If it wasn't a Monochrome Input profile, look for the Red Colorant tag. If that
            // tag is found and the profile is indeed an input profile, then this profile is
            // a Three-Component Matrix-Based Input profile

            ICCCurveType rTRCTag = (ICCCurveType)tags[(System.Int32)kdwRedTRCTag];


            if (rTRCTag != null)
            {
                ICCCurveType gTRCTag      = (ICCCurveType)tags[(System.Int32)kdwGreenTRCTag];
                ICCCurveType bTRCTag      = (ICCCurveType)tags[(System.Int32)kdwBlueTRCTag];
                ICCXYZType   rColorantTag = (ICCXYZType)tags[(System.Int32)kdwRedColorantTag];
                ICCXYZType   gColorantTag = (ICCXYZType)tags[(System.Int32)kdwGreenColorantTag];
                ICCXYZType   bColorantTag = (ICCXYZType)tags[(System.Int32)kdwBlueColorantTag];
                return(RestrictedICCProfile.createInstance(rTRCTag, gTRCTag, bTRCTag, rColorantTag, gColorantTag, bColorantTag));
            }

            throw new ICCProfileInvalidException("curve data not found in profile");
        }
Ejemplo n.º 5
0
		/// <summary> Factory method for getting a lut from a given curve.</summary>
		/// <param name="curve"> the data
		/// </param>
		/// <param name="dwNumInput">the size of the lut 
		/// </param>
		/// <returns> the lookup table
		/// </returns>
		
		public static LookUpTableFP createInstance(ICCCurveType curve, int dwNumInput)
		{
			
			if (curve.nEntries == 1)
				return new LookUpTableFPGamma(curve, dwNumInput);
			else
				return new LookUpTableFPInterp(curve, dwNumInput);
		}
Ejemplo n.º 6
0
		/* Construct the lut 
		*   @param curve data 
		*   @param dwNumInput size of lut 
		*   @param dwMaxOutput max value of lut   
		*/
		public LookUpTable16Gamma(ICCCurveType curve, int dwNumInput, int dwMaxOutput):base(curve, dwNumInput, dwMaxOutput)
		{
			double dfE = ICCCurveType.CurveGammaToDouble(curve.entry(0)); // Gamma exponent for inverse transformation
			for (int i = 0; i < dwNumInput; i++)
			{
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
				lut[i] = (short) System.Math.Floor(System.Math.Pow((double) i / (dwNumInput - 1), dfE) * dwMaxOutput + 0.5);
			}
		}
        /* Construct the lut
         *   @param curve data
         *   @param dwNumInput size of lut
         *   @param dwMaxOutput max value of lut
         */
        public LookUpTable16Gamma(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput, dwMaxOutput)
        {
            double dfE = ICCCurveType.CurveGammaToDouble(curve.entry(0)); // Gamma exponent for inverse transformation

            for (int i = 0; i < dwNumInput; i++)
            {
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                lut[i] = (short)System.Math.Floor(System.Math.Pow((double)i / (dwNumInput - 1), dfE) * dwMaxOutput + 0.5);
            }
        }
Ejemplo n.º 8
0
        /// <summary> Factory method for getting a lut from a given curve.</summary>
        /// <param name="curve"> the data
        /// </param>
        /// <param name="dwNumInput">the size of the lut
        /// </param>
        /// <returns> the lookup table
        /// </returns>

        public static LookUpTableFP createInstance(ICCCurveType curve, int dwNumInput)
        {
            if (curve.nEntries == 1)
            {
                return(new LookUpTableFPGamma(curve, dwNumInput));
            }
            else
            {
                return(new LookUpTableFPInterp(curve, dwNumInput));
            }
        }
Ejemplo n.º 9
0
 /// <summary> Factory method for getting a 32 bit lut from a given curve.</summary>
 /// <param name="curve"> the data
 /// </param>
 /// <param name="dwNumInput">the size of the lut
 /// </param>
 /// <param name="dwMaxOutput">max output value of the lut
 /// </param>
 /// <returns> the lookup table
 /// </returns>
 public static LookUpTable32 createInstance(ICCCurveType curve, int dwNumInput, int dwMaxOutput)
 {
     if (curve.count == 1)
     {
         return(new LookUpTable32Gamma(curve, dwNumInput, dwMaxOutput));
     }
     else
     {
         return(new LookUpTable32Interp(curve, dwNumInput, dwMaxOutput));
     }
 }
Ejemplo n.º 10
0
        /// <summary> Construct the common state of all 3 component RestrictedICCProfiles
        ///
        /// </summary>
        /// <param name="rcurve">red curve
        /// </param>
        /// <param name="gcurve">green curve
        /// </param>
        /// <param name="bcurve">blue curve
        /// </param>
        /// <param name="rcolorant">red colorant
        /// </param>
        /// <param name="gcolorant">green colorant
        /// </param>
        /// <param name="bcolorant">blue colorant
        /// </param>
        protected internal RestrictedICCProfile(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant)
        {
            trc      = new ICCCurveType[3];
            colorant = new ICCXYZType[3];

            trc[RED]   = rcurve;
            trc[GREEN] = gcurve;
            trc[BLUE]  = bcurve;

            colorant[RED]   = rcolorant;
            colorant[GREEN] = gcolorant;
            colorant[BLUE]  = bcolorant;
        }
		/// <summary> Construct a 3 component RestrictedICCProfile</summary>
		/// <param name="rcurve">Red TRC curve
		/// </param>
		/// <param name="gcurve">Green TRC curve
		/// </param>
		/// <param name="bcurve">Blue TRC curve
		/// </param>
		/// <param name="rcolorant">Red colorant
		/// </param>
		/// <param name="gcolorant">Green colorant
		/// </param>
		/// <param name="bcolorant">Blue colorant
		/// </param>
		protected internal MatrixBasedRestrictedProfile(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant):base(rcurve, gcurve, bcurve, rcolorant, gcolorant, bcolorant)
		{
		}
		/// <summary> Factory method which returns a 3 component RestrictedICCProfile</summary>
		/// <param name="rcurve">Red TRC curve
		/// </param>
		/// <param name="gcurve">Green TRC curve
		/// </param>
		/// <param name="bcurve">Blue TRC curve
		/// </param>
		/// <param name="rcolorant">Red colorant
		/// </param>
		/// <param name="gcolorant">Green colorant
		/// </param>
		/// <param name="bcolorant">Blue colorant
		/// </param>
		/// <returns> the RestrictedICCProfile
		/// </returns>
		public static new RestrictedICCProfile createInstance(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant)
		{
			return new MatrixBasedRestrictedProfile(rcurve, gcurve, bcurve, rcolorant, gcolorant, bcolorant);
		}
Ejemplo n.º 13
0
 /// <summary> For subclass usage.</summary>
 /// <param name="curve">The curve data
 /// </param>
 /// <param name="dwNumInput">Number of values in created lut
 /// </param>
 protected internal LookUpTable(ICCCurveType curve, int dwNumInput)
 {
     this.curve      = curve;
     this.dwNumInput = dwNumInput;
 }
Ejemplo n.º 14
0
 /// <summary> Construct the common state of all gray RestrictedICCProfiles</summary>
 /// <param name="gcurve">curve data
 /// </param>
 protected internal RestrictedICCProfile(ICCCurveType gcurve)
 {
     trc       = new ICCCurveType[1];
     colorant  = null;
     trc[GRAY] = gcurve;
 }
Ejemplo n.º 15
0
 /// <summary> Factory method for creating a RestrictedICCProfile from
 /// gray curve data.
 /// </summary>
 /// <param name="gcurve">gray curve
 /// </param>
 /// <returns> MonochromeInputRestrictedProfile
 /// </returns>
 public static RestrictedICCProfile createInstance(ICCCurveType gcurve)
 {
     return(MonochromeInputRestrictedProfile.createInstance(gcurve));
 }
Ejemplo n.º 16
0
 /// <summary> Factory method for creating a RestrictedICCProfile from
 /// 3 component curve and colorant data.
 /// </summary>
 /// <param name="rcurve">red curve
 /// </param>
 /// <param name="gcurve">green curve
 /// </param>
 /// <param name="bcurve">blue curve
 /// </param>
 /// <param name="rcolorant">red colorant
 /// </param>
 /// <param name="gcolorant">green colorant
 /// </param>
 /// <param name="bcolorant">blue colorant
 /// </param>
 /// <returns> MatrixBasedRestrictedProfile
 /// </returns>
 public static RestrictedICCProfile createInstance(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant)
 {
     return(MatrixBasedRestrictedProfile.createInstance(rcurve, gcurve, bcurve, rcolorant, gcolorant, bcolorant));
 }
		/// <summary> Construct a 1 component RestrictedICCProfile</summary>
		/// <param name="c">Gray TRC curve
		/// </param>
		private MonochromeInputRestrictedProfile(ICCCurveType c):base(c)
		{
		}
Ejemplo n.º 18
0
		/// <summary> Construct the common state of all gray RestrictedICCProfiles</summary>
		/// <param name="gcurve">curve data
		/// </param>
		protected internal RestrictedICCProfile(ICCCurveType gcurve)
		{
			trc = new ICCCurveType[1];
			colorant = null;
			trc[GRAY] = gcurve;
		}
Ejemplo n.º 19
0
		/// <summary> Factory method for creating a RestrictedICCProfile from 
		/// gray curve data.
		/// </summary>
		/// <param name="gcurve">gray curve
		/// </param>
		/// <returns> MonochromeInputRestrictedProfile
		/// </returns>
		public static RestrictedICCProfile createInstance(ICCCurveType gcurve)
		{
			return MonochromeInputRestrictedProfile.createInstance(gcurve);
		}
Ejemplo n.º 20
0
 /// <summary> Construct a 1 component RestrictedICCProfile</summary>
 /// <param name="c">Gray TRC curve
 /// </param>
 private MonochromeInputRestrictedProfile(ICCCurveType c) : base(c)
 {
 }
 /// <summary> Construct a 3 component RestrictedICCProfile</summary>
 /// <param name="rcurve">Red TRC curve
 /// </param>
 /// <param name="gcurve">Green TRC curve
 /// </param>
 /// <param name="bcurve">Blue TRC curve
 /// </param>
 /// <param name="rcolorant">Red colorant
 /// </param>
 /// <param name="gcolorant">Green colorant
 /// </param>
 /// <param name="bcolorant">Blue colorant
 /// </param>
 protected internal MatrixBasedRestrictedProfile(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant) : base(rcurve, gcurve, bcurve, rcolorant, gcolorant, bcolorant)
 {
 }
Ejemplo n.º 22
0
		/// <summary> Construct a 16 bit lut from a given curve.</summary>
		/// <param name="curve">the data
		/// </param>
		/// <param name="dwNumInput">the size of the lut t lut.
		/// </param>
		/// <param name="dwMaxOutput">max output value of the lut
		/// </param>
		protected internal LookUpTable32(ICCCurveType curve, int dwNumInput, int dwMaxOutput):base(curve, dwNumInput)
		{
			this.dwMaxOutput = dwMaxOutput;
			lut = new int[dwNumInput];
		}
Ejemplo n.º 23
0
 /// <summary> Construct an empty lut</summary>
 /// <param name="dwNumInput">the size of the lut t lut.
 /// </param>
 /// <param name="dwMaxOutput">max output value of the lut
 /// </param>
 protected internal LookUpTableFP(ICCCurveType curve, int dwNumInput) : base(curve, dwNumInput)
 {
     lut = new float[dwNumInput];
 }
Ejemplo n.º 24
0
		/// <summary> For subclass usage.</summary>
		/// <param name="curve">The curve data  
		/// </param>
		/// <param name="dwNumInput">Number of values in created lut
		/// </param>
		protected internal LookUpTable(ICCCurveType curve, int dwNumInput)
		{
			this.curve = curve;
			this.dwNumInput = dwNumInput;
		}
Ejemplo n.º 25
0
 /// <summary> Construct a 16 bit lut from a given curve.</summary>
 /// <param name="curve">the data
 /// </param>
 /// <param name="dwNumInput">the size of the lut t lut.
 /// </param>
 /// <param name="dwMaxOutput">max output value of the lut
 /// </param>
 protected internal LookUpTable32(ICCCurveType curve, int dwNumInput, int dwMaxOutput) : base(curve, dwNumInput)
 {
     this.dwMaxOutput = dwMaxOutput;
     lut = new int[dwNumInput];
 }
Ejemplo n.º 26
0
		/// <summary> Construct an empty lut</summary>
		/// <param name="dwNumInput">the size of the lut t lut.
		/// </param>
		/// <param name="dwMaxOutput">max output value of the lut
		/// </param>
		protected internal LookUpTableFP(ICCCurveType curve, int dwNumInput):base(curve, dwNumInput)
		{
			lut = new float[dwNumInput];
		}
		/// <summary> Factory method which returns a 1 component RestrictedICCProfile</summary>
		/// <param name="c">Gray TRC curve
		/// </param>
		/// <returns> the RestrictedICCProfile
		/// </returns>
		public static new RestrictedICCProfile createInstance(ICCCurveType c)
		{
			return new MonochromeInputRestrictedProfile(c);
		}
Ejemplo n.º 28
0
		/// <summary> Construct the common state of all 3 component RestrictedICCProfiles
		/// 
		/// </summary>
		/// <param name="rcurve">red curve
		/// </param>
		/// <param name="gcurve">green curve
		/// </param>
		/// <param name="bcurve">blue curve
		/// </param>
		/// <param name="rcolorant">red colorant
		/// </param>
		/// <param name="gcolorant">green colorant
		/// </param>
		/// <param name="bcolorant">blue colorant
		/// </param>
		protected internal RestrictedICCProfile(ICCCurveType rcurve, ICCCurveType gcurve, ICCCurveType bcurve, ICCXYZType rcolorant, ICCXYZType gcolorant, ICCXYZType bcolorant)
		{
			trc = new ICCCurveType[3];
			colorant = new ICCXYZType[3];
			
			trc[RED] = rcurve;
			trc[GREEN] = gcurve;
			trc[BLUE] = bcurve;
			
			colorant[RED] = rcolorant;
			colorant[GREEN] = gcolorant;
			colorant[BLUE] = bcolorant;
		}
Ejemplo n.º 29
0
 /// <summary> Factory method which returns a 1 component RestrictedICCProfile</summary>
 /// <param name="c">Gray TRC curve
 /// </param>
 /// <returns> the RestrictedICCProfile
 /// </returns>
 public static new RestrictedICCProfile createInstance(ICCCurveType c)
 {
     return(new MonochromeInputRestrictedProfile(c));
 }