Beispiel #1
0
        public bool LoadXML_palette256(XmlNode xnode)
        {
            short nColors = 0;

            foreach (XmlNode xn in xnode.ChildNodes)
            {
                if (xn.Name == "color")
                {
                    string strRGB = XMLUtils.GetXMLAttribute(xn, "rgb");
                    int    nRGB;
                    if (!Palette.ParseRGBColorValue(strRGB, out nRGB))
                    {
                        m_doc.ErrorString("Unable to parse color value '{0}' in palette '{1}'.", strRGB, Name);
                        return(false);
                    }

                    Color c = Color555.CalcColor(nRGB);
                    if (nColors < 256)
                    {
                        m_mapId2Color.Add(nColors, c);
                    }
                    nColors++;
                }
            }

            if (nColors != 256)
            {
                m_doc.ErrorString("Incorrect number of colors in background image palette");
                return(false);
            }
            return(true);
        }