资源简介
android使用手机摄像头.zip
代码片段和文件信息
/*
* @version 1.2 2012-06-29
* @author wanghai
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
import java.net.Socket;
import java.net.ServerSocket;
/**
*在服务器开启情况下,启动客户端,创建套接字接收图像
*/
public class ImageServer {
public static ServerSocket ss = null;
public static void main(String args[]) throws IOException{
ss = new ServerSocket(6000);
final Imageframe frame = new Imageframe(ss);
frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
frame.setVisible(true);
while(true){
frame.panel.getimage();
frame.repaint();
}
}
}
/**
A frame with an image panel
*/
@SuppressWarnings(“serial“)
class Imageframe extends Jframe{
public ImagePanel panel;
public JButton jb;
public Imageframe(ServerSocket ss){
// get screen dimensions
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;
// center frame in screen
settitle(“ImageTest“);
setLocation((screenWidth - DEFAULT_WIDTH) / 2 (screenHeight - DEFAULT_HEIGHT) / 2);
setSize(DEFAULT_WIDTH DEFAULT_HEIGHT);
// add panel to frame
this.getContentPane().setLayout(null);
panel = new ImagePanel(ss);
panel.setSize(640480);
panel.setLocation(0 0);
add(panel);
jb = new JButton(“拍照“);
jb.setBounds(048064050);
add(jb);
saveimage saveaction = new saveimage(ss);
jb.addActionListener(saveaction);
}
public static final int DEFAULT_WIDTH = 640;
public static final int DEFAULT_HEIGHT = 560;
}
/**
A panel that displays a tiled image
*/
@SuppressWarnings(“serial“)
class ImagePanel extends JPanel {
private ServerSocket ss;
private Image image;
private InputStream ins;
public ImagePanel(ServerSocket ss) {
this.ss = ss;
}
public void getimage() throws IOException{
Socket s = this.ss.accept();
System.out.println(“连接成功!“);
this.ins = s.getInputStream();
this.image = ImageIO.read(ins);
this.ins.close();
}
public void paintComponent(Graphics g){
super.paintComponent(g);
if (image == null) return;
g.drawImage(image 0 0 null);
}
}
class saveimage implements ActionListener {
RandomAccessFile inFile = null;
byte byteBuffer[] = new byte[1024];
InputStream ins;
private ServerSocket ss;
public saveimage(ServerSocket ss){
this.ss = ss;
}
public void actionPerformed(ActionEvent event){
try {
Socket s = ss.accept();
ins = s.getInputStream();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-10-15 07:44 CameraTest\
文件 459 2013-09-16 14:16 CameraTest\.classpath
文件 846 2012-06-20 21:45 CameraTest\.project
文件 1461 2012-07-03 18:49 CameraTest\AndroidManifest.xm
目录 0 2013-09-16 14:17 CameraTest\bin\
文件 1461 2013-09-16 14:16 CameraTest\bin\AndroidManifest.xm
文件 42956 2013-09-16 14:17 CameraTest\bin\CameraTest.apk
目录 0 2013-09-16 14:16 CameraTest\bin\classes\
目录 0 2013-09-16 14:16 CameraTest\bin\classes\org\
目录 0 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\
目录 0 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\
文件 353 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\BuildConfig.class
文件 1404 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\CameraTest$1.class
文件 3167 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\CameraTest.class
文件 1676 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\GetIP$1.class
文件 885 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\GetIP$2.class
文件 2231 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\GetIP.class
文件 1540 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\MyThread.class
文件 352 2013-09-16 14:17 CameraTest\bin\classes\org\wanghai\CameraTest\R$attr.class
文件 419 2013-09-16 14:17 CameraTest\bin\classes\org\wanghai\CameraTest\R$drawable.class
文件 524 2013-09-16 14:17 CameraTest\bin\classes\org\wanghai\CameraTest\R$id.class
文件 463 2013-09-16 14:17 CameraTest\bin\classes\org\wanghai\CameraTest\R$layout.class
文件 439 2013-09-16 14:17 CameraTest\bin\classes\org\wanghai\CameraTest\R$string.class
文件 559 2013-09-16 14:17 CameraTest\bin\classes\org\wanghai\CameraTest\R.class
文件 2088 2013-09-16 14:16 CameraTest\bin\classes\org\wanghai\CameraTest\StreamIt.class
文件 11416 2013-09-16 14:17 CameraTest\bin\classes.dex
目录 0 2013-09-16 14:17 CameraTest\bin\dexedLibs\
文件 943 2013-09-16 14:17 CameraTest\bin\dexedLibs\annotations-2626851360bb9fc5460fef54dbd031a5.jar
文件 120 2013-09-16 14:16 CameraTest\bin\jarlist.cache
目录 0 2012-06-27 00:59 CameraTest\bin\res\
目录 0 2012-06-27 00:59 CameraTest\bin\res\drawable-hdpi\
............此处省略38个文件信息
- 上一篇:javaweb使用mvc框架实现注册登录
- 下一篇:javax 常用jar
相关资源
- BAT大牛深度剖析Android10大开源框架视
- Registered.java
- JAVA互联网.txt
- 尚硅谷java核心技术教程.txt
- 传智播客20套java项目高清视频完整源
- servlet实现密码修改功能
- JAVA实验报告(四)-李兆明.doc
- JetbrainsCrack-2.10-release-enc.jar.zip
- 全套Java视频.docx
- 毕向东java基础全套视频教程.txt
- 传智播客崔希凡JAVAWEB教程.txt
- 敏感词库27000条代码实现敏感词过滤
- echart-java.zip
- 152G的java全套资源.zip
- java彩票模拟投注系统.zip
- java项目,前后端分离视频教程源码
- 疯狂Android讲义第三版Androidstudio所有源
- Java固定资产管理系统课程设计源码整
- javaSpringcloudB2B2Co2o电子商务.zip
- MainActivity.java
- java_random_util_list.zip
- 魔乐李兴华零基础学Java系列视频教程
- 第一行代码JavaPDF.txt
- 《Java编程规范第三版》PDF.txt
- javaweb网上商城视频加源码.txt
- Java秒杀系统方案全套视频.zip
- JAVA例题.rar
- alex-word-filter-2.0.jar
- 张人杰双向词汇Java敏感词过滤3.0.ra
- Java设计模式-32讲地址.zip
评论
共有 条评论