0
                        
                    
                    دخیره عکس ها با سی شارپ
سلام دوستان ، من قطعه کدی رو نوشتم که از هر 10 ثانیه یه عکس از صفحه ی دسکتاپ می گیره ولی مشکل این جاست که از 10 ثانیه ی دوم عکسی که تو 10 ثانیه ی اول گرفته رو حذف میکنه و به جاش یه عکس جدید می زاره ، می خوام اسم عکسا در هر بار که عکس میگیره عوض شه ، ممنونم اگه کمکم کنید
        private void timer1_Tick(object sender, EventArgs e)
        {
            {
                Graphics grff;
                Bitmap pho = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppPArgb);
                grff = Graphics.FromImage(pho);
                grff.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
                pho.Save(@"D:\p" + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }
                        1 پاسخ
                                    
                                    1
                                    
                                    
                                
                                باید یه متغیر بزاری کانتر بشه و هر بار یکی بهش اضافه بشه و اسم فایل عکس بعدی با قبلی متفاوت بشه تا اوررایت نکنه
private Int32 pictureCount = 0;
    public Form1()
    {
        timer1.Tick += new EventHandler(this.timer1_Tick);
        timer1.Interval = (100) * (50);
        timer1.Enabled = true;
        timer1.Start();
    }
    private void timer1_Tick(object sender, EventArgs e)
    {
        /* Screen capture logic here */
        sc.pictureBox1.Image.Save(pictureCount.ToString() + ".jpg", ImageFormat.Jpeg);
        pictureCount++;
    }