|
|
|
C# ต้องการ capture หน้าจอ เป็น VDO ต้องทำอย่างไรครับ เริ่มไม่ถูก ^^ |
|
|
|
|
|
|
|
Code (C#)
private void Form1_Load(object sender, System.EventArgs e)
{
// set the image capture size
this.WebCamCapture.CaptureHeight = this.pictureBox1.Height;
this.WebCamCapture.CaptureWidth = this.pictureBox1.Width;
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// stop the video capture
this.WebCamCapture.Stop();
}
/// <summary>
/// An image was capture
/// </summary>
/// <param name="source">control raising the event</param>
/// <param name="e">WebCamEventArgs</param>
private void WebCamCapture_ImageCaptured(object source, WebCam_Capture.WebcamEventArgs e)
{
// set the picturebox picture
this.pictureBox1.Image = e.WebCamImage;
}
private void cmdStart_Click(object sender, System.EventArgs e)
{
// change the capture time frame
this.WebCamCapture.TimeToCapture_milliseconds = (int) this.numCaptureTime.Value;
// start the video capture. let the control handle the
// frame numbers.
this.WebCamCapture.Start(0);
}
private void cmdStop_Click(object sender, System.EventArgs e)
{
// stop the video capture
this.WebCamCapture.Stop();
}
private void cmdContinue_Click(object sender, System.EventArgs e)
{
// change the capture time frame
this.WebCamCapture.TimeToCapture_milliseconds = (int) this.numCaptureTime.Value;
// resume the video capture from the stop
this.WebCamCapture.Start(this.WebCamCapture.FrameNumber);
}
}
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1339&lngWId=10
|
|
|
|
|
Date :
2011-11-27 08:11:01 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาอันนี้ไปดูไอ้น้องรับรองตอบคำถามครับพี่น้อง
http://kishordgupta.wordpress.com/2011/02/01/step-by-step-to-create-a-desktop-video-recorder-in-c/
Download sample project: http://www.multiupload.com/BR4MF5TEYM
วิธีใช้งาน
1. แตกไฟล์ desktopvideomaker.rar
2. เข้าไปที่ desktopvideomaker\ScreenCapture\bin\Debug
3. Double click ScreenCapture.exe
4. กดปุ่ม Start
5. โปรแกรมจะเริ่ม capture desktop screen
6. เมื่อพอใจกดปุ่ม Cancel
7. ไปดู video file ได้ที่ desktopvideomaker\ScreenCapture\Output
ตัวอย่างโปรแกรมดุได้ใน Project ที่โหลดมาได้ด้วยเหมือนกันครับพีน้อง
Code (C#)
#region Using directives
///kishor datta gupta
///[email protected]
///www.kishordgupta.wordpress.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using AviFile;
using System.Threading;
using System.IO;
#endregion
namespace ScreenCapture
{
public partial class Form1 : Form
{
AviManager aviManager = new AviManager(@"..\..\Output\output.avi", false);
int ScreenWidth = Screen.PrimaryScreen.Bounds.Width;
int ScreenHeight = Screen.PrimaryScreen.Bounds.Height;
VideoStream aviStream = null;
public Form1()
{
InitializeComponent();
}
public void startrecording()
{
Graphics g;
Bitmap b = new Bitmap(ScreenWidth, ScreenHeight);
g = Graphics.FromImage(b);
g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);
aviStream.AddFrame(b);
b.Dispose();
}
private void button1_Click(object sender, EventArgs e)
{
Graphics g;
Bitmap bi = new Bitmap(ScreenWidth, ScreenHeight);
g = Graphics.FromImage(bi);
g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);
aviStream = aviManager.AddVideoStream(true,4, bi);
bi.Dispose(); ; ;
timer1.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
aviManager.Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
startrecording();
}
}
}
http://www.facebook.com/profile.php?id=100003191106723&ref=tn_tnmn
|
ประวัติการแก้ไข 2011-11-27 15:36:27
|
|
|
|
Date :
2011-11-27 15:32:14 |
By :
pStudio |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๅครับผม
|
|
|
|
|
Date :
2011-11-27 20:47:21 |
By :
TELESIS |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|