Bsbosa.com
07-14-2010, 08:05 AM
drawn an rectangle on the image using picture box.
quires
1. when tried to zoom image the drawn rectangles needs to be placed on the drawn area.
2. Also draw another rectangle (in zoomed mode).
3. when i zommed out the rectangle needs to resized.
How can i achieve this.
I achieved this by using graphics.drawrectangle but i don't want to draw rectangle on the image because it's stay permanently on the image.
Please help on this......
//getting size of picture box in sz1
public void ZoomIn()
{
//pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
if (sz1.Width >= 800 * 6)
MessageBox.Show("Max ZoomIn");
else {
sz1.Width += 100;
sz1.Height += 100;
pictureBox1.Size = sz1;
pictureBox1.Invalidate();
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (mybitmap == null)
{
mybitmap = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
mybitmap.SetResolution(300, 300);
}
rect = new Rectangle(e.X, e.Y, 0, 0);
pictureBox1.Invalidate();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if (mybitmap == null)
{
return;
}
using (Pen pen = new Pen(Color.Green, 2))
{
foreach (Rectangle r in rectangles)
{
e.Graphics.DrawRectangle(pen, r);
e.Graphics.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 8F), new SolidBrush(label1.ForeColor), r);
}
}
}
modified on Tuesday, July 13, 2010 4:15 AM
quires
1. when tried to zoom image the drawn rectangles needs to be placed on the drawn area.
2. Also draw another rectangle (in zoomed mode).
3. when i zommed out the rectangle needs to resized.
How can i achieve this.
I achieved this by using graphics.drawrectangle but i don't want to draw rectangle on the image because it's stay permanently on the image.
Please help on this......
//getting size of picture box in sz1
public void ZoomIn()
{
//pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
if (sz1.Width >= 800 * 6)
MessageBox.Show("Max ZoomIn");
else {
sz1.Width += 100;
sz1.Height += 100;
pictureBox1.Size = sz1;
pictureBox1.Invalidate();
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (mybitmap == null)
{
mybitmap = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
mybitmap.SetResolution(300, 300);
}
rect = new Rectangle(e.X, e.Y, 0, 0);
pictureBox1.Invalidate();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if (mybitmap == null)
{
return;
}
using (Pen pen = new Pen(Color.Green, 2))
{
foreach (Rectangle r in rectangles)
{
e.Graphics.DrawRectangle(pen, r);
e.Graphics.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 8F), new SolidBrush(label1.ForeColor), r);
}
}
}
modified on Tuesday, July 13, 2010 4:15 AM