方法一 as 2.0
cam= Camera.get(); //抓取当前默认的摄像头图像
MyCam.attachVideo(cam);
方法二 as 2.0
var my_video:Video;
my_video.clear()
my_video._x=100;
my_video._y=40;
var my_cam:Camera = Camera.get();
my_cam.setMode(180, 140, 10, true);
my_video.attachVideo(my_cam);
shutter.onRelease = function() {
myBitmap = new flash.display.BitmapData(160, 120, true, 0);
myBitmap.draw(my_video);
var tempObj = _root.createEmptyMovieClip("photo", 100);
tempObj._x = 300;
tempObj._y = 40;
tempObj._;
tempObj._;
tempObj.attachBitmap(myBitmap, 1, "always", true);
};
方法三 as 3.0
myCam = Camera.get();
myCam.setMode(266,200,10);
my_video.attachVideo(myCam);
3 ,以下代码实现图片的获得和上传
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.ColorTransform;
class PrintScreen {
public var addListener:Function
public var broadcastMessage:Function
private var id: Number;
public var record:LoadVars;
function PrintScreen(){
AsBroadcaster.initialize( this );
}
public function print(mc:MovieClip, w:Number, h:Number){
broadcastMessage("onStart", mc);
w = Math.floor(w);
h = Math.floor(h);
var bmp:BitmapData = new BitmapData(w, h, false);
record = new LoadVars();
record.width = w
record.height = h
record.cols = 0
record.rows = 0
bmp.draw(mc);
id = setInterval(copysource, 1, this, mc, bmp);
}
private function copysource(scope, movie, bit){
var pixel:Number
var str_pixel:String
scope.record["px" + scope.record.rows] = new Array();
for(var a = 0; a < bit.width; a++){
pixel = bit.getPixel(a, scope.record.rows )
str_pixel = pixel.toString(16)
scope.record["px" + scope.record.rows].push(str_pixel)
}
scope.record.rows += 1
if(scope.record.rows >= bit.height){
clearInterval(scope.id)
bit.dispose();
}
}
}
最后再加上一个拍照后再保存到服务器吧。jsp版式
String width");
String height");
int w = Integer.parseInt(width);
int h = Integer.parseInt(height);
try {
OutputStream fos = response.getOutputStream();
BufferedImage bf = new BufferedImage(w, h,
BufferedImage.TYPE_INT_RGB);
for (int i = 0; i < bf.getHeight(); i++) {
String data = request.getParameter("px" + i);
String[] ds = data.split(",");
for (int j = 0; j < bf.getWidth(); j++) {
int d = Integer.parseInt(ds[j], 16);
bf.setRGB(j, i, d);
}
}
ImageWriter writer = null;
ImageTypeSpecifier type = ImageTypeSpecifier
.createFromRenderedImage(bf);
Iterator iter = ImageIO.getImageWriters(type, "jpg");
if (iter.hasNext()) {
writer = (ImageWriter) iter.next();
}
if (writer == null) {
return null;
}
IIOImage iioImage = new IIOImage(bf, null, null);
ImageWriteParam param = writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(0.2f);
// save to file
ImageOutputStream outputStream2 = ImageIO
.createImageOutputStream(response.getOutputStream());
writer.setOutput(outputStream2);
writer.write(null, iioImage, param);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("w = " + w + ",h=" + h);
response.setContentType("image/jpeg");
return null;
我的博物馆故事 官方安卓版v1.61.2
我的博物馆故事是一款以消除为主题的经营养成类手游,在这里玩家
专业模拟飞行10 手机版v12.2.4
专业模拟飞行10安卓版是一款飞行休闲手游,顶尖的物理飞行引擎
动物起义战斗模拟器二琳同款 最新版v4.1.1
动物起义战斗模拟器是一个非常有趣的模拟类游戏,玩家可以召唤各
迷你世界七周年 安卓手机版v1.43.0
迷你世界7周年是一款由《迷你世界》官方推出的庆祝特别版本,在
劫后公司无限资源版 v1.0.5.1
劫后公司内置菜单版是游戏的破解版本,在该版本中为玩家提供了内