arash.gh
یک شنبه 04 اردیبهشت 1390, 02:43 صبح
دوستان با استفاده از متد زیر می خوام یک خط رسم کنم دستورات رو نوشتم اما error داره هرکاری کردم رفع نشد اساتید گرامی اگه edit کردن یا دستورات جدید گذاشتن یا error رو پیدا کردن ممنون می شم رهنمایی کنن .
با تشکر فراوان
public partial class Form1 : Form
{
Bitmap mybmp;
//ilag3=0;
int x1,x2,y1,y2,bold;
Color mycolor = System.Drawing.Color.Red;
//***********************
void line(int x1, int y1, int x2, int y2)
{
int step = 0, k, dx = x2 - x1, dy = y2 - y1;
float x, y, xinc = 0, yinc = 0;
if (Math.Abs(dx) > Math.Abs(dy))
step = Math.Abs(dx);
else
step = Math.Abs(dy);
if (step > 0)
{
xinc = (float)(dx) / step;
yinc = (float)(dy) / step;
}
x = x1;
y = y2;
for (k = 0; k <= step; k++)
{
mybmp.SetPixel(Convert.ToInt32(x), Convert.ToInt32(y), mycolor);
x+= xinc;
y+= yinc;
}
pictureBox1.Refresh();
}
//************************************************** **************
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
line(x1,y1,x2,y2);
//line(50, 70, 40, 90);
pictureBox1.Image = mybmp;
}
با تشکر فراوان
public partial class Form1 : Form
{
Bitmap mybmp;
//ilag3=0;
int x1,x2,y1,y2,bold;
Color mycolor = System.Drawing.Color.Red;
//***********************
void line(int x1, int y1, int x2, int y2)
{
int step = 0, k, dx = x2 - x1, dy = y2 - y1;
float x, y, xinc = 0, yinc = 0;
if (Math.Abs(dx) > Math.Abs(dy))
step = Math.Abs(dx);
else
step = Math.Abs(dy);
if (step > 0)
{
xinc = (float)(dx) / step;
yinc = (float)(dy) / step;
}
x = x1;
y = y2;
for (k = 0; k <= step; k++)
{
mybmp.SetPixel(Convert.ToInt32(x), Convert.ToInt32(y), mycolor);
x+= xinc;
y+= yinc;
}
pictureBox1.Refresh();
}
//************************************************** **************
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
line(x1,y1,x2,y2);
//line(50, 70, 40, 90);
pictureBox1.Image = mybmp;
}