/// <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"); }
private double[] createMatrix(RestrictedICCProfile ricc, int[] maxValues) { // Coefficients from the input linear to PCS matrix double dfPCS00 = ICCXYZType.XYZToDouble(ricc.colorant[RED].x); double dfPCS01 = ICCXYZType.XYZToDouble(ricc.colorant[GREEN].x); double dfPCS02 = ICCXYZType.XYZToDouble(ricc.colorant[BLUE].x); double dfPCS10 = ICCXYZType.XYZToDouble(ricc.colorant[RED].y); double dfPCS11 = ICCXYZType.XYZToDouble(ricc.colorant[GREEN].y); double dfPCS12 = ICCXYZType.XYZToDouble(ricc.colorant[BLUE].y); double dfPCS20 = ICCXYZType.XYZToDouble(ricc.colorant[RED].z); double dfPCS21 = ICCXYZType.XYZToDouble(ricc.colorant[GREEN].z); double dfPCS22 = ICCXYZType.XYZToDouble(ricc.colorant[BLUE].z); double[] matrix = new double[9]; matrix[M00] = maxValues[0] * (SRGB00 * dfPCS00 + SRGB01 * dfPCS10 + SRGB02 * dfPCS20); matrix[M01] = maxValues[0] * (SRGB00 * dfPCS01 + SRGB01 * dfPCS11 + SRGB02 * dfPCS21); matrix[M02] = maxValues[0] * (SRGB00 * dfPCS02 + SRGB01 * dfPCS12 + SRGB02 * dfPCS22); matrix[M10] = maxValues[1] * (SRGB10 * dfPCS00 + SRGB11 * dfPCS10 + SRGB12 * dfPCS20); matrix[M11] = maxValues[1] * (SRGB10 * dfPCS01 + SRGB11 * dfPCS11 + SRGB12 * dfPCS21); matrix[M12] = maxValues[1] * (SRGB10 * dfPCS02 + SRGB11 * dfPCS12 + SRGB12 * dfPCS22); matrix[M20] = maxValues[2] * (SRGB20 * dfPCS00 + SRGB21 * dfPCS10 + SRGB22 * dfPCS20); matrix[M21] = maxValues[2] * (SRGB20 * dfPCS01 + SRGB21 * dfPCS11 + SRGB22 * dfPCS21); matrix[M22] = maxValues[2] * (SRGB20 * dfPCS02 + SRGB21 * dfPCS12 + SRGB22 * dfPCS22); return(matrix); }
/// <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); }
/// <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 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) { }