luberda-molinet / FFImageLoading

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

Question or Bug: CropTransformation always return square images #483

Closed bvschie closed 7 years ago

bvschie commented 7 years ago

I use CropTransformation in the way demonstrated in the project for Xamarin.Forms.

        Transformations = new List<ITransformation>() {
            new CropTransformation(CurrentZoomFactor, CurrentXOffset, CurrentYOffset)
        };

The XAML looks like this;

    <ScrollView>
        <StackLayout>
            <ffimageloading:CachedImage x:Name="PhotoViewer" HorizontalOptions="Fill" VerticalOptions="Fill"
                Source="{Binding ImageUrl}" 
                Transformations="{Binding Transformations}" CacheType="Disk">
<ffimageloading:CachedImage.GestureRecognizers>
                    <PinchGestureRecognizer PinchUpdated="OnPinchUpdated" />
                    <PanGestureRecognizer PanUpdated="OnPanUpdated" />
                </ffimageloading:CachedImage.GestureRecognizers>  
</ffimageloading:CachedImage>
        </StackLayout>
    </ScrollView>

As soon i apply a CropTransformation to a non-square image; the result is a squared image; Is this a Bug or do I use the Transformation or XAML wrongly ?

Thank you, Bob. image image

daniel-luberda commented 7 years ago

It's not a bug, CropTransformation has aspect ratio properties for controlling that:

https://github.com/luberda-molinet/FFImageLoading/blob/master/source/FFImageLoading.Transformations/CropTransformation.cs#L31-L32