Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The image gets slightly distorted on pixel perfect images #356

Closed
rocboronat opened this issue Dec 30, 2019 · 12 comments
Closed

The image gets slightly distorted on pixel perfect images #356

rocboronat opened this issue Dec 30, 2019 · 12 comments

Comments

@rocboronat
Copy link

Hi everyone! Here's a very picky image distortion bug.

I have a 56dp widget with an 8dp padding. On the other side, I have pixel-perfect images made at 40dp (it's 56dp - 8dp * 2 sides).

If I apply those images to an ImageView, the result is pixel-perfect. But if I replace that ImageView with a CircleImageView, the result is not pixel-perfect anymore.

Thinking about it, I think that CircleImageView is getting the 40dp image, then resizing it to 56dp, and then applying the padding and resizing the image again to 40dp.

Here are some screenshots. First a comparison, and then a screenshot of every case:

Comparing side by side:
Comparison

Using the plain ImageView:
ImageView

Using CircleImageView:
CicleImageView

By the way, I'm using a local .png file. No network or strange things there.

Thanks again for your work! And happy New Year 😃 🎆 🎆 🎆

@rocboronat
Copy link
Author

I've thought that having a common 40dp without padding (that I used to have a bigger touchable area) would fix the issue... but nope. A 40dp CircleImageView with a 40dp image still has the issue.

Comparison

There are this widgets:

<de.hdodenhof.circleimageview.CircleImageView
    style="@style/fast_share_button"
    android:src="@drawable/ic_share_default" />

<de.hdodenhof.circleimageview.CircleImageView
    style="@style/fast_share_button"
    android:src="@drawable/ic_share_default"
    android:rotation="@integer/rtl_rotation"/>

<ImageView
    style="@style/fast_share_button"
    android:src="@drawable/ic_share_default"
    android:rotation="@integer/rtl_rotation"/>

And the style is:

<style name="fast_share_button">
    <item name="android:layout_width">@dimen/icon_fast_share</item>
    <item name="android:layout_height">@dimen/icon_fast_share</item>
    <item name="android:layout_margin">@dimen/padding_medium</item>
    <item name="android:foreground">@drawable/ripple_on_transparent_round</item>
</style>

@rocboronat rocboronat changed the title The image gets distorted if a padding is applied The image gets slightly distorted on pixel perfect images Dec 30, 2019
@hdodenhof
Copy link
Owner

Hi @rocboronat,

thanks for the detailed report! I just tried to reproduce your issue but wasn't successful so far. Using a 40dp image with 40dp widgets this is what I get:
image

I'm currently a little lost as to what might be causing the issue for you. Does this happen on all devices? Does this only happen with the share icon or any pixel-perfect icon of that size? Can you reproduce the issue dropping the image in question into the sample app?

@hdodenhof
Copy link
Owner

I just pushed a small change to feature/bitmap-filtering (diff) - could you try and see if that changes anything?

You can switch to the feature branch by adding the jitpack repository to your build file and replacing the CircleImageView dependency:

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

dependencies {
    ...
    implementation 'com.github.hdodenhof:CircleImageView:feature~bitmap-filtering-SNAPSHOT'
}

Thanks!

@rocboronat
Copy link
Author

Of course I will, @hdodenhof! Thanks for getting dirt in your hands today 😄

@hdodenhof
Copy link
Owner

@rocboronat Have you had a chance to try out the tweak yet?

@rocboronat
Copy link
Author

Nope, I've been focused in marketing things and didn't have space to try it. But I have it on mind. Thanks for the patience! :·)

@hdodenhof
Copy link
Owner

👌

@rocboronat
Copy link
Author

Good morning @hdodenhof ! 🌞

Here's a comparison between master and your patch branch:
Comparison

You fixed it! 👏🙇

If you want to see the issue by yourself, before we update the app, download QuitNow! and check the flags in the top right corner.

I'm so glad I opened this issue. I think it happened for years... I always had it in my "I will investigate this slight issue someday" because I thought that the issue was related to the image itself... and well, you fixed it with a line of code. Hell yeah! 🎉

Thanks a lot and congrats for the good work 😃

@hdodenhof
Copy link
Owner

Hi @rocboronat,

that's great to hear! I'll try to prepare a new release today or tomorrow at latest so you don't need to rely on a temporary feature branch.

What's a little strange though is that the change should only have an effect if scaling is involved - which shouldn't be the case for pixel perfect images... 🤔 I'll try to get to the bottom of this when I find some time.

I'll update this once the new release is ready.

Cheers!

@rocboronat
Copy link
Author

Thanks a lot! 🚀

@hdodenhof
Copy link
Owner

v3.1.0 with the change is released and should be available on MavenCentral and jCenter.

@rocboronat
Copy link
Author

Awesome! Thanks for that quick release, @hdodenhof

Releasing to production in 3, 2, 1... 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants