我使用AForge.video.dll
和AForge.video.DirectShow.dll
。捕獲前顯示在PictureBox中的圖像不同且捕獲的圖像不同
我想保存這是在拍攝時顯示的圖片框精確圖像(pbPhoto
是我用來顯示相機的視頻圖片框)
void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bit = (Bitmap)eventArgs.Frame.Clone();
pbPhoto.Image = bit;
}
private void btImage_Click(object sender, EventArgs e)
{
try
{
photo = true;
if (!scanFlag)
{
btPrintPass.Enabled = false;
scanFlag = true;
cam = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
cam.Start();
this.btImage.Text = "Stop Scan";
}
else
{
btPrintPass.Enabled = true;
scanFlag = false;
if (cam.IsRunning)
{
cam.Stop();
}
this.btImage.Text = "Scan Photo";
string path = "temp.Jpeg";
if (pbPhoto.Image != null)
{
pbPhoto.Image.Save(path, ImageFormat.Jpeg);
//this.pictureBox1.Image.Save(path,ImageFormat.Bmp) ;
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
//long Len = ss.Length ;
//this.pictureBox1.Image.Save(
m_barrImg = new byte[Convert.ToInt32(fs.Length)];
int iBytesRead = fs.Read(m_barrImg, 0, Convert.ToInt32(fs.Length));
fs.Close();
}
}
}
catch (Exception ex)
{
LogError(ex.ToString());
}
finally
{ }
}
與您想要的圖像有什麼不同?只有幾幀未來? –
picturebox圖像顯示爲像縮放圖像,但在捕獲圖像後,它看起來像是從太遠捕獲圖像 – shridhar
然後我懷疑它是'picturebox'的'SizeMode'屬性。它是什麼? –