JAVAWEB照相带完整例子
资源http://download.csdn.net/detail/bjl373842798/7698003
JS
$(function() {
LODOP=getLodop();
var pos = 0, ctx = null, image = [];
var ctxh = null;
$("#webcam").webcam({
width: 320,//320
height: 240,//240
mode: "callback",
swffile: "${ctx}js/jQuery-webcam-master/jscam_canvas_only.swf",
onSave: function(data) {
var col = data.split(";");
var img = image;
// for(var i = 0; i < 320; i++) {
for(var i = 0; i < 320; i++) {
var tmp = parseInt(col[i]);
img.data[pos + 0] = (tmp >> 16) & 0xff;
img.data[pos + 1] = (tmp >> 8) & 0xff;
img.data[pos + 2] = tmp & 0xff;
img.data[pos + 3] = 0xff;
pos+= 4;
}
//if (pos >= 4 * 320 * 240) {
if (pos >= 4 * 320 * 240) {
//ctxh.clearRect(0, 0, 320, 240);
ctxh.putImageData(img, 0, 0);
image = ctxh.getImageData(0, 0, 320, 240);
ctx.clearRect(0, 0, 160, 200);
ctx.putImageData(image,-80,-40,80,40,160,200);
pos = 0;
}
},
onCapture: function () {
webcam.save();
jQuery("#flash").css("display", "block");
jQuery("#flash").fadeOut("fast", function () {
jQuery("#flash").css("opacity", 1);
});
webcam.save();
}
});
window.addEventListener("load", function() {
jQuery("body").append("<div id=\"flash\"></div>");
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
ctx = document.getElementById("canvas").getCont