Terry.Li-彬

          虛其心,可解天下之問;專其心,可治天下之學;靜其心,可悟天下之理;恒其心,可成天下之業。

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            143 隨筆 :: 344 文章 :: 130 評論 :: 0 Trackbacks

          前兩天看了一個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. ??

          posted on 2011-08-05 22:32 禮物 閱讀(3031) 評論(2)  編輯  收藏

          評論

          # re: flex攝像頭拍照 java上傳到數據庫 . 2012-08-31 13:48 霞之大夢
          你好,flex的需要引什么包嗎  回復  更多評論
            

          # re: flex攝像頭拍照 java上傳到數據庫 . 2014-04-13 11:04 123yedddd
          //連接WebService失敗事件
          private function __onSavePictureFault(event:FaultEvent):void
          {
          //Alert.show(event.fault.toString(),"提示",Alert.OK);
          Alert.show("連接WebService失敗。","提示",Alert.OK);
          }
          我把提示改連接WebService失敗123。 怎么沒反映啊。。還是連接WebService失敗。  回復  更多評論
            


          只有注冊用戶登錄后才能發表評論。

          網站導航:
           
          主站蜘蛛池模板: 灯塔市| 福安市| 曲松县| 会昌县| 稷山县| 临桂县| 闻喜县| 涟水县| 湛江市| 南开区| 全南县| 安顺市| 嵩明县| 白水县| 保山市| 柳林县| 万盛区| 布尔津县| 恭城| 化隆| 神农架林区| 喀喇沁旗| 阿克陶县| 琼结县| 中牟县| 巴林右旗| 且末县| 宜城市| 黄大仙区| 宁国市| 富宁县| 满城县| 南通市| 恩平市| 平武县| 格尔木市| 武强县| 安平县| 昌黎县| 杭锦后旗| 江川县|