import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class HelloDSJ extends JLabel implements Runnable
{
BufferedImage im;
DSCapture graph;
public HelloDSJ()
{
DSFilterInfo[][] info = DSCapture.queryDevices() ;
//~ for(int i=0;i
//~ for(int j=0;j
//~ System.out.println("["+i+"]["+j+"]"+info[i][j]);
//~ }
//~ }
graph = new DSCapture(DSFiltergraph.RENDER_NATIVE, info[0][0], false, DSFilterInfo.doNotRender(), null);
graph.play();
try
{
Thread.sleep(2000);
}
catch(Exception e)
{
}//BufferedImage im = graph.getImage();
}
public void paint(Graphics g)
{
g.drawImage(im, 0,0, null);
}
public void run()
{
while(true)
{
im = graph.getImage();
repaint();
}
}
public static void main(String arg[]) throws Exception
{
//~ DSCapture graph;
//~ graph = new DSCapture(DSFiltergraph.RENDER_NATIVE, info[0][0], false, DSFilterInfo.doNotRender(), null);
//~ graph.play();
//~ Thread.sleep(1000);
//~ BufferedImage im = graph.getImage();
//~ ImageIO.write(im, "jpg", new File("result.jpg"));
//~ System.out.println("hi");
//~ graph.dispose();
HelloDSJ h = new HelloDSJ();
JFrame frame = new JFrame("kambing");
frame.setVisible(true);
frame.setSize(800,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(h);
frame.validate();
Thread t = new Thread(h);
t.start();
}
}
No comments:
Post a Comment