package cn.test;
import java.io.*;
import java.util.Date;
import java.util.Enumeration;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.VideoControl;
import javax.microedition.amms.*;
import javax.microedition.amms.control.camera.*;
import javax.microedition.io.file.*;
import javax.microedition.io.*;
public class VideoMain extends Form implements CommandListener, ItemStateListener, ItemCommandListener{
private Player player;
private VideoControl vidCtrl = null;
private String defaultPath;
private CameraDemo demo;
private Command exitCommand = new Command("Exit", Command.ITEM, 1);
private Command saveCommand = new Command("Save", Command.BACK, 1);
private Command backCommand = new Command("Back", Command.BACK, 2);
private Command chooseCommand = new Command("choose", Command.ITEM, 1);
private Command backToBrowserCommand =
new Command("BackToBrows", Command.BACK, 1);
private Command deleteImageFile =
new Command("Delete from disk", Command.ITEM, 1);
//摄像头拍照命令
private final Command snapCommand =
new Command("Snapshot", Command.STOP, 1);
private final Command saveSnapCommand =
new Command("Save it", Command.STOP, 1);
private final Command deleteSnapCommand =
new Command("Delete it", Command.ITEM, 1);
private Command analyCommand = new Command("analyze", Command.ITEM, 2);
private final Command setSnapshotCommand =
new Command("Snapshot setting", Command.ITEM, 1);
private final Command viewGalleryCommand =
new Command("View gallery", Command.ITEM, 6);
//显示图片
private final Command displayCommand = new Command("Display", Command.ITEM, 6);
//选择配置相片保存路径
private Command fileOkCommand = new Command("select", Command.BACK, 1);
private Command fileCancelCommand = new Command("exit", Command.BACK, 2);
//图片预览分析后界面后退按钮
private Command snapViewAnaBackCommand = new Command("backView", Command.BACK, 2);
//图片预览分析后界面保存按钮
private Command snapViewAnaSaveCommand = new Command("SaveCovertPic", Command.BACK, 1);
private Display display;
private Form vidForm;
private Form snapForm;
private Item videoItem;
private List browser;
private Form imageViewer;
private FileConnection currImage;
private StringItem si;
private String previewFileName;
//是否保存图片
private boolean savePic = false;
private String picPath;
private Form snapView;
private Form analyViewForm;
private Image analyImg;
private Image cvtAnalyImage;
private int showPic = 0;
//浏览的图片名, 用于分析后的图像名称使用
private String browserImageName;
private Form snapshotSettingsForm;
private ChoiceGroup snapSetDisOrSave;
//拍摄后是否显示图片
private String[] snapSetOption = {"yes",
"no"};
//拍摄后是否保存
private String[] snapSaveOption = {"yes",
"no"};
private ChoiceGroup snapSaveOrNo;
private ChoiceGroup snapSetFreezeOrConfirm;
private TextField burstNum;
private boolean savedMessageAppear = false;
List lstMenu;
/* separator character as defined by FC specification */
private final static char SEP = '/';
private String PHOTOS_DIR = null;
List list = new List("File Browser", List.IMPLICIT);
/**
* 表示根目录的字符串
*/
private final static String ROOT = "/";
/**
* 表示父目录的字符串
*/
private final static String PARENT_FOLDER = "..";
//文件和目录的图标
Image imgFile = null; //文件图标
Image imgDir = null; //目录图标
Image imgRoot = null; //根目录图标
//保存当前的路径,缺省为根路径
String curURI = ROOT;
public VideoMain(CameraDemo d, String path) {
super("camera demo");
this.demo = d;
vidForm = this;
//vidForm = new Form("Camera Player");
display = d.display;
vidForm.addCommand(exitCommand);
vidForm.addCommand(snapCommand);
vidForm.addCommand(setSnapshotCommand);
vidForm.addCommand(viewGalleryCommand);
vidForm.setCommandListener(this);
defaultPath = path;
try {
player = Manager.createPlayer("capture://video");
player.prefetch();
player.realize();
vidCtrl = (VideoControl)player.getControl(
"VideoControl");
if (vidCtrl != null) {
videoItem = (Item)vidCtrl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);
vidCtrl.setDisplaySize(210, 180);
vidForm.append(videoItem);
player.start();
player.start();
} else {
System.out.println("Error: Can not create VideoControl");
return;
}
} catch (MediaException me) {
me.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
//文件浏览
//装载文件图标
try {
imgFile = Image.createImage("/txtfile.JPG");
} catch (IOException e) {
System.out.println("不能装载文件图标");
}
//装载目录图标
try {
imgDir = Image.createImage("/dirclose.JPG");
} catch (IOException e) {
System.out.println("不能装载目录图标");
}
//装载根目录图标
try {
imgRoot = Image.createImage("/drive.JPG");
} catch (IOException e) {
System.out.println("不能装载根目录图标");
}
//display.setCurrent(vidForm);
}
/**
* 显示文件目录
*
*/
private void displayDir() {
list.deleteAll();
if (curURI.equals(ROOT)) {
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements()) {
String rootName = (String)e.nextElement();
list.append(rootName, imgRoot);
}
} else {
//显示目录中的全部文件和文件夹
list.append(PARENT_FOLDER, imgDir); //添加父目录
try {
FileConnection fc = (FileConnection)Connector.open(
"file://"+curURI);
Enumeration e = fc.list();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
if (name.indexOf("/")>-1) {
//添加目录
list.append(name, imgDir);
} else {
//添加文件
list.append(name, imgFile);
}
}
fc.close();
}
catch (IOException ioe) {
}
}
}
/*
* Respond to commands, including back
*/
public void commandAction(Command c, Displayable s) {
if(c =
没有合适的资源?快使用搜索试试~ 我知道了~
J2ME手机照相图片解析程序
共42个文件
class:28个
java:4个
jad:3个
需积分: 10 37 下载量 155 浏览量
2009-05-20
09:22:21
上传
评论 1
收藏 111KB RAR 举报
温馨提示
在WTK2.5的DEFAULTCOLORPHONE和S60 3rd模拟器上测试正常通过. 具有指定保存路径, 缩放图片, 保存图片, 解析指定像素颜色, 是一个简单的利用手机拍摄图片的分析软件, 希望对各位有所帮助 :0) 解压后用eclipse导入工程项目即可.
资源推荐
资源详情
资源评论
收起资源包目录
J2MeNormal.rar (42个子文件)
J2MeNormal
.project 542B
bin
cn
test
VideoMain$10.class 550B
VideoMain$9.class 4KB
VideoMain$5.class 549B
VideoMain$8.class 549B
VideoMain$3.class 548B
VideoMain$7.class 549B
ConvertImage.class 6KB
CanvaDraw.class 4KB
VideoMain$1.class 2KB
CameraDemo.class 4KB
VideoMain.class 17KB
VideoMain$6.class 1KB
VideoMain$4.class 889B
VideoMain$2.class 2KB
.settings
eclipseme.core.prefs 95B
org.eclipse.jdt.core.prefs 208B
J2MeNormal.jad 241B
deployed
J2MeNormal.jad 265B
J2MeNormal.jar 26KB
.eclipseme.tmp
emulation
J2MeNormal.jad 265B
J2MeNormal.jar 25KB
verified
libs
classes
cn
test
VideoMain$10.class 550B
VideoMain$9.class 4KB
VideoMain$5.class 549B
VideoMain$8.class 549B
VideoMain$3.class 548B
VideoMain$7.class 549B
ConvertImage.class 7KB
CanvaDraw.class 5KB
VideoMain$1.class 3KB
CameraDemo.class 4KB
VideoMain.class 17KB
VideoMain$6.class 1KB
VideoMain$4.class 889B
VideoMain$2.class 2KB
src
cn
test
CanvaDraw.java 5KB
ConvertImage.java 11KB
CameraDemo.java 2KB
VideoMain.java 25KB
.eclipseme 227B
.classpath 200B
共 42 条
- 1
资源评论
麦神-mirson
- 粉丝: 9897
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功