Exemplo n.º 1
0
        private void methodotherthread()
        {
            int   w         = curimg.Height;
            int   h         = curimg.Width;
            Image imgrnd    = new Bitmap(w, h);
            var   graphics2 = Graphics.FromImage(imgrnd);
            int   w1        = w / splitcount;
            int   h1        = h / splitcount;

            int[] rndidx  = CropJoin.getrandomnumber(splitcount * splitcount - 1, splitcount * splitcount);
            int   loopcnt = 0;

            foreach (int ind in rndidx)
            {
                int i = ind / splitcount;
                int j = ind % splitcount;
                graphics2.DrawImage(imgarr[ind], new Rectangle(i * h1, j * w1, h1, w1), new Rectangle(0, 0, h1, w1), GraphicsUnit.Pixel);
                setpic(imgrnd);
                if (loopcnt > splitcount * splitcount / 10)
                {
                    Thread.Sleep(sp);
                }
                loopcnt++;
            }
            graphics2.Dispose();
        }
Exemplo n.º 2
0
        private void methodotherthread()
        {
            //all processing here and call imagereload from here. ....
            string nmbrfile = Path.Combine(Directory.GetCurrentDirectory(), "numbers.jpg");

            Image[] numarr = CropJoin.splitimg(nmbrfile, 10, 10);
            gridn = int.Parse(textBox1.Text);
            int[] index = CropJoin.getrandomnumber(maximgcount / 2 - 1, gridn * gridn / 2);
            int   delay = 1;

            try
            {
                delay = int.Parse(textBox3.Text);
            }
            catch (Exception ex)
            {
            }
            //Debug.Print("index: " + string.Join(",", index));

            selectedimg = new Image[gridn * gridn];
            imginput    = CropJoin.creategrid(pxsz, pxsz, gridn, gridn);
            for (int ii = 0; ii < selectedimg.Count(); ii++)
            //foreach (Image oneimg in selectedimg)
            {
                //imgadd = Image.FromFile(one);
                CropJoin.addimg(imginput, numarr[ii], ii, pxsz, pxsz, gridn, gridn);
            }
            pictureBox1.Image = imginput;
            Thread.Sleep(2000);
            //int[] x = new int[10];
            for (int ii = 0; ii < index.Count(); ii++)
            {
                selectedimg[2 * ii]     = allimgs[2 * index[ii]];
                selectedimg[2 * ii + 1] = allimgs[2 * index[ii] + 1];
                //Debug.Print(String.Format("selected img : {0},{1} from: {2},{3}", 2 * ii, (2 * ii + 1), index[ii], index[ii] + 1));
            }
            CropJoin.shuffle(selectedimg);
            int[] rndidx;
            if (checkBox1.Checked == true)
            {
                rndidx = CropJoin.getrandomnumber(selectedimg.Count() - 1, selectedimg.Count());
            }
            else
            {
                rndidx = Enumerable.Range(0, selectedimg.Count()).ToArray();
            }
            //Debug.Print(string.Join(",", x));
            //for (int ii = 0; ii < selectedimg.Count(); ii++)
            foreach (int ii in rndidx)
            //foreach (Image oneimg in selectedimg)
            {
                Image imageinclone = (Image)imginput.Clone();
                //imgadd = Image.FromFile(one);
                CropJoin.addimg(imageinclone, selectedimg[ii], ii, pxsz, pxsz, gridn, gridn);
                pictureBox1.Image = imageinclone;
                Thread.Sleep(1000 * delay);
            }
            pictureBox1.Image = imginput;
        }