luberda-molinet / FFImageLoading

Image loading, caching & transforming library for Xamarin and Windows
MIT License
1.42k stars 377 forks source link

Circletransformation has an unwanted offset from the border #943

Open woutermeuwis opened 6 years ago

woutermeuwis commented 6 years ago

Description

When using a CircleTransformation on my image with a border (Size=40, color=FFFFFF) It looks like the there's an outer circle of 1 pixel wide that is not covered by the border

Steps to Reproduce

<ffimageloading:CachedImage Source="{Binding Source}"
                                DownsampleToViewSize="true"
                                Aspect="AspectFit"
                                HorizontalOptions="Center"
                                LoadingPlaceholder="icn_placeholder"
                                ErrorPlaceholder="icn_placeholder"
                                HeightRequest="100"
                                WidthRequest="100">

        <ffimageloading:CachedImage.Transformations>

            <fftransformations:CircleTransformation BorderSize="40"
                                                    BorderHexColor="FFFFFF" />

        </ffimageloading:CachedImage.Transformations>

</ffimageloading:CachedImage>`

Expected Behavior

Circular image with a white border that covers the outer edge

Actual Behavior

White border is 1 pixel removed from the edge

Basic Information

daniel-luberda commented 6 years ago

This is the code used to draw borders:

Any clues?

Slepter commented 5 years ago

@woutermeuwis I've faced with the same problem and I just used another library. Check it: https://github.com/jamesmontemagno/ImageCirclePlugin

adrianknight89 commented 5 years ago

@Slepter Using two different libraries should be avoided as they use different caching stores.

@daniel-luberda I can confirm this issue as well. Seems like there is a rounding problem with the calculations being made.

Also, is the border size in pixels? It would be great if we had a way to define it in dp units. Setting a 40px border size will look different on different screen sizes.