PDA

View Full Version : مقاله: تغییر سایز اسکرین شات و ذخیره به صورت فایل



میلاد قاضی پور
یک شنبه 28 آبان 1391, 20:13 عصر
میخواستم یه برنامه ی مشاهده ی کارهای کاربران در شبکه بنویسم که به دلیل بالا رفتن حجم فایلهای اسکرینشات مجبور بودم به محض اینکار قبل از ذخیره اونهارو کوچیک تر کنم. متأسفانه به خاطر نکات خیلی ریز ساعتها وقتم تلف شد . اما وقتی موفق شدم تصمیم گرفتم کدشو براتون بذارم چون موقع سرچ پروژه آماده ای پیدا نکردم .


int number = 0;
private void timer1_Tick(object sender, EventArgs e)
{
number += 1;

Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphicsFromBmp = Graphics.FromImage(bmp as Image);
Size framesize = new Size(Screen.PrimaryScreen.Bounds.Width , Screen.PrimaryScreen.Bounds.Height);
graphicsFromBmp.CopyFromScreen(0, 0, 0, 0, framesize);
Image smaller = (bmp.GetThumbnailImage(Screen.PrimaryScreen.Bounds .Width / 2, Screen.PrimaryScreen.Bounds.Height / 2, null, IntPtr.Zero));
graphicsFromBmp.Dispose();
smaller.Save("c:\\" + Environment.MachineName.ToString()+'_'+ number + ".jpg", ImageFormat.Jpeg);

//printscreen.Save("\\\\UAST-PCLIBRARY\\Desktop View\\" +
// System.Environment.MachineName.ToString() + "_" + number + ".jpg", ImageFormat.Jpeg);

}


ممکنه بعدن هم پروژه ی کامل رو به همراه نسخه های کلاینت و سرور بذارم .