วันจันทร์ที่ 22 เมษายน พ.ศ. 2556

Part 2 แสดง DateTime ในภาพ


ต่อจากส่วนที่แล้ว ตอนนี้เราจะแสดงตัวเลขของ วัน/เดือน/ปี เวลา ที่เดินไปเรื่อยๆ 

ซึ่งพอ run จะปรากฎพร้อมกับการแสดงผลจาก webcam ใน PictureBox

image
เพิ่ม Code ส่วนนี้ลงไป
void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap b = (Bitmap)eventArgs.Frame.Clone();
           
            DateTime now = DateTime.Now;
            Graphics g =Graphics.FromImage(b);

           // paint current time            SolidBrush brush = new SolidBrush(Color.Red);
            g.DrawString(now.ToString(), this.Font, brush, new PointF(5, 5));
            brush.Dispose();

            g.Dispose();
            cap = b;
            pictureBox1.Image = b;

       }

ไม่มีความคิดเห็น:

แสดงความคิดเห็น