Ejemplo n.º 1
0
        private Bitmap composeMakeup(xmlChunkDetails details, uint casPartType)
        {
            DateTime startTime2 = DateTime.Now;
            List <MadScience.Wrappers.ResourceKey> tempList = new List <MadScience.Wrappers.ResourceKey>();

            tempList.Add(new MadScience.Wrappers.ResourceKey(details.faceOverlay));
            tempList.Add(new MadScience.Wrappers.ResourceKey(details.Mask));

            List <Stream> textures  = KeyUtils.findKey(tempList, 2);
            DateTime      stopTime2 = DateTime.Now;
            TimeSpan      duration2 = stopTime2 - startTime2;

            Console.WriteLine("Key search time: " + duration2.TotalMilliseconds);

            if (MadScience.Patterns.isEmptyTexture(details.Multiplier))
            {
                textures[0] = null;
            }

            DateTime startTime = DateTime.Now;
            Bitmap   output    = null;

            if (String.IsNullOrEmpty(details.TintColor))
            {
                if (MadScience.Patterns.isEmptyMask(details.Mask) && details.tint.A.enabled != null && details.tint.A.enabled.ToLower() == "true")
                {
                    output = PatternProcessor.ProcessMakeupTexture(textures, MadScience.Colours.convertColour(details.tint.A.color));
                }
                else if (MadScience.Patterns.isEmptyMask(details.Mask) || String.IsNullOrEmpty(details.Mask))
                {
                    //                    output = new Bitmap(16, 16);
                    output = PatternProcessor.ProcessMakeupTexture(textures, Color.White);
                }
                else
                {
                    output = PatternProcessor.ProcessMakeupTexture(textures,
                                                                   details.tint.A,
                                                                   details.tint.B,
                                                                   details.tint.C,
                                                                   details.tint.D);
                }
            }
            else if (details.TintColor != null)
            {
                output = PatternProcessor.ProcessMakeupTexture(textures, MadScience.Colours.convertColour(details.TintColor));
            }

            DateTime stopTime = DateTime.Now;
            TimeSpan duration = stopTime - startTime;

            Console.WriteLine("Total Makeup Texture generation time: " + duration.TotalMilliseconds);
            return(output);
        }
Ejemplo n.º 2
0
        private Bitmap composeHair(xmlChunkDetails details)
        {
            Bitmap patterns = composeMultiplier(details);

            List <MadScience.Wrappers.ResourceKey> tempList = new List <MadScience.Wrappers.ResourceKey>();

            tempList.Add(new MadScience.Wrappers.ResourceKey(details.DiffuseMap));
            tempList.Add(new MadScience.Wrappers.ResourceKey(details.ControlMap));

            List <Stream> textures = KeyUtils.findKey(tempList, 2);

            if (MadScience.Patterns.isEmptyTexture(details.DiffuseMap))
            {
                textures[0] = null;
            }

            DateTime startTime = DateTime.Now;
            Bitmap   hair      = PatternProcessor.ProcessHairTexture(textures,
                                                                     MadScience.Colours.convertColour(details.hair.DiffuseColor),
                                                                     MadScience.Colours.convertColour(details.hair.RootColor),
                                                                     MadScience.Colours.convertColour(details.hair.HighlightColor),
                                                                     MadScience.Colours.convertColour(details.hair.TipColor));

            if (patterns.Width < hair.Width)
            {
                using (Graphics g = Graphics.FromImage(hair))
                {
                    g.DrawImage(patterns, 0, 0, patterns.Width, patterns.Height);
                }
                return(hair);
            }
            else
            {
                using (Graphics g = Graphics.FromImage(patterns))
                {
                    g.DrawImage(hair, 0, 0, patterns.Width, patterns.Height);
                }
                return(patterns);
            }
        }
Ejemplo n.º 3
0
        private Bitmap composeMultiplier(xmlChunkDetails details)
        {
            Bitmap[] myPatterns = new Bitmap[1];
            DateTime startTime2 = DateTime.Now;
            List <MadScience.Wrappers.ResourceKey> tempList = new List <MadScience.Wrappers.ResourceKey>();

            tempList.Add(new MadScience.Wrappers.ResourceKey(details.Multiplier));
            tempList.Add(new MadScience.Wrappers.ResourceKey(details.Mask));

            List <Stream> textures = KeyUtils.findKey(tempList, 2);

            if (details.pattern[3].Enabled.ToLower() == "true" && details.filename == "CasRgbaMask")
            {
                myPatterns = new Bitmap[4];
            }
            else if (details.pattern[2].Enabled.ToLower() == "true")
            {
                myPatterns = new Bitmap[3];
            }
            else if (details.pattern[1].Enabled.ToLower() == "true")
            {
                myPatterns = new Bitmap[2];
            }

            PointF[] tilings = new PointF[myPatterns.Length];

            for (int i = 0; i < myPatterns.Length; i++)
            {
                if (details.pattern[i].Enabled.ToLower() == "true")
                {
                    myPatterns[i] = (Bitmap)Patterns.makePatternThumb(details.pattern[i]);;
                    tilings[i]    = new PointF(1f, 1f);
                    if (details.pattern[i].Tiling != null)
                    {
                        String[] s = details.pattern[i].Tiling.Split(',');
                        if (s.Length == 2)
                        {
                            try
                            {
                                tilings[i].X = Convert.ToSingle(s[0], CultureInfo.InvariantCulture);
                                tilings[i].Y = Convert.ToSingle(s[1], CultureInfo.InvariantCulture);
                            }
                            catch (Exception)
                            {
                                tilings[i] = new PointF(1f, 1f);
                            }
                        }
                    }
                }
            }

            DateTime stopTime2 = DateTime.Now;
            TimeSpan duration2 = stopTime2 - startTime2;

            Console.WriteLine("Key search time: " + duration2.TotalMilliseconds);

            DateTime startTime = DateTime.Now;

            if (MadScience.Patterns.isEmptyTexture(details.Multiplier))
            {
                textures[0] = null;
            }

            Bitmap output;

            if (MadScience.Patterns.isEmptyMask(details.Mask))
            {
                output = PatternProcessor.ProcessSingleChannelTexture(
                    textures,
                    myPatterns[0],
                    tilings[0]);
            }
            else
            {
                output = PatternProcessor.ProcessClothingTexture(
                    textures,
                    myPatterns,
                    tilings);
            }

            DateTime stopTime = DateTime.Now;
            TimeSpan duration = stopTime - startTime;

            Console.WriteLine("Total Multiplier Texture generation time: " + duration.TotalMilliseconds);
            return(output);
        }