乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      flex攝像頭拍照 java上傳到數據庫 .

       richsky 2012-04-16

      前兩天看了一個flex攝像頭拍照的程序感覺不錯不過是C#

      代碼的,有點遺憾,今天給他改成了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.   

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發(fā)現有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多