【问题标题】:How to make my profile background image as darker blur如何使我的个人资料背景图像变暗模糊
【发布时间】:2017-03-11 04:55:27
【问题描述】:

我正在尝试将图像设置为较暗的模糊。如何进行较暗的模糊?

我正在使我的图像模糊,工作正常,但那个不是更暗。我也在使用网络图像视图,我的图像是来自服务 api 的动态图像。如何使图像变暗模糊。

提前致谢。

我正在使用下面的代码。

 public static Bitmap blur(Context ctx, Bitmap image) {
        int width = Math.round(image.getWidth() * BITMAP_SCALE);
        int height = Math.round(image.getHeight() * BITMAP_SCALE);

        Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(ctx);
        ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);
        tmpOut.copyTo(outputBitmap);

        return outputBitmap;
    }

【问题讨论】:

    标签: android networkimageview


    【解决方案1】:

    你可以使用setColorFilter

    imageView =(ImageView) findViewById(R.id.image_view) ;
    imageView.getDrawable().setColorFilter(0x76ffffff, PorterDuff.Mode.MULTIPLY );
    

    平均黑色0xff555555

    查看我的答案here

    或者你可能想使用这个 github 项目https://github.com/wasabeef/Blurry

    Blurry.with(context)
      .radius(10)
      .sampling(8)
      .color(Color.argb(66, 255, 255, 0))
      .async()
      .onto(rootView);
    

    【讨论】:

    • 那么如何让它变得模糊呢?
    • 让它像你一样模糊,你说你这样做了,并获得图像视图并应用这个,如果你不知道模糊从这个问题中得到一个想法stackoverflow.com/questions/40421723/…你可以使用同一个类叫做 BlurView
    • 点击图像后还有一个疑问,如果我禁用我想要以前的图像没有黑暗,我想应用更暗的模糊。我怎么能
    • 简单你说你从服务器获取图像所以你有正确的 url 所以只需将图像重置为视图如果它被点击你可以再次应用模糊和黑暗效果也检查给定的库它可能帮助您快速锻炼
    • 那没问题。现在我会在单击图像后执行此操作。如果我取消选择该图像,我如何删除这个 setColorFilter(0x76ffffff, PorterDuff.Mode.MULTIPLY);
    猜你喜欢
    • 2015-10-16
    • 1970-01-01
    • 1970-01-01
    • 2017-03-07
    • 2019-06-11
    • 1970-01-01
    • 2013-09-11
    • 2017-11-10
    • 1970-01-01
    相关资源
    最近更新 更多