Example #1
0
        /// <summary>
        /// Initialize the options by searching data directories for image files
        /// </summary>
        public void InitializeOptions()
        {
            //hair front
            filesHairFront = EngineTools.GetFiles("hair_front");
            lbx_HairFront  = EngineTools.PrepWindow(filesHairFront, lbx_HairFront);

            //hair back
            filesHairBack = EngineTools.GetFiles("hair_back");
            lbx_HairBack  = EngineTools.PrepWindow(filesHairBack, lbx_HairBack);

            //head
            filesHead = EngineTools.GetFiles("head");
            lbx_Head  = EngineTools.PrepWindow(filesHead, lbx_Head);

            //eyes
            filesEyes = EngineTools.GetFiles("eye");
            lbx_Eyes  = EngineTools.PrepWindow(filesEyes, lbx_Eyes);

            //face
            filesFace = EngineTools.GetFiles("face_front");
            lbx_Face  = EngineTools.PrepWindow(filesFace, lbx_Face);

            //outfit
            filesOutfit = EngineTools.GetFiles("body_front");
            lbx_Outfit  = EngineTools.PrepWindow(filesOutfit, lbx_Outfit);
        }
Example #2
0
        private Image <Bgra, byte> AddImages(Image <Bgra, byte>[] imageArray)
        {
            if (imageArray == null || imageArray.Length == 0)
            {
                throw new Exception("wtf parameters are empty bro");
            }
            int _height = imageArray[0].Height;
            int _width  = imageArray[0].Width;

            foreach (Image <Bgra, byte> i in imageArray)
            {
                if (i.Height != _height || i.Width != _width)
                {
                    throw new Exception("Array of images are not of the same dimensions");
                }
            }
            //data cleaned

            Image <Bgra, byte> output = EngineTools.CreateTransparent(_width, _height);

            for (int x = 0; x < _width; x++)
            {
                for (int y = 0; y < _height; y++)
                {
                    Bgra          pixeldata  = new Bgra(0, 0, 0, 0);
                    List <double> alphaArray = new List <double>();
                    for (int i = 0; i < imageArray.Length; i++) //check to see if layers have anything on them at all, skip math if there is
                    {
                        alphaArray.Add(imageArray[i][y, x].Alpha);
                    }
                    if (alphaArray.Sum() <= 0.001)
                    {
                        goto SkipSum;
                    }
                    for (int i = 0; i < imageArray.Length; i++)
                    {
                        if (imageArray[i][y, x].Alpha > 0.001)
                        {
                            double a1 = imageArray[i][y, x].Alpha / 255;
                            double r1 = imageArray[i][y, x].Red;
                            double g1 = imageArray[i][y, x].Green;
                            double b1 = imageArray[i][y, x].Blue;
                            double a2 = pixeldata.Alpha / 255;
                            double r2 = pixeldata.Red;
                            double g2 = pixeldata.Green;
                            double b2 = pixeldata.Blue; //stacking value 2 over value 1

                            //additive compositing
                            pixeldata.Alpha = (a2 * (1 - a1) + a1) * 255; //x255 because scale of 0-255
                            pixeldata.Red   = r2 * a2 * (1 - a1) + r1 * a1;
                            pixeldata.Green = g2 * a2 * (1 - a1) + g1 * a1;
                            pixeldata.Blue  = b2 * a2 * (1 - a1) + b1 * a1;
                        }
                    }
SkipSum:            //cancel excecution of adding nothing to itself
                    output[y, x] = pixeldata;
                }
            }
            return(output);
        }
        /// <summary>
        /// File > Save As
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = sfd_SaveFile.ShowDialog();

            if (dr == DialogResult.OK)
            {
                EngineTools.Save(sfd_SaveFile);
            }
        }
Example #4
0
        public Form1()
        {
            theNullImage = EngineTools.CreateTransparent(300, 400);
            im_eyes      = theNullImage;
            im_face      = theNullImage;
            im_hairBack  = theNullImage;
            im_hairFront = theNullImage;
            im_head      = theNullImage;
            im_outfit    = theNullImage;
            im_bodyBack  = theNullImage;
            redraw       = true; //flag used when mass deselecting to prevent ultralag

            InitializeComponent();
            InitializeOptions();

            imbx_ImagePrimary.FunctionalMode = ImageBox.FunctionalModeOption.Minimum;
        }