<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      異步加載圖片以及Bitmap相關處理方法

      私類:

      // 異步更新Image
          private class GetImageTask extends AsyncTask<String, Void, Bitmap> {
      
              // 覆寫的方法,這個方法將在這個類的對象execute()的時候調用
              protected Bitmap doInBackground(String... urls) {
                  Bitmap bmp = null;
                  Bitmap newBitmap = null;
                  int bmWidth, bmHeight;
                  try {
                      bmp = FileUtil.getBitmapByPath(urls[0]);//本地圖片獲得Bitmap
                      bmWidth = bmp.getWidth();
                      bmHeight = bmp.getHeight();
      
                      // 圖片過大就剪裁以下
                      if ((bmWidth > 240) || (bmHeight > 240)) {
                          newBitmap = fileUtil.imageCropSquare(bmp);//從bitmap剪裁為正方形Bitmap
                      } else {
                          newBitmap = bmp;
                      }
      
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                  return newBitmap;
              }
      
              @Override
              // 覆寫的方法,當耗時的操作執行完之后執行,這里就是把獲得的Bitmap更新到ImageView上
              protected void onPostExecute(Bitmap result) {
                  // TODO Auto-generated method stub
                  super.onPostExecute(result);
                  imgPostPic.setImageBitmap(result);
      
              }
      getBitmapByPath本地圖片路徑獲得BitMap方法:
      /**
           * 從本地路徑獲取、生成與原圖同樣大小的Bitmap,不作壓縮
           * 
           * @param path
           * @return
           */
          public static Bitmap getBitmapByPath(String path) {
              if (path == null){
                  return null;
              }
              
              Bitmap bmTemp = null;
              if (bmTemp == null) {
                  try {
                      bmTemp = BitmapFactory.decodeFile(path);
                  } catch (Exception e) {
                      e.printStackTrace();
                  } catch (Error e) {
                      e.printStackTrace();
                  }
              }
              return bmTemp;
          }

      網絡圖片路徑獲得Bitmap的方法

      /**
           * Android獲取網絡圖片轉換成Bitmap
           * 
           * @return Bitmap
           */
      
          private static final int IO_BUFFER_SIZE = 4 * 1024;// 設置緩沖區大小
      
          public static Bitmap GetBitmapFromWeb(String url) {
              Bitmap bitmap = null;
              InputStream in = null;
              BufferedOutputStream out = null;
              try {
                  System.out.println("GetLocalOrWebBitmap HEAD, url:" + url);
                  in = new BufferedInputStream(new URL(url).openStream(),
                          IO_BUFFER_SIZE);
                  final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
                  out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
                  copy(in, out);
                  out.flush();
                  byte[] data = dataStream.toByteArray();
                  bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
                  data = null;
                  System.out.println("GetLocalOrWebBitmap END");
                  return bitmap;
              } catch (IOException e) {
                  e.printStackTrace();
                  return null;
              }
          }
      
          // 附加的copy函數
          private static void copy(InputStream in, OutputStream out)
                  throws IOException {
              byte[] b = new byte[IO_BUFFER_SIZE];
              int read;
              while ((read = in.read(b)) != -1) {
                  out.write(b, 0, read);
              }
          }

      正方形Bitmap剪裁:

      /**
           * 按正方形裁切圖片
      
           */
      
          public  Bitmap imageCropSquare(Bitmap bitmap) {
      
              int w = bitmap.getWidth(); // 得到圖片的寬,高
              int h = bitmap.getHeight();
              int wh = w > h ? h : w;// 裁切后所取的正方形區域邊長
              int retX = w > h ? (w - h) / 2 : 0;//基于原圖,取正方形左上角x坐標
              int retY = w > h ? 0 : (h - w) / 2;
      
              //下面這句是關鍵
      
              return Bitmap.createBitmap(bitmap, retX, retY, wh, wh, null, false);
      
          }

       

      posted @ 2013-10-18 15:53  朝野布告  閱讀(503)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 成人av专区精品无码国产| 欧美日韩国产亚洲沙发| 亚洲午夜久久久久久噜噜噜 | 亚洲愉拍一区二区三区| 亚洲精品中文字幕二区| 国产乱人伦AV在线麻豆A| 锦州市| 亚洲无码精品视频| 中文字幕成人精品久久不卡| 国产精品区一二三四久久| 激情五月开心婷婷深爱| 国产99久久久国产精品~~牛| 精品视频福利| 国产精品一码二码三码| 浪潮av色综合久久天堂| 青柠影院免费观看高清电视剧丁香| 国产不卡一区二区四区| 看免费的无码区特aa毛片| 欧美日韩视频综合一区无弹窗| 熟妇的奶头又大又长奶水视频| 在线精品另类自拍视频| 动漫AV纯肉无码AV电影网| 日韩免费美熟女中文av| 色欲国产精品一区成人精品| 国产欧美在线观看不卡| 中文字幕人妻av12| 国产成人精品1024免费下载| 精品人妻无码中文字幕在线| 久久精品国产精品亚洲精品| 人妻伦理在线一二三区| 亚洲一区二区三区久久受| 精品国产免费一区二区三区香蕉 | 国产大尺度一区二区视频| 久久久久无码精品国产AV| 国产美女被遭强高潮免费一视频 | 又粗又大又黄又硬又爽免费看| 色欲综合久久中文字幕网| 欧美人与zoxxxx另类| 51午夜精品免费视频| 久久精品国产99国产精品澳门| 九九热精品免费视频|