日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

flex攝像頭拍照 java上傳到數(shù)據(jù)庫(kù) .

 richsky 2012-04-16

前兩天看了一個(gè)flex攝像頭拍照的程序感覺(jué)不錯(cuò)不過(guò)是C#

代碼的,有點(diǎn)遺憾,今天給他改成了java代碼的。

java 代碼:

  1. public   void  processRequest(HttpServletRequest request,  
  2.             HttpServletResponse response)  throws  ServletException, IOException {  
  3.         response.setContentType( "text/html;charset=UTF-8" );  
  4.         response.setHeader( "Pragma" "No-cache" );  
  5.         response.setHeader( "Cache-Control" "no-cache" );  
  6.         response.setDateHeader( "Expires" 0 );  
  7.               String bitmap_data = request.getParameter( "bitmap_data" );  
  8.           
  9.          int  width = commons.getRequestInt(request.getParameter( "width" ), 0 );  
  10.          int  height = commons.getRequestInt(request.getParameter( "height" ), 0 );  
  11.           
  12.         BufferedImage img =  new  BufferedImage(width, height,  
  13.                 BufferedImage.TYPE_INT_RGB);  
  14.                  try  {  
  15.               
  16.              int  w = width;  
  17.              int  h = height;  
  18.              int [] pixels =  new   int [w * h];  
  19.             String[] m_tempPics = bitmap_data.split( "," );  
  20.              for  ( int  x =  0 ; x < w; x++) {  
  21.                  for  ( int  y =  0 ; y < h; y++) {  
  22.                                     Long pic_argb = Long.parseLong(m_tempPics[x * h + y]);  
  23.                                          int  a = ( int ) (pic_argb >>  24  &  0xFF );  
  24.                      int  r = ( int ) (pic_argb >>  16  &  0xFF );   //右移16位 ,取后8位;   
  25.                      int  g = ( int ) (pic_argb >>  8  &  0xFF );  
  26.                      int  b = ( int ) (pic_argb &  0xFF );  
  27.                                         pixels[y * w + x] =  new  Color(r, g, b, a).getRGB();  
  28.                       
  29.                 }  
  30.             }  
  31.             img.setRGB( 0 0 , w, h, pixels,  0 , w);  
  32.             img.flush();  
  33.             ByteArrayOutputStream bao =  new  ByteArrayOutputStream();  
  34.               
  35.             ImageIO.write(img,  "jpg" , bao);  
  36.              byte [] data = bao.toByteArray();  
  37.             Personimage user =  new  Personimage();  
  38.             user.setFileContent(data);  
  39.             PersonimageDAO hm =  new  PersonimageDAO();  
  40.             hm.save(user);  
  41.             PersonrelationDAO prm =  new  PersonrelationDAO();  
  42.             Personrelation pr = prm.findById( new  Long(personRelationId));  
  43.             pr.setPersonimageid(user.getId());  
  44.             pr.setImageflag( "1" );  
  45.             prm.update(pr);  
  46.             str.append( "保存成功" );  
  47.         }  catch  (Exception e) {  
  48.             e.printStackTrace();  
  49.             str.append( "保存失敗" );  
  50.         }  
  51.         response.setContentType( "text/xml" );  
  52.         response.getWriter().write(str.toString());  
  53.     }  
  54.   

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多