简体   繁体   English

Android:在确保文本可读性的同时模糊位图

[英]Android: Blur bitmap while ensuring text readability

I am blurring a bitmap in my android app. 我在我的android应用中模糊了位图。 This answer was quite helpful for that. 这个答案对此很有帮助。 The problem is that I am using white text on this image which is not visible if the contrast is not good enough, particularly for images which have a major white or yellow portion. 问题是我在此图像上使用白色文本,如果对比度不够好,则该白色文本是不可见的,尤其是对于具有较大白色或黄色部分的图像而言。 I wanted to ask if there is a simple way to overcome this problem, somehow by making the image a bit dirty by adding shades of black or so. 我想问一下是否有一种简单的方法可以解决此问题,即通过添加黑色阴影使图像有点脏。 Spotify seems to do it very elegantly. Spotify似乎做得非常优雅。

在此处输入图片说明

Any tutorials, guides etc that can be helpful? 任何教程,指南等会有所帮助吗? Any help would be appreciated. 任何帮助,将不胜感激。

Adding a full scrim on top of your blurred image should do the trick. 在模糊的图像上添加完整的稀松布应该可以解决问题。

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="@dimen/some_height"
        android:src="@drawable/placeholder"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/some_height"
        android:background="@color/full_image_scrim"/>

   <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center">

       <!-- Top layer views -->

   </LinearLayout>

</FrameLayout>

color.xml

<!-- 60% opaque black (use whatever transparent color works best for you) -->
<color name="full_image_scrim">#99000000</color>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM