hamid_73
یک شنبه 03 فروردین 1393, 16:51 عصر
سلام دوستان
int x, y, x2, y2;
bool state = false;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
state = true;
x = e.X;
y = e.Y;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (state == true)
{
Graphics a = pictureBox1.CreateGraphics();
pictureBox1.Refresh();
a.DrawRectangle(Pens.Red, x, y, e.X, e.Y);
}
}
private static Image cropImage(Image img, Rectangle cropArea)
{
Bitmap bmpImage = new Bitmap(img);
Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
return (Image)(bmpCrop);
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
state = false;
Graphics a = pictureBox1.CreateGraphics();
pictureBox1.Refresh();
System.Drawing.Drawing2D.HatchBrush Br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing .Drawing2D.HatchStyle.Weave, Color.Red, Color.Transparent);
a.FillRectangle(Br, x, y, e.X, e.Y);
a.DrawRectangle(Pens.Blue, x, y, e.X, e.Y);
pictureBox2.Image = cropImage(pictureBox1.Image, new Rectangle(x +36 , y + 100, e.X + 160, e.Y + 350));
}
دوستان این کد کراپ کردنه تصویره
وقتی یک تیکه از عکس رو با موس انتخاب می کنی روی این خط ارور میده
Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
میزنه out of memory چیکار کنم
int x, y, x2, y2;
bool state = false;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
state = true;
x = e.X;
y = e.Y;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (state == true)
{
Graphics a = pictureBox1.CreateGraphics();
pictureBox1.Refresh();
a.DrawRectangle(Pens.Red, x, y, e.X, e.Y);
}
}
private static Image cropImage(Image img, Rectangle cropArea)
{
Bitmap bmpImage = new Bitmap(img);
Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
return (Image)(bmpCrop);
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
state = false;
Graphics a = pictureBox1.CreateGraphics();
pictureBox1.Refresh();
System.Drawing.Drawing2D.HatchBrush Br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing .Drawing2D.HatchStyle.Weave, Color.Red, Color.Transparent);
a.FillRectangle(Br, x, y, e.X, e.Y);
a.DrawRectangle(Pens.Blue, x, y, e.X, e.Y);
pictureBox2.Image = cropImage(pictureBox1.Image, new Rectangle(x +36 , y + 100, e.X + 160, e.Y + 350));
}
دوستان این کد کراپ کردنه تصویره
وقتی یک تیکه از عکس رو با موس انتخاب می کنی روی این خط ارور میده
Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
میزنه out of memory چیکار کنم