hdodenhof / CircleImageView

A circular ImageView for Android
Apache License 2.0
14.55k stars 3.12k forks source link

Image with black frame not working correctly #383

Closed marctan closed 4 years ago

marctan commented 4 years ago

Hello,

Thanks for making this library but I've some problem with some images that has a black frame making it look like not rounded.

Example below: It is taken from https://i1.sndcdn.com/artworks-kj7zCHzxyAO9mISm-aLKVGQ-t500x500.jpg

image.

In my app, it looks like this: image

I don't have any control with the raw images (JPG). I'm only fetching it from a URL so it's not possible to edit it directly.

Do you have some workaround to fix this?

Here's the xml:

<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/album_artwork"
    android:layout_width="225dp"
    android:layout_height="230dp"
    android:layout_gravity="center"
    android:src="@drawable/me"
    app:layout_constraintBottom_toBottomOf="@+id/big_album_circle"
    app:layout_constraintEnd_toEndOf="@+id/big_album_circle"
    app:layout_constraintHorizontal_bias="0.54"
    app:layout_constraintStart_toStartOf="@+id/big_album_circle"
    app:layout_constraintTop_toTopOf="@+id/big_album_circle"
    app:layout_constraintVertical_bias="0.54" />

Thanks!

hdodenhof commented 4 years ago

If all the images come with the same black border, you could crop the Bitmap by a fixed amount of pixels before updating the CircleImageView. But I guess only some images come with a border - in that case there's unfortunately no easy way. You could use OpenCV to try to automatically detect and remove borders but that's not trivial and probably over the top for your use case. I'd consider moving from a circle to a "squircle"