真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Android實(shí)現(xiàn)圖片轉(zhuǎn)高斯模糊以及高斯模糊布局-創(chuàng)新互聯(lián)

第一個(gè)為大家介紹圖片如何轉(zhuǎn)高斯模擬:

創(chuàng)新互聯(lián)公司專注于于都網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供于都營(yíng)銷型網(wǎng)站建設(shè),于都網(wǎng)站制作、于都網(wǎng)頁(yè)設(shè)計(jì)、于都網(wǎng)站官網(wǎng)定制、小程序開發(fā)服務(wù),打造于都網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供于都網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

1.方法的實(shí)現(xiàn):

public static void updateBgToBlur(Activity a, Bitmap bmpToBlur, View view, int resId) {
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inJustDecodeBounds = true;
    opt.inSampleSize = 8;
    opt.inJustDecodeBounds = false;
    Bitmap bmp = BitmapFactory.decodeResource(a.getResources(), resId, opt);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
      view.setBackground(null);
    } else {
      view.setBackgroundDrawable(null);
    }
    if (bmpToBlur != null && !bmpToBlur.isRecycled()) {
      bmpToBlur.recycle();
    }
    bmpToBlur = blurBitmap(a, bmp);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      view.setBackground(new BitmapDrawable(a.getResources(), bmpToBlur));
    } else {
      view.setBackgroundDrawable(new BitmapDrawable(a.getResources(), bmpToBlur));
    }
  }


  public static Bitmap blurBitmap(Context c, Bitmap bitmap) {

    //Let's create an empty bitmap with the same size of the bitmap we want to blur
    Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_4444);

    //Instantiate a new Renderscript
    RenderScript rs = RenderScript.create(c.getApplicationContext());

    //Create an Intrinsic Blur Script using the Renderscript
    ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));

    //Create the Allocations (in/out) with the Renderscript and the in/out bitmaps
    Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
    Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);

    //Set the radius of the blur
    blurScript.setRadius(25.f);

    //Perform the Renderscript
    blurScript.setInput(allIn);
    blurScript.forEach(allOut);

    //Copy the final bitmap created by the out Allocation to the outBitmap
    allOut.copyTo(outBitmap);

    //recycle the original bitmap
    bitmap.recycle();

    //After finishing everything, we destroy the Renderscript.
    rs.destroy();

    return outBitmap;
  }


分享標(biāo)題:Android實(shí)現(xiàn)圖片轉(zhuǎn)高斯模糊以及高斯模糊布局-創(chuàng)新互聯(lián)
轉(zhuǎn)載來(lái)源:http://weahome.cn/article/dsojhh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部