Esempio n. 1
0
    public static String print_color_value(string str, TET tet, int doc, int colorid)
    {
        int    colorinfo;
        String csname;                  /* color space name */
        int    i;

        /* We handle only the fill color, but ignore the stroke color.
         * The stroke color can be retrieved analogously with the
         * keyword "stroke".
         */
        colorinfo = tet.get_color_info(doc, colorid, "usage=fill");
        if (tet.colorspaceid == -1 && tet.patternid == -1)
        {
            str = str + String.Format(" (not filled)");
            return(str);
        }

        str = str + String.Format(" (");

        if (tet.patternid != -1)
        {
            int patterntype =
                (int)tet.pcos_get_number(doc, "patterns[" + tet.patternid + "]/PatternType");

            if (patterntype == 1)       /* Tiling pattern */
            {
                int painttype =
                    (int)tet.pcos_get_number(doc, "patterns[" + tet.patternid + "]/PaintType");
                if (painttype == 1)
                {
                    str = str + String.Format("colored Pattern)");
                    return(str);
                }
                else if (painttype == 2)
                {
                    str = str + String.Format("uncolored Pattern, base color: ");
                    /* FALLTHROUGH to colorspaceid output */
                }
            }
            else if (patterntype == 2)  /* Shading pattern */
            {
                int shadingtype =
                    (int)tet.pcos_get_number(doc,
                                             "patterns[" + tet.patternid + "]/Shading/ShadingType");

                str = str + String.Format("shading Pattern, ShadingType={0})", shadingtype);
                return(str);
            }
        }

        csname = tet.pcos_get_string(doc, "colorspaces[" + tet.colorspaceid + "]/name");

        str = str + String.Format("{0}", csname);

        /* Emit more details depending on the colorspace type */
        if (csname.Equals("ICCBased"))
        {
            int    iccprofileid;
            String profilename;
            String profilecs;
            String errormessage;

            iccprofileid = (int)tet.pcos_get_number(doc,
                                                    "colorspaces[" + tet.colorspaceid + "]/iccprofileid");

            errormessage = tet.pcos_get_string(doc,
                                               "iccprofiles[" + iccprofileid + "]/errormessage");

            /* Check whether the embedded profile is damaged */
            if (errormessage.Equals(""))
            {
                str = str + String.Format(" ({0})", errormessage);
            }
            else
            {
                profilename =
                    tet.pcos_get_string(doc,
                                        "iccprofiles[" + iccprofileid + "]/profilename");
                str = str + String.Format(" '{0}'", profilename);

                profilecs = tet.pcos_get_string(doc,
                                                "iccprofiles[" + iccprofileid + "]/profilecs");
                str = str + String.Format(" '{0}'", profilecs);
            }
        }
        else if (csname.Equals("Separation"))
        {
            String colorantname =
                tet.pcos_get_string(doc, "colorspaces[" + tet.colorspaceid + "]/colorantname");
            str = str + String.Format(" '{0}'", colorantname);
        }
        else if (csname.Equals("DeviceN"))
        {
            str = str + String.Format(" ");

            for (i = 0; i < tet.components.Length; i++)
            {
                String colorantname =
                    tet.pcos_get_string(doc,
                                        "colorspaces[" + tet.colorspaceid + "]/colorantnames[" + i + "]");

                str = str + String.Format("{0}", colorantname);

                if (i != tet.components.Length - 1)
                {
                    str = str + String.Format("/");
                }
            }
        }
        else if (csname.Equals("Indexed"))
        {
            int baseid =
                (int)tet.pcos_get_number(doc, "colorspaces[" + tet.colorspaceid + "]/baseid");

            csname = tet.pcos_get_string(doc, "colorspaces[" + baseid + "]/name");

            str = str + String.Format(" {0}", csname);
        }

        str = str + String.Format(" ");
        for (i = 0; i < tet.components.Length; i++)
        {
            str = str + String.Format("{0}", tet.components[i]);

            if (i != tet.components.Length - 1)
            {
                str = str + String.Format("/");
            }
        }
        str = str + String.Format(")");
        return(str);
    }