Click here to Skip to main content
15,884,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This code snippet is use to capture image from imaging device provided by Touchless library. Plz help me in converting this ff. code from c# to vb...this code is from http://touchless.codeplex.com/releases/view/17986 sample... but i need it in vb version... thanks in advance sorry for bad English
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TouchlessLib;
using System.Drawing.Imaging;

namespace sample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        TouchlessMgr _touch = new TouchlessMgr();
        Bitmap _overlay;

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (Camera c in _touch.Cameras)
            {
                if (c != null)
                {
                    _touch.CurrentCamera = c;
                    c.OnImageCaptured += new EventHandler<CameraEventArgs>(c_OnImageCaptured);
                    _overlay = new Bitmap(c.CaptureWidth, c.CaptureHeight, PixelFormat.Format24bppRgb);
                    _overlay.MakeTransparent();
                    break;
                }
            }

            pictureBox1.Paint += new PaintEventHandler(pictureBox1_Paint);

        }

        void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            lock (this)
            {
                if (_b != null)
                {
                    e.Graphics.DrawImageUnscaledAndClipped(_b, pictureBox1.ClientRectangle);
                    e.Graphics.DrawImageUnscaledAndClipped(_overlay, pictureBox1.ClientRectangle);
                }
            }
        }

        Bitmap _b;

        void c_OnImageCaptured(object sender, CameraEventArgs e)
        {
            if (button1.Enabled)
            {
                _b = e.Image;
                pictureBox1.Invalidate();
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap c = _touch.CurrentCamera.GetCurrentImage();
            pictureBox2.BackgroundImage = c;
            //button1.Enabled = false;
        }

       
    }
}

you can download the library to this link >> http://touchless.codeplex.com/releases/view/17986[^]
Posted
Updated 18-Apr-11 19:27pm
v2
Comments
Sandeep Mewara 19-Apr-11 4:36am    
What help? If you would not be specific then it would be difficult for anyone to help you.
Try and then tell where you get stuck.

 
Share this answer
 
Comments
Nithin Sundar 19-Apr-11 2:13am    
Comment from OP:

thanks mdusara84 for the link... but still i got problems not totally the code is converted to vb... i encounter error in raising event..
[no name] 19-Apr-11 7:04am    
which error???? Please be specific.
i got problem in raising event...what is equivalent code to this in vb..

XML
c.OnImageCaptured += new EventHandler<CameraEventArgs>(c_OnImageCaptured);



calling this method...

C#
void c_OnImageCaptured(object sender, CameraEventArgs e)
        {
            if (button1.Enabled)
            {
                _b = e.Image;
                pictureBox1.Invalidate();
            }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900