OSDN Git Service

Copied remotely
[nyartoolkit-and/nyartoolkit-and.git] / branches / 1.2.0-last / sample / jmf / jp / nyatla / nyartoolkit / jmf / sample / JmfCaptureTest.java
1 /**
2  * VFMキャプチャテストプログラム
3  * (c)2008 A虎@nyatla.jp
4  * airmail@ebony.plala.or.jp
5  * http://nyatla.jp/
6  */
7 package jp.nyatla.nyartoolkit.jmf.sample;
8
9 import javax.media.*;
10
11 import javax.media.util.BufferToImage;
12 import javax.media.format.*;
13 import jp.nyatla.nyartoolkit.NyARException;
14 import jp.nyatla.nyartoolkit.jmf.utils.*;
15
16 import java.awt.*;
17
18
19
20 public class JmfCaptureTest extends Frame implements JmfCaptureListener{
21     public JmfCaptureTest() throws NyARException
22     {
23         setTitle("JmfCaptureTest");
24         setBounds(0,0,320+64,240+64);     
25         capture=new JmfCameraCapture(320,240,30f,JmfCameraCapture.PIXEL_FORMAT_RGB);
26         capture.setCaptureListener(this);
27     }
28
29
30
31     private JmfCameraCapture  capture;
32     public void onUpdateBuffer(Buffer i_buffer)
33     {
34         BufferToImage b2i=new BufferToImage((VideoFormat)i_buffer.getFormat());
35         Image img=b2i.createImage(i_buffer);
36         Graphics g = getGraphics();        
37         g.drawImage(img, 32, 32,this);       
38     }
39     private void startCapture()
40     {
41         try{
42             capture.start();
43         }catch(Exception e){
44             e.printStackTrace();
45         }
46     }
47     public static void main(String[] args) {
48         try{
49             JmfCaptureTest mainwin = new JmfCaptureTest();
50             mainwin.setVisible(true);
51             mainwin.startCapture();
52         }catch(Exception e){
53             e.printStackTrace();
54         }
55         
56     }
57
58 }