Back to Subsampling Scale Image View

ImageSource (library 3.10.0 API)

docs/javadoc/com/davemorrissey/labs/subscaleview/ImageSource.html

3.10.013.0 KB
Original Source

Skip navigation links

com.davemorrissey.labs.subscaleview

Class ImageSource


public final classImageSourceextends[Object](https://developer.android.com/reference/java/lang/Object.html?is-external=true "class or interface in java.lang")

Helper class used to set the source and additional attributes from a variety of sources. Supports use of a bitmap, asset, resource, external file or any other URI. When you are using a preview image, you must set the dimensions of the full size image on the ImageSource object for the full size image using the dimensions(int, int) method.

Method Summary

All Methods Static Methods Instance Methods Concrete Methods | Modifier and Type | Method and Description | | --- | --- | | static ImageSource | asset(String assetName) Create an instance from an asset name. | | static ImageSource | bitmap(Bitmap bitmap) Provide a loaded bitmap for display. | | static ImageSource | cachedBitmap(Bitmap bitmap) Provide a loaded and cached bitmap for display. | | ImageSource | dimensions(int sWidth, int sHeight) Declare the dimensions of the image. | | protected Bitmap | getBitmap() | | protected Integer | getResource() | | protected int | getSHeight() | | protected Rect | getSRegion() | | protected int | getSWidth() | | protected boolean | getTile() | | protected Uri | getUri() | | protected boolean | isCached() | | ImageSource | region(Rect sRegion) Use a region of the source image. | | static ImageSource | resource(int resId) Create an instance from a resource. | | ImageSource | tiling(boolean tile) Enable or disable tiling of the image. | | ImageSource | tilingDisabled() Disable tiling of the image. | | ImageSource | tilingEnabled() Enable tiling of the image. | | static ImageSource | uri(String uri) Create an instance from a URI. | | static ImageSource | uri(Uri uri) Create an instance from a URI. |

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

- 

resource

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public static[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")resource(int resId)

Create an instance from a resource. The correct resource for the device screen resolution will be used. Parameters:resId - resource ID.Returns:an ImageSource instance.

- 

asset

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public static[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")asset([@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")assetName)

Create an instance from an asset name. Parameters:assetName - asset name.Returns:an ImageSource instance.

- 

uri

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public static[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")uri([@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")uri)

Create an instance from a URI. If the URI does not start with a scheme, it's assumed to be the URI of a file. Parameters:uri - image URI.Returns:an ImageSource instance.

- 

uri

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public static[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")uri([@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")[Uri](https://developer.android.com/reference/android/net/Uri.html?is-external=true "class or interface in android.net")uri)

Create an instance from a URI. Parameters:uri - image URI.Returns:an ImageSource instance.

- 

bitmap

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public static[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")bitmap([@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html?is-external=true "class or interface in android.graphics")bitmap)

Provide a loaded bitmap for display. Parameters:bitmap - bitmap to be displayed.Returns:an ImageSource instance.

- 

cachedBitmap

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public static[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")cachedBitmap([@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html?is-external=true "class or interface in android.graphics")bitmap)

Provide a loaded and cached bitmap for display. This bitmap will not be recycled when it is no longer needed. Use this method if you loaded the bitmap with an image loader such as Picasso or Volley. Parameters:bitmap - bitmap to be displayed.Returns:an ImageSource instance.

- 

tilingEnabled

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")tilingEnabled()

Enable tiling of the image. This does not apply to preview images which are always loaded as a single bitmap., and tiling cannot be disabled when displaying a region of the source image. Returns:this instance for chaining.

- 

tilingDisabled

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")tilingDisabled()

Disable tiling of the image. This does not apply to preview images which are always loaded as a single bitmap, and tiling cannot be disabled when displaying a region of the source image. Returns:this instance for chaining.

- 

tiling

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")tiling(boolean tile)

Enable or disable tiling of the image. This does not apply to preview images which are always loaded as a single bitmap, and tiling cannot be disabled when displaying a region of the source image. Parameters:tile - whether tiling should be enabled.Returns:this instance for chaining.

- 

region

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")region([Rect](https://developer.android.com/reference/android/graphics/Rect.html?is-external=true "class or interface in android.graphics")sRegion)

Use a region of the source image. Region must be set independently for the full size image and the preview if you are using one. Parameters:sRegion - the region of the source image to be displayed.Returns:this instance for chaining.

- 

dimensions

[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public[ImageSource](../../../../com/davemorrissey/labs/subscaleview/ImageSource.html "class in com.davemorrissey.labs.subscaleview")dimensions(int sWidth,
                                       int sHeight)

Declare the dimensions of the image. This is only required for a full size image, when you are specifying a URI and also a preview image. When displaying a bitmap object, or not using a preview, you do not need to declare the image dimensions. Note if the declared dimensions are found to be incorrect, the view will reset. Parameters:sWidth - width of the source image.sHeight - height of the source image.Returns:this instance for chaining.

- 

getUri

protected final[Uri](https://developer.android.com/reference/android/net/Uri.html?is-external=true "class or interface in android.net")getUri()
- 

getBitmap

protected final[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html?is-external=true "class or interface in android.graphics")getBitmap()
- 

getResource

protected final[Integer](https://developer.android.com/reference/java/lang/Integer.html?is-external=true "class or interface in java.lang")getResource()
- 

getTile

protected final boolean getTile()
- 

getSWidth

protected final int getSWidth()
- 

getSHeight

protected final int getSHeight()
- 

getSRegion

protected final[Rect](https://developer.android.com/reference/android/graphics/Rect.html?is-external=true "class or interface in android.graphics")getSRegion()
- 

isCached

protected final boolean isCached()

Skip navigation links