Hi everyone,
In windows Application form,I have put a Picture Box on it and button which name is "Load" below the picture box.
Pressing button "Load" it opens a dialog box to have the choice of the image i want to load.
All I want to do, is to draw a line in the loading photo in the picture box,how do i achieve this?
What is the appropriate code to have the loading image with drawing line in the center of the image for example???
Thank you in advance about your time!
Loading
Christos AlexiouPosted May 9, 2010, 10:48 PM
This code is under the "Load" button???
The code is
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Lines
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Load_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(open.FileName);
}
}
catch (Exception)
{
throw new ApplicationException("Failed loading image");
}
}
private void Load_Paint(object sender, PaintEventArgs e)
{
Graphics g = pictureBox1.CreateGraphics();
g.DrawLine(new Pen(new SolidBrush(Color.Red)), new Point(50, 50), new Point(200, 50));
}
}
}
But this is not what i really want. The point is to load the image in picture Box and a drawline appears in the center of photo.
How do i achieve that???
Kirtan PatelPosted May 9, 2010, 10:39 PM
{
Graphics g = pictureBox1.CreateGraphics();
g.DrawLine(new Pen(new SolidBrush(Color.Red)), new Point(50, 50), new Point(200, 50));
}