91亚洲va在线天线va天堂va国产 ,亚洲一区二区三区夜色 ,亚洲粉嫩美白在线http://www.tkk7.com/obpm/category/46134.htmlzh-cnWed, 01 Sep 2010 08:39:57 GMTWed, 01 Sep 2010 08:39:57 GMT60Flex在線拍照功能(附源碼)http://www.tkk7.com/obpm/archive/2010/08/29/330207.htmlobpmobpmSun, 29 Aug 2010 13:52:00 GMThttp://www.tkk7.com/obpm/archive/2010/08/29/330207.htmlhttp://www.tkk7.com/obpm/comments/330207.htmlhttp://www.tkk7.com/obpm/archive/2010/08/29/330207.html#Feedback2http://www.tkk7.com/obpm/comments/commentRss/330207.htmlhttp://www.tkk7.com/obpm/services/trackbacks/330207.html功能:在線拍照
簡介:用flex與java結(jié)合實(shí)現(xiàn)在線拍照
需求:為了滿足希望通過攝像頭拍照的圖片,然后通過服務(wù)器來展示需要
效果:
            后臺(tái): 

            前臺(tái):


實(shí)現(xiàn)代碼:
flex:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="388" height="222" creationComplete="initApp()" backgroundColor="#A6C9E2">
     
<mx:Style>
         Alert{font-size:12px;}
     
</mx:Style>
     
<mx:Script>
         
<![CDATA[
             import mx.events.CloseEvent;
             import mx.rpc.events.FaultEvent;
             import mx.rpc.events.ResultEvent;
             import mx.controls.Alert;
             import mx.core.Application;
            
             private static const DEFAULT_CAMERA_WIDTH:Number = 160; //攝像頭顯示寬度
             private static const DEFAULT_CAMERA_HEIGHT:Number = 120; //攝像頭顯示高度
             private var DEFAULT_WEBSERVICE_URL:String = ""; //WebService地址
             private var str:String;
            
             private var m_camera:Camera; //定義一個(gè)攝像頭
             private var m_localVideo:Video; //定義一個(gè)本地視頻
             private var m_pictureBitmapData:BitmapData //定義視頻截圖
             [Bindable]
             private var m_pictureData:String;
            
             private function initApp():void
             {
                 t_btn_Shooting.enabled = false;
                 t_ban_Save.enabled = false;
                 initCamera();
                 DEFAULT_WEBSERVICE_URL = Application.application.parameters.contextPath+"/onLineTakePhotoServlet";
                 t_ws_SavePicture.url=DEFAULT_WEBSERVICE_URL;
             }
            
             //初始化攝像頭
             private function initCamera():void
             {
                 m_camera = Camera.getCamera();
                 if(m_camera != null)
                 {
                     m_camera.addEventListener(StatusEvent.STATUS,__onCameraStatusHandler);
                    
                     m_camera.setMode(DEFAULT_CAMERA_WIDTH,DEFAULT_CAMERA_HEIGHT,30);
                     m_localVideo = new Video();
                     m_localVideo.width = DEFAULT_CAMERA_WIDTH;
                     m_localVideo.height = DEFAULT_CAMERA_HEIGHT;
                     m_localVideo.attachCamera(m_camera);
                     t_vd_Video.addChild(m_localVideo);
                 }
                 else
                 {
                     Alert.show("沒有找到攝像頭,是否重新查找。","提示:",Alert.OK|Alert.NO,this,__InitCamera);
                     return;
                 }
             }
            
             //拍照按鈕事件,進(jìn)行視頻截圖
             private function SnapshotPicture():void
             {
                 m_pictureBitmapData = new BitmapData(DEFAULT_CAMERA_WIDTH,DEFAULT_CAMERA_HEIGHT);
                 m_pictureBitmapData.draw(t_vd_Video,new Matrix());
                
                 var m_pictureBitmap:Bitmap = new Bitmap(m_pictureBitmapData);
                 t_img_Picture.addChild(m_pictureBitmap);
                
                 t_panel_Picture.visible = true;
                 t_ban_Save.enabled = true;
             }
            
             //保存按鈕事件,保存視頻截圖
             //通過WebService保存
             private function SavePicture():void
             {
                 m_pictureData = "";
                 for(var i:int = 0; i < DEFAULT_CAMERA_WIDTH; i++)
                 {
                     for(var j:int = 0; j < DEFAULT_CAMERA_HEIGHT; j++)
                     {
                         if(m_pictureData.length > 0)
                         {
                             m_pictureData += "," + m_pictureBitmapData.getPixel32(i,j).toString();
                         }
                         else
                         {
                             m_pictureData = m_pictureBitmapData.getPixel32(i,j).toString();
                         }
                     }
                 }
                 
                 var params:URLVariables = new URLVariables();
     params.width = DEFAULT_CAMERA_WIDTH;
     params.height = DEFAULT_CAMERA_HEIGHT;
     params.bitmap_data = m_pictureData;
     t_ws_SavePicture.send(params);
             }
            
             //檢測攝像頭權(quán)限事件
             private function __onCameraStatusHandler(event:StatusEvent):void
             {
                 if(!m_camera.muted)
                 {
                     t_btn_Shooting.enabled = true;
                 }
                 else
                 {
                     Alert.show("無法鏈接到活動(dòng)攝像頭,是否重新檢測。","提示:",Alert.OK|Alert.NO,this,__InitCamera);
                 }
                 m_camera.removeEventListener(StatusEvent.STATUS,__onCameraStatusHandler);
             }
            
             //當(dāng)攝像頭不存在,或連接不正常時(shí)重新獲取
             private function __InitCamera(event:CloseEvent):void
             {
                 if(event.detail == Alert.OK)
                 {
                     initApp();
                 }
             }
            
             //WebService保存圖片成功事件
             private function __onSavePictureResult(event:ResultEvent):void
             {
                 //trace(event.result);
                 if(event.result.toString() != "保存失敗")
                 {
                   str = event.result.toString();
                   
                     Alert.show("保存成功,是否關(guān)閉窗口?","提示",3,this,__onAlertCloseHandler);
                 }
                 else
                 {
                     Alert.show(event.result.toString(),"提示",Alert.OK);
                 }
             }
            
             //連接WebService失敗事件
             private function __onSavePictureFault(event:FaultEvent):void
             {
                 //Alert.show(event.fault.toString(),"提示",Alert.OK);
                 Alert.show("連接服務(wù)器失敗。","提示",Alert.OK);
             }
            
             //保存圖片成功后的彈出窗口確認(rèn)事件
             private function __onAlertCloseHandler(event:CloseEvent):void
             {
                 if(event.detail == Alert.YES)
                 {
                    ExternalInterface.call("setValueToField",str);
                 }
             }
         
]]>
     
</mx:Script>
     
<mx:HTTPService id="t_ws_SavePicture" showBusyCursor="true" method="POST" useProxy="false" result="__onSavePictureResult(event)" fault="__onSavePictureFault(event)"/>
     
<mx:Panel x="10" y="10" width="180" height="200" layout="absolute" title="視頻拍照" fontSize="12">
         
<mx:VideoDisplay id="t_vd_Video" width="160" height="120"/>
         
<mx:ControlBar horizontalAlign="right">
             
<mx:Button id="t_btn_Shooting" label="拍照" click="SnapshotPicture()"/>
         
</mx:ControlBar>
     
</mx:Panel>
     
<mx:Panel id="t_panel_Picture" x="198" y="10" width="180" height="200" layout="absolute" title="拍照圖片" fontSize="12" visible="false">
         
<mx:Image id="t_img_Picture" x="0" y="0" width="160" height="120"/>
         
<mx:ControlBar   horizontalAlign="right">
             
<mx:Button id="t_ban_Save" label="保存" click="SavePicture()" />
         
</mx:ControlBar>
     
</mx:Panel>
</mx:Application>



java:

package cn.myapps.core.onlinetakephoto;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.myapps.constans.Environment;
import cn.myapps.util.sequence.Sequence;

/**
 * Servlet implementation class onLineTakePhotoServlet
 
*/
public class onLineTakePhotoServlet extends HttpServlet {
 
private static final long serialVersionUID = 1L;
    
 
private Environment env = Environment.getInstance();
 
 
public void doGet(HttpServletRequest request, HttpServletResponse response)    
 
throws ServletException, IOException {    
 processRequest(request, response);    
 }    
   
 
public void doPost(HttpServletRequest request, HttpServletResponse response)    
  
throws ServletException, IOException {    
 processRequest(request, response);    
 }    
 
 
public void processRequest(HttpServletRequest request, HttpServletResponse response)

    
throws ServletException, IOException {
  response.setContentType(
"text/html;charset=UTF-8");   
        response.setHeader(
"Pragma""No-cache");   
        response.setHeader(
"Cache-Control""no-cache");   
        response.setDateHeader(
"Expires"0);   
  
        String bitmap_data 
= request.getParameter("bitmap_data");   
        
int width = Integer.parseInt(request.getParameter("width"));   
        
int height = Integer.parseInt(request.getParameter("height"));   
        BufferedImage img 
= new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);   
  
try {   
            
int w = width;   
            
int h = height;   
            
int[] pixels = new int[w * h];   
            String[] m_tempPics 
= bitmap_data.split(",");   
            
for (int x = 0; x < w; x++) {   
                
for (int y = 0; y < h; y++) {   
                    Long pic_argb 
= Long.parseLong(m_tempPics[x * h + y]);   
                    
int a = (int) (pic_argb >> 24 & 0xFF);   
                    
int r = (int) (pic_argb >> 16 & 0xFF);   
                    
int g = (int) (pic_argb >> 8 & 0xFF);   
                    
int b = (int) (pic_argb & 0xFF);   
                    pixels[y 
* w + x] = new Color(r, g, b, a).getRGB();   
                }   
            }   
            img.setRGB(
00, w, h, pixels, 0, w);   
            img.flush();   
            ByteArrayOutputStream bao 
= new ByteArrayOutputStream();   
            ImageIO.write(img, 
"jpg", bao);   
            
byte[] data = bao.toByteArray();  
            String filePath 
= env.getRealPath("/uploads/photo");
            
//判斷路徑是否存在,若不存在則創(chuàng)建路徑
            File upDir = new File(filePath);
            
if (!upDir.exists())
            {
                upDir.mkdir();
            }
            
//生成隨機(jī)文件名
            String saveName = Sequence.getSequence();
            String fileName 
= saveName + ".jpg";
            
//寫圖片
            File f = new File(filePath+"\\" + fileName);
      DataOutputStream dos 
= new DataOutputStream(new FileOutputStream(f));
      dos.write(data);
      dos.flush();
      dos.close();
      response.setContentType(
"text/xml");   
            response.getWriter().write(
"/uploads/photo/" + fileName);   
        }
        
catch(Exception ex)
        {
         response.setContentType(
"text/xml");   
            response.getWriter().write(
"保存失敗");   
        }
 }

}

 


源碼:/Files/obpm/onlinetakephoto.rar

 原創(chuàng)人員:Denny



obpm 2010-08-29 21:52 發(fā)表評論
]]>
obpm一鍵生成視圖功能原理(原創(chuàng))http://www.tkk7.com/obpm/archive/2010/07/12/330199.htmlobpmobpmSun, 11 Jul 2010 18:08:00 GMThttp://www.tkk7.com/obpm/archive/2010/07/12/330199.htmlhttp://www.tkk7.com/obpm/comments/330199.htmlhttp://www.tkk7.com/obpm/archive/2010/07/12/330199.html#Feedback0http://www.tkk7.com/obpm/comments/commentRss/330199.htmlhttp://www.tkk7.com/obpm/services/trackbacks/330199.htmlobpm一鍵生成視圖功能原理

在obpm系統(tǒng)后臺(tái)表單右上角有一個(gè)“一鍵生成視圖”功能。實(shí)現(xiàn)它的真正目的是為了后臺(tái)管理人員方便從實(shí)現(xiàn)好的表單中快速生成所有帶值的列的視圖。這樣管理人員就不需要手工新建視圖,然后再添加視圖中的帶值的列。

實(shí)現(xiàn)原理圖:

在實(shí)現(xiàn)原理圖中,我們發(fā)現(xiàn)沒有視圖中并沒有不帶值Field4相應(yīng)的Column4在視圖中,這是因?yàn)樵谝晥D中是要根據(jù)不同Column顯示不同的值的。如果Column是不帶值的話,那么視圖中就不應(yīng)該要這個(gè)Column,即使是要了,在視圖中沒有意義了。

實(shí)現(xiàn)原理代碼:

其中代碼路徑是:src-java-cn-myapps-core-dynaform-form-ejb-FormProcessBean.java

/**

     * 根據(jù)表單編號(hào)來生成視圖

     * @param formid 表單編號(hào)

     * @throws Exception

     */

    public Form oneKeyCreateView(String formid) throws Exception {

           FormProcess formPross = (FormProcess) ProcessFactory.createProcess(FormProcess.class);

           ViewProcess viewPross = (ViewProcess) ProcessFactory.createProcess(ViewProcess.class);

          

           Form form = (Form) formPross.doView(formid);//獲得form

           Collection formfield=form.getValueStoreFields();//獲得form存儲(chǔ)值的field

          

           //新建視圖

           View view = new View();

           if (view.getId() == null || view.getId().trim().length() <= 0) {

              view.setId(Sequence.getSequence());//設(shè)置視圖的ID

              view.setSortId(Sequence.getTimeSequence());//設(shè)置視圖的排序ID     }

            view.setName(form.getName());//把表單的名字賦給視圖

            view.setOpenType(view.OPEN_TYPE_NORMAL); //設(shè)置視圖打開類型-普通類型

            view.setLastmodifytime(new Date());//最后修改日期

            view.setApplicationid(form.getApplicationid());//把表單應(yīng)用程序Id賦給視圖的應(yīng)用程序Id

            view.setModule(form.getModule());//把表單模塊Id賦給視圖的模塊ID

            view.setPagelines("10");//設(shè)置視圖的分頁每頁顯示10條數(shù)據(jù)

            view.setShowTotalRow(true); //是否顯示總共條數(shù)數(shù)據(jù)

            view.setPagination(true); //是否分頁顯示

            view.setRelatedForm(form.getId());//把表單ID賦給視圖的映射表單,從而映射了該表單

          

           

            //將表單中對應(yīng)有值的列轉(zhuǎn)換為視圖的列

            int i=0;

           for(Iterator iterator=formfield.iterator();iterator.hasNext();){

              FormField field=(FormField)iterator.next();

             

              Column column = new Column();

              if (column.getId() == null || column.getId().trim().length() <= 0) {

              column.setId(Sequence.getSequence());

              column.setOrderno(i);

              }

              if(field.getDiscript()!=null && !field.getDiscript().equals("")){//如果該表單中帶值Field有描述的話,就作為視圖Column,否則的用Field名稱

              column.setName(field.getDiscript());

                  }else{

              column.setName(field.getName());

                  }

              column.setFormid(form.getId());//把表單中的ID賦給Column的表單ID

              column.setApplicationid(form.getApplicationid());//把表單中應(yīng)用程序的ID賦給Column的表單應(yīng)用程序ID

 

              column.setFieldName(field.getName());  //把表單中的名稱賦給Column的表單名稱

 

              column.setParentView(view.getId());//將視圖ID賦給Column的父視圖

 

             

              view.getColumns().add(column); //將視圖和Column關(guān)聯(lián)

              i++;

           }

          

          

           //分別創(chuàng)建兩個(gè)按鈕  新建,刪除

           Activity activityCreate = new Activity();

           if (activityCreate.getId() == null || activityCreate.getId().trim().length() <= 0) {

              activityCreate.setId(Sequence.getSequence());

              activityCreate.setOrderno(0);

           }

           activityCreate.setApplicationid(form.getApplicationid());

           activityCreate.setName("新建");

           activityCreate.setParentView(view.getId());

           activityCreate.setType(ActivityType.DOCUMENT_CREATE);

           activityCreate.setOnActionForm(form.getId());

          

           view.getActivitys().add(activityCreate); //將視圖和新建按鈕關(guān)聯(lián)

          

          

           Activity activityDelete = new Activity();

           if (activityDelete.getId() == null || activityDelete.getId().trim().length() <= 0) {

              activityDelete.setId(Sequence.getSequence());

              activityDelete.setOrderno(1);

           }

           activityDelete.setApplicationid(form.getApplicationid());

           activityDelete.setName("刪除");

           activityDelete.setParentView(view.getId());

           activityDelete.setType(ActivityType.DOCUMENT_DELETE);

          

           view.getActivitys().add(activityDelete); //將視圖和刪除按鈕關(guān)聯(lián)

          

          

           viewPross.doCreate(view); //創(chuàng)建視圖

            return form;

    }

 

后臺(tái)效果圖:

表單:

視圖:

視圖列:

視圖按鈕:

前臺(tái)效果:

視圖:

 

表單:

 

 

原創(chuàng)人員:Denny


文章來源:http://www.cnblogs.com/obpm/archive/2010/07/12/1775453.html

obpm 2010-07-12 02:08 發(fā)表評論
]]>
主站蜘蛛池模板: 亚洲av一本岛在线播放| 秋霞人成在线观看免费视频 | 亚洲日韩中文字幕一区| 久久久青草青青亚洲国产免观| 免费萌白酱国产一区二区| 成年免费大片黄在线观看岛国| 免费在线中文日本| 日本特黄特色AAA大片免费| 亚洲夂夂婷婷色拍WW47| 亚洲色av性色在线观无码| 亚洲精品无码MV在线观看| 亚洲中文字幕无码爆乳av中文| 国产成人综合久久精品免费| 97视频免费在线| 老汉精品免费AV在线播放| 成在人线av无码免费高潮喷水 | 亚洲国产成人五月综合网| 成人免费男女视频网站慢动作| 日本免费一区二区在线观看| 日韩精品在线免费观看| 中文字幕a∨在线乱码免费看| 日本永久免费a∨在线视频| 日韩亚洲翔田千里在线| 亚洲精品精华液一区二区| 一本色道久久88—综合亚洲精品 | 国内自产少妇自拍区免费| 免费人成网站在线观看10分钟| 91香蕉在线观看免费高清| 亚洲免费视频网站| 午夜精品射精入后重之免费观看 | 全部免费毛片免费播放| 免费大黄网站在线观看| 免费在线观看黄色毛片| 亚洲AV无码乱码在线观看牲色| 亚洲国产精品人人做人人爽| 亚洲国产成人久久综合野外| 国产亚洲美女精品久久久2020| 亚洲综合伊人久久大杳蕉| 国产AV无码专区亚洲AV毛网站 | 精品国产污污免费网站| 免费人成在线观看网站品爱网|