国产精品久久久久久亚洲调教,国产日韩精品在线,欧美中文字幕在线视频http://www.aygfsteel.com/obpm/category/46134.htmlzh-cnWed, 01 Sep 2010 08:39:57 GMTWed, 01 Sep 2010 08:39:57 GMT60Flex在線拍照功能(附源碼)http://www.aygfsteel.com/obpm/archive/2010/08/29/330207.htmlobpmobpmSun, 29 Aug 2010 13:52:00 GMThttp://www.aygfsteel.com/obpm/archive/2010/08/29/330207.htmlhttp://www.aygfsteel.com/obpm/comments/330207.htmlhttp://www.aygfsteel.com/obpm/archive/2010/08/29/330207.html#Feedback2http://www.aygfsteel.com/obpm/comments/commentRss/330207.htmlhttp://www.aygfsteel.com/obpm/services/trackbacks/330207.html功能:在線拍照
簡介:用flex與java結合實現在線拍照
需求:為了滿足希望通過攝像頭拍照的圖片,然后通過服務器來展示需要
效果:
            后臺: 

            前臺:


實現代碼:
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; //定義一個攝像頭
             private var m_localVideo:Video; //定義一個本地視頻
             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;
                 }
             }
            
             //拍照按鈕事件,進行視頻截圖
             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);
             }
            
             //檢測攝像頭權限事件
             private function __onCameraStatusHandler(event:StatusEvent):void
             {
                 if(!m_camera.muted)
                 {
                     t_btn_Shooting.enabled = true;
                 }
                 else
                 {
                     Alert.show("無法鏈接到活動攝像頭,是否重新檢測。","提示:",Alert.OK|Alert.NO,this,__InitCamera);
                 }
                 m_camera.removeEventListener(StatusEvent.STATUS,__onCameraStatusHandler);
             }
            
             //當攝像頭不存在,或連接不正常時重新獲取
             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("保存成功,是否關閉窗口?","提示",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("連接服務器失敗。","提示",Alert.OK);
             }
            
             //保存圖片成功后的彈出窗口確認事件
             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");
            
//判斷路徑是否存在,若不存在則創建路徑
            File upDir = new File(filePath);
            
if (!upDir.exists())
            {
                upDir.mkdir();
            }
            
//生成隨機文件名
            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

 原創人員:Denny



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

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

實現原理圖:

在實現原理圖中,我們發現沒有視圖中并沒有不帶值Field4相應的Column4在視圖中,這是因為在視圖中是要根據不同Column顯示不同的值的。如果Column是不帶值的話,那么視圖中就不應該要這個Column,即使是要了,在視圖中沒有意義了。

實現原理代碼:

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

/**

     * 根據表單編號來生成視圖

     * @param formid 表單編號

     * @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存儲值的field

          

           //新建視圖

           View view = new View();

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

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

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

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

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

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

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

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

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

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

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

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

          

           

            //將表單中對應有值的列轉換為視圖的列

            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());//把表單中應用程序的ID賦給Column的表單應用程序ID

 

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

 

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

 

             

              view.getColumns().add(column); //將視圖和Column關聯

              i++;

           }

          

          

           //分別創建兩個按鈕  新建,刪除

           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); //將視圖和新建按鈕關聯

          

          

           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); //將視圖和刪除按鈕關聯

          

          

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

            return form;

    }

 

后臺效果圖:

表單:

視圖:

視圖列:

視圖按鈕:

前臺效果:

視圖:

 

表單:

 

 

原創人員:Denny


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

obpm 2010-07-12 02:08 發表評論
]]>
主站蜘蛛池模板: 夹江县| 交口县| 遂昌县| 朝阳市| 伽师县| 江山市| 抚松县| 石城县| 滁州市| 广安市| 绵竹市| 高密市| 会理县| 武鸣县| 确山县| 漳浦县| 策勒县| 长垣县| 南皮县| 临高县| 白城市| 桑植县| 孟连| 荣成市| 额敏县| 屏南县| 孟州市| 墨脱县| 崇信县| 榆社县| 通榆县| 合山市| 汕尾市| 祁连县| 西和县| 积石山| 嘉黎县| 镇坪县| 郁南县| 余干县| 晋中市|