|
وبلاگ تخصصی کامپیوتر و نرم افزار درباره وبلاگ ![]() هادی قائمی معاون اجرایی موسسه غیر انتفاعی رستگاران کامیاران آخرین مطالب آرشيو وبلاگ لینک های مفید چت باکس :: :: نويسنده : هادی قائمي
الگوریتم رسم خط در سی شارپ:
ابتدا یک عکس یا جعبه عکس در فرم قرار می دهیم: public partial class Form1 : Form{ Bitmap mybmp; ilag3=0; int x1, x2, y1, y2,x3,y3; Color mycolor; string address;برای نگهداشتن عکسmy bmp تعریف متغیر ها: یک متغیر برای ذخیره رنگ فعلی و یک متغییر از نوع عکس به نام //*********************** void line(int x1, int y1, int x2, int y2) { int step = 0, k, dx = x2 - x1, dy = y2 - y1; float x = x1, y = y1, xinc = 0, yinc = 0; if (dx > dy) step = dx; else step = dy; xinc = dx / ( float)step;yinc = dy / ( float)step;mybmp.SetPixel( Convert.ToInt32(Math.Round(x)), Convert.ToInt32(Math.Round(y)), mycolor); for (k = 1; k <= step; k++){ x += xinc; y += yinc; mybmp.SetPixel( Convert.ToInt32(Math.Round(x)), Convert.ToInt32(Math.Round(y)), mycolor);} pictureBox1.Refresh(); } //****************************************************************/ private void pictureBox1_MouseClick(object sender, MouseEventArgs e){ if (x1 < x2){ if (bold == 1){ for (int i = 1; i < 4; i++)line(x1, y1 + i, x2, y2 + i); } if (bold == 2){ for (int i = 1; i < 8; i++)line(x1, y1 + i, x2, y2 + i); } } if (x1 > x2){ if (bold == 1){ for (int i = 1; i < 4; i++)line(x2, y2 + i, x1, y1 + i); } if (bold == 2){ for (int i = 1; i < 8; i++)line(x2, y2 + i, x1, y1 + i); } } picturebox1.image=mybmp; عکس را رد جعبه عکس قرار می دهیم } پیوندهای روزانه لینک های مفید |
||
|
تمامی حقوق این وبلاگ محفوظ است |طراحی : هادی قائمی
|