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失敗。  回復  更多評論
            


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

          網站導航:
           
          主站蜘蛛池模板: 申扎县| 勐海县| 茌平县| 吉林市| 南郑县| 资兴市| 寿阳县| 罗山县| 平定县| 大悟县| 汝城县| 云龙县| 日喀则市| 英超| 沛县| 曲阳县| 蒙城县| 临颍县| 肇州县| 平山县| 民勤县| 金秀| 涿州市| 彭阳县| 上蔡县| 葫芦岛市| 四川省| 阜城县| 兴宁市| 平遥县| 雅江县| 鹤岗市| 华蓥市| 抚顺市| 江永县| 鹤庆县| 贡嘎县| 张家口市| 长兴县| 中牟县| 图木舒克市|