morteza_carefree
یک شنبه 09 مرداد 1390, 20:23 عصر
سللم دوستان
من از panel توی برنامه عکس میگیرم و توی یک bitmap ذخیره میکنم و میخوام که اون رو به یه عکس کوچکتر که اندازش رو کاربر وارد میکنه تبدیل کنم اما هر کاری میکنم درست در نمیاد
کدهامو میزارم میشه کمکم کنید
private void pic2pix(Bitmap org)
{
int height = int.Parse(h.Text);// ورودی تکس باک برای ارتفاع عکس
int width = int.Parse(w.Text);//عرض عکس
int h2, w2;
h2 = org.Height / height;
w2 = org.Width / width;
int tj, ti;
Bitmap bmp = new Bitmap(width, height);
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
ti = i + (w2 / 2);
tj = j + (h2 / 2);
Color clr = org.GetPixel(ti,tj);
bmp.SetPixel(i, j, clr);
}
}
pictureBox2.Image = bmp;
}
من از panel توی برنامه عکس میگیرم و توی یک bitmap ذخیره میکنم و میخوام که اون رو به یه عکس کوچکتر که اندازش رو کاربر وارد میکنه تبدیل کنم اما هر کاری میکنم درست در نمیاد
کدهامو میزارم میشه کمکم کنید
private void pic2pix(Bitmap org)
{
int height = int.Parse(h.Text);// ورودی تکس باک برای ارتفاع عکس
int width = int.Parse(w.Text);//عرض عکس
int h2, w2;
h2 = org.Height / height;
w2 = org.Width / width;
int tj, ti;
Bitmap bmp = new Bitmap(width, height);
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
ti = i + (w2 / 2);
tj = j + (h2 / 2);
Color clr = org.GetPixel(ti,tj);
bmp.SetPixel(i, j, clr);
}
}
pictureBox2.Image = bmp;
}