Hi!
How I can use this savePhoto() function for convert image from picBoxTwo.
Convert Image from PictureBox image before Insert to byte.
namespace WebCaptureCRUD
{
public partial class mainForm : Form
{
VideoCaptureDevice videoCapture;
FilterInfoCollection filterInfo;
public webClassCode webClass = new webClassCode();
public mainForm()
{
InitializeComponent();
}
private void mainForm_Load(object sender, EventArgs e)
{
StartCamera();
}
void StartCamera()
{
try
{
filterInfo = new FilterInfoCollection(FilterCategory.VideoInputDevice);
videoCapture = new VideoCaptureDevice(filterInfo[0].MonikerString);
videoCapture.NewFrame += new NewFrameEventHandler(Camera_On);
videoCapture.Start();
}
catch (Exception ex)
{
throw ex;
}
}
private void Camera_On(object sender, NewFrameEventArgs eventArgs)
{
picBoxOne.Image = (Bitmap)eventArgs.Frame.Clone();
}
private void btnCapture_Click(object sender, EventArgs e)
{
picBoxTwo.Image = picBoxOne.Image;
}
//save image
public byte[] savePhoto(System.Drawing.Image image)
{
MemoryStream ms = new MemoryStream();
image.Save(ms, image.RawFormat);
return ms.GetBuffer();
}
private void btnSave_Click(object sender, EventArgs e)
{
weblass.insertStudent(txtLName.Text.Trim(), txtName.Text.Trim(), masked.Mask, Convert.ToInt32(cmbClass.SelectedIndex), txtMobile.Text.Trim(), txtAddress.Text.Trim(), savePhoto(picBoxTwo.Image))
}
}
}