flash+asp+数据库保存从摄像头采集的图像
数据库, 摄像头, 图像, flash, asp数据库, 摄像头, 图像, flash, asp
主要思路:
BitmapData绘制图像,然后用getPixel()函数记住每个像素点,保存到数组中。把这个数组保存到数据库。读取仍然差不多,从数据库中读出图像数据,新建一个BitmapData对像setPixel()把数据还原回去。
System.useCodepage = true;
import flash.display.BitmapData;
//============摄像头初始化=============
var _cam:Camera = ();
_cam.setMode(160, 120, 12, true);
_video.attachVideo(_cam);
//==========收集图像数据并显示========
var photo_mc:MovieClip = ateEmptyMovieClip("photo_mc", 2);
photo_mc._x = 200;
photo_mc._y = 10;
var _BMP:BitmapData = new BitmapData(160, 120, true, 0xfff000);
var cam_func:Function = function () {
_BMP.draw(_video);
photo_mc.attachBitmap(_BMP, 3, "always", true);
};
Release = cam_func;
//================输出图像==============
var out_mc:MovieClip = ateEmptyMovieClip("out_mc", 10);
out_mc._x = 380;
out_mc._y = 130;
out_mc._yscale = -100;
ateTextField("_txt", 22, out_mc._x+10, out_mc._y-25, 100, 20);
this._Color = 0xffffff;
var out_func:Function = function (_array:Array, name_str:String) {
var out_bmp:BitmapData = new BitmapData(160, 120, true);
for (var x:Number = _array.length-1; x>=0; x--) {
for (var y:Number = _array[x].length-1; y>=0; y--) {
out_bmp.setPixel(x, y, Number("0x"+_array[x][y]));
}
}
out_mc.attachBitmap(out_bmp, 11, "always", true);
this._ = name_str;
};
//===================接收图片数据========
var bmpdatashow_func:Function = function (_lvoadVars) {
var out_array:Array = new Array();
var temp_array:Array = new Array();
temp_array = _lv.data_asp.split("|");
for (var d:Number = temp_array.length-2; d>=0; d--) {
var temp2_array:Array = new Array();
temp2_array = temp_array[d].split(",");
out_array.push(temp2_array);
}
out_func(out_array, _lv.name_asp);
};
//============发送图像数据并接收========
var bmp_lvoadVars = new LoadVars();
Load = function(success:Boolean):Void {
if (success && this.suc_asp == "刷新成功!") {
bmpdatashow_func(this);
= "数据发送成功!";
nameshow_func();
}
};
var bmp_func:Function = function () {
var bmp_array:Array = new Array();
for (var x:Number = 159; x>=0; x--) {
var bmpy_array:Array = new Array();
for (var y:Number = 119; y>=0; y--) {
bmpy_array.push(_Pixel(x, y).toString(16));
}
bmp_array.push(bmpy_array+"|");
}
bmp_lv.name = ;
bmp_lv.bmp_data = bmp_array;
= "正在发送数据,请稍等......";
bmp_lv.sendAndLoad("asp/bmp.asp?id="+Math.random(), bmp_lv, "post");
};
Release = function() {
if ( != "") {
bmp_func();
} else {
= "请输入您的姓名!";
setTimeout(function () {
= "";
}, 2000);
}
};
//=============列表添加=========
var addItem_func:Function = function (_array:Array) {
veAll();
for (var d:Number = 0; d<_array.length-1; d++) {
name_list.addItem((d+1)+":"+_array[d]);
}
};
name_list.addEventListener("change", this);
this.change = function(evt) {
//trace(evt.target.selectedIndex);
select_func(name_array[evt.target.selectedIndex]);
};
//===============名字显示================
var name_lvoadVars = new LoadVars();
var name_array:Array = new Array();
Load = function(success) {
trace(success);
if (success) {
name_array = [];
name_array = this.name_asp.split("|");
addItem_func(name_array);
setTimeout(function () {
= "";
= "";
}, 1000);
}
};
var nameshow_func:Function = function () {
name_lv.load("asp/showname.asp?id="+Math.random());
};
nameshow_func();
//===============图像查询===================
var showbmp_lvoadVars = new LoadVars();
Load = function(success) {
if (success) {
bmpdatashow_func(this);
= "数据接收成功!";
nameshow_func();
asp数据
}
};
var select_func:Function = function (name_str:String) {
showbmp_lv.name = name_str;
showbmp_lv.sendAndLoad("asp/selectbmp.asp?id="+Math.random(), showbmp_lv, "post");
= "正在接收数据,请稍等......";
};
Release = function() {
select_func();
};
//============删除===================
var delete_lvoadVars = new LoadVars();
Load = function(success) {
if (success) {
= this.suc_asp;
_ = "";
nameshow_func();
} else {
= "删除失败!";
}
};
var delete_func:Function = function () {
if (_ != undefined) {
= "正在删除图片,请稍等......";

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。