Skip to content

Softeq/SubsamplingScaleImageView-xamarin-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Subsampling Scale Image View

Build Status NuGet Badge

Xamarin binding library for SubsamplingScaleImageView Android library.


A custom image view for Android, designed for photo galleries and displaying huge images (e.g. maps and building plans) without OutOfMemoryErrors. Includes pinch to zoom, panning, rotation and animation support, and allows easy extension so you can add your own overlays and touch event detection.

The view optionally uses subsampling and tiles to support very large images - a low resolution base layer is loaded and as you zoom in, it is overlaid with smaller high resolution tiles for the visible area. This avoids holding too much data in memory. It's ideal for displaying large images while allowing you to zoom in to the high resolution details. You can disable tiling for smaller images and when displaying a bitmap object. There are some advantages and disadvantages to disabling tiling so to decide which is best, see the original wiki.

Installation

NuGet:

Install-Package SubsamplingScaleImageViewBinding

The minimum SDK is now 14.

Usage

1) Add the view to your layout XML.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>

2) Now, in your fragment or activity, set the image resource, asset name or file path.

var imageView = view.FindViewById<SubsamplingScaleImageView>(Resource.Id.imageView);

imageView.SetImage(ImageSource.ForResource(Resource.Drawable.swissroad));

Integration

FFImageLoading

Use FFImageLoading custom ViewTarget declaration:

public class SubsamplingScaleImageViewTarget : ViewTarget<SubsamplingScaleImageView>
{
    public SubsamplingScaleImageViewTarget(SubsamplingScaleImageView imageView)
        : base(imageView)
    {
    }

    public override void Set(IImageLoaderTask task, SelfDisposingBitmapDrawable image,
        bool animated)
    {
        var source = ImageSource.ForBitmap(image.Bitmap);
        Control.SetImage(source);
    }
}
var target = new SubsamplingScaleImageViewTarget(_imageView);

ImageService.Instance.LoadUrl("image-url").IntoAsync(target);

About

This project is maintained by Softeq Development Corp.

We specialize in developing mobile applications using Xamarin and native technology stack.

License

SubsamplingScaleImageViewBinding library for android is released under the MIT license. See LICENSE for details.

The original SubsamplingScaleImageView project was created by Dave Morrissey under a different license (Apache License 2.0)