flash中的代码:
在舞台上放上一个视频元件,大小是160×120,名字为mybox。再放一个button按扭,名字为photo_btn,第一桢代码如下:

 1 import mx.data.components.WebServiceConnector;
 2 this.cam = Camera.get();
 3 var bitmap_data:String = "";
 4 var pic_width:Number;
 5 var pic_height:Number;
 6 mybox.attachVideo(this.cam);
 7 photo_btn.onRelease = function() {
 8     myBitmap = new flash.display.BitmapData(160, 120, true, 0);
 9     myBitmap.draw(mybox);
10     var tempObj = _root.createEmptyMovieClip("photo", 100);
11     tempObj._x = 300;
12     tempObj._y = 100;
13     pic_width = myBitmap.width;
14     pic_height = myBitmap.height;
15     tempObj.attachBitmap(myBitmap, 1, "always", true);
16     for (i=0; i<pic_width; i++) {
17         for (j=0; j<pic_height; j++) {
18             bitmap_data += myBitmap.getPixel32(i, j).toString()+",";
19         }
20     }
21     trace(pic_width+"   "+pic_height);
22     trace(bitmap_data);
23     wsConn.params = [pic_width, pic_height, bitmap_data];
24     bitmap_data = "";
25     wsConn.trigger();
26 };
27 var res:Function = function (evt:Object) {
28     //返回值的处理函数
29     trace(evt.target.results);
30 };
31 var wsConn:WebServiceConnector = new WebServiceConnector();
32 wsConn.addEventListener("result", res);
33 wsConn.WSDLURL = "http://localhost/bitmap_process/bitmap_process.asmx?Wsdl";
34 wsConn.operation = "bitmap_data_store2";
35 wsConn.suppressInvalidCalls = true;
36 

Flex 2.0代码:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()" fontSize="25">
 3 <mx:Script>
 4     <![CDATA[
 5     import flash.media.Camera;
 6     import flash.media.Video;
 7     import flash.display.*;
 8     import mx.rpc.soap.*;
 9     [Bindable]
10     public  var bitmap_data:String = "";
11     public     var pic_width:int;
12     public     var pic_height:int;
13     public function init():void
14     {
15          var    cam:Camera =  Camera.getCamera();
16         if (cam != null) {
17             video_mc.attachCamera(cam);
18         } else {
19                 trace("You need a camera.");
20         }
21      }
22      public function but_click():void {
23          var myBitmap:BitmapData = new flash.display.BitmapData(160, 120, true, 0);
24          myBitmap.draw(video_mc);
25          var tempObj:MovieClip = new MovieClip();
26          tempObj.name="photo";
27          tempObj.x = 300
28          tempObj.y = 100
29          pic_width = myBitmap.width;
30         pic_height = myBitmap.height;
31         
32         var bitmap_temp:Bitmap = new Bitmap(myBitmap);
33         bitmap_temp.x =400;
34         bitmap_temp.y =122;
35         this.parent.addChild(bitmap_temp);
36         bitmap_data = "";
37         for (var i:int=0; i<pic_width; i++) {
38             for (var j:int=0; j<pic_height; j++) {
39                 bitmap_data += myBitmap.getPixel32(i,j).toString() + ",";
40             }
41         }
42         webserver1.bitmap_data_store2.send();
43     };
44     ]]>
45 </mx:Script>
46     <mx:WebService id="webserver1" showBusyCursor="true" wsdl="http://localhost/bitmap_process/bitmap_process.asmx?WSDL" useProxy="false">
47         <mx:operation name="bitmap_data_store2">
48         <mx:request>
49             <pic_width>160</pic_width>
50             <pic_height>
51             120
52             </pic_height>
53             <bitmap_temp>
54                 { bitmap_data }
55             </bitmap_temp>
56         </mx:request>
57         </mx:operation>
58     </mx:WebService>
59     <mx:VideoDisplay id="video_mc" x="215" y="122" width="160" height="120"/>
60     <mx:Button id="photo_btn" click="but_click();" x="378" y="250" label="拍照" fontSize="12"/>
61     
62 </mx:Application>

注意:
        在第9行的[Bindable]不能少,不然会出现warnning,只要有数据绑定的均要用上,保证实时更新。
        在flash 和flex中的getPixel32返回值类型不一样,flash返回int,flex返回uint,因此我在c#中的转换用了long,这样兼容了flash和flex

新建一个web service,关键代码如下:

 1 [WebMethod]
 2         public string bitmap_data_store2(int pic_width,int pic_height,String  bitmap_temp)
 3         {
 4             try
 5             {
 6                 Bitmap new_pic= new Bitmap(pic_width,pic_height);
 7                 string[] Bitmap_temp_ary = bitmap_temp.Split(',');
 8                 for (int i = 0;i < pic_width;i++)
 9                 {
10                     for (int j = 0;j < pic_height;j++)
11                     {
12                         uint pic_argb =(uint)long.Parse(Bitmap_temp_ary[i*pic_height+j]);
13                         int pic_a =(int)(pic_argb >> 24 & 0xFF);
14                         int pic_r = (int)(pic_argb >> 16 & 0xFF);
15                         int pic_g = (int)(pic_argb >> 8 & 0xFF);
16                         int pic_b = (int)(pic_argb & 0xFF);
17                         new_pic.SetPixel(i,j,Color.FromArgb(pic_a,pic_r,pic_g,pic_b));
18                     }
19                 }
20                 String filepath = Server.MapPath("image/b.jpg");
21                 new_pic.Save(filepath,System.Drawing.Imaging.ImageFormat.Jpeg);
22                 return "保存成功!";
23             }
24             catch (System.Exception e)
25             {
26                 return "处理失败!"+e.ToString();
27             }
28 
29         }

转载于:https://www.cnblogs.com/FireYang/archive/2006/07/22/457317.html

flash 8或flex 2.0+.net web service做在线大头贴,完善中!相关推荐

  1. Web Service学习笔记

    Web Service概述 Web Service的定义 W3C组织对其的定义例如以下,它是一个软件系统,为了支持跨网络的机器间相互操作交互而设计.Web Service服务通常被定义为一组模块化的A ...

  2. 在ASP.NET Atlas中调用Web Service——创建Mashup调用远端Web Service(基础知识以及简单示例)...

    作者:Dflying Chen (http://dflying.cnblogs.com/) 注:Atlas中的Mashup极其复杂,其中涉及众多的对象与架构,为了写这篇文章,我花了不少时间学习研究.同 ...

  3. [Axis2与Eclipse整合开发Web Service系列之三] 服务端返回值

    前言 在前面的三篇中 [Axis2与Eclipse整合开发Web Service系列之一] 生成Web Service Client(将WSDl 转化成 Java代码) [Axis2与Eclipse整 ...

  4. Java RESTful Web Service实战(第2版)

    Java核心技术系列 Java RESTful Web Service实战 (第2版) 韩陆 著 图书在版编目(CIP)数据 Java RESTful Web Service实战 / 韩陆著. -2版 ...

  5. Python中使用GoogleMaps API(包含Geocoding API,Places API Web Service )详细教程

    前言 业务需要根据经纬度获取该城市的邮政编码,需要通过调用GoogleMaps来搜索地点,来获取地点的详细信息.于是查阅了一些相关的资料,特意分享出来给大家参考参考. 涉及相关的资料: google官 ...

  6. web自动化测试之百度经验-HTTP层面的Web Service自动化测试

    2019独角兽企业重金招聘Python工程师标准>>> 前言 我们之前在测试web service的时候尝试过多种方法:比如使用SoapUI:使用本地代理类编程等.前者不太方便做自动 ...

  7. 【分布计算环境学习笔记】9 Web Service

    作者:gnuhpc 出处:http://www.cnblogs.com/gnuhpc/ 1.概述: 在现有的各种异构平台的基础上,构筑一个通用的,与应用无关.语言无关的技术层,各种不同平台之上的应用依 ...

  8. Web Service属性介绍

    Web Service属性介绍 每个 Web Service都需要唯一的命名空间,它可使客户端应用程序区分出可能使用相同方法名称的 Web Service.在 Visual Studio.NET中创建 ...

  9. BASISI系统中如何配置web service

    在不同的客户端,需要对该客户端进行配置才能运行Web Service 1. 配置服务器 使之能解析Xml文件(这个只需要配置一次,以后就不需要配置了), T-code: SICF 分别激活下面几个路径 ...

最新文章

  1. OpenBLAS简介及在Windows7 VS2013上源码的编译过程
  2. python使用matplotlib可视化、使用matplotlib可视化scipy.misc图像、自定义使用RdYIBu色彩映射、将不同亮度映射到不同的色彩
  3. python常见错误-Python错误及异常总结汇总
  4. 怎么自学python编程-怎么能学习好python编程?有自学的方法吗?
  5. Linux系统入门之如何安装Linux系统
  6. vb.net2019-多线程并行计算(2)
  7. 流水调度问题c语言,基于遗传算法的流水车间调度问题汇总.doc
  8. yarn container写token目录选择bug
  9. 关于 SAP Fiori Elements 应用标题属性(title) 的复制逻辑单步调试
  10. Day6-------BOM
  11. 使用MATLAB转换图片为数据进行vga显示
  12. abaqus生成adams柔性体_Abaqus和STAR-CCM+流固耦合
  13. 05 Confluent_Kafka权威指南 第五章: kafka内部实现原理
  14. 关于MacOS升级10.13系统eclipse菜单灰色无法使用解决方案
  15. 软件测试技术---单元测试和集成测试
  16. 【Wechat】微信支付APIV3(商户) 接入批量转账到零钱
  17. Steven Lin 林嘉澍
  18. SQL on log : 同比分析各种指标
  19. android仿网易云音乐引导页、仿书旗小说Flutter版、ViewPager切换、爆炸菜单、风扇叶片效果等源码
  20. linux打开文件乱码

热门文章

  1. a 便签实现 下载
  2. stata如何将xls/xlsx数据转换为dta数据
  3. 关于refs/for/ 和refs/heads/
  4. 2019年传统商家如何做社交新零售?
  5. [git]ssh: Could not resolve hostname github.com: nodename nor servname provided, or not known
  6. 新概念二册 Lesson 40 food and talk进餐与交谈( 现在进行时vs将来进行时+虚拟语气假设现在)
  7. 计算机课教案评语,认识方向教学课件评语(共3篇)
  8. 同位素标记脱氢丙氨酸(Dha)
  9. H - Log Concave Sequences —— 矩阵快速幂
  10. 记录一下微信小程序-一键复制链接功能