Android Open Source - subsampling-scale-image-view Image Region Decoder






From Project

Back to project page subsampling-scale-image-view.

License

The source code is released under:

Apache License

If you think the Android project subsampling-scale-image-view listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.davemorrissey.labs.subscaleview.decoder;
//  w  w w .j a v a 2s  .  co m
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import android.net.Uri;

/**
 * Interface for image decoding classes, allowing the default {@link android.graphics.BitmapRegionDecoder}
 * based on the Skia library to be replaced with a custom class.
 */
public interface ImageRegionDecoder {

    /**
     * Initialise the decoder. When possible, initial setup work once in this method. This method
     * must return the dimensions of the image. The URI can be in one of the following formats:
     * File: file:///scard/picture.jpg
     * Asset: file:///android_asset/picture.png
     * Resource: android.resource://com.example.app/drawable/picture
     * @param context Application context. A reference may be held, but must be cleared on recycle.
     * @param uri URI of the image.
     * @return Dimensions of the image.
     * @throws Exception if initialisation fails.
     */
    Point init(Context context, Uri uri) throws Exception;

    /**
     * Decode a region of the image with the given sample size. This method is called off the UI thread so it can safely
     * load the image on the current thread. It is called from an {@link android.os.AsyncTask} running in a single
     * threaded executor, and while a synchronization lock is held on this object, so will never be called concurrently
     * even if the decoder implementation supports it.
     * @param sRect Source image rectangle to decode.
     * @param sampleSize Sample size.
     * @return The decoded region. It is safe to return null if decoding fails.
     */
    Bitmap decodeRegion(Rect sRect, int sampleSize);

    /**
     * Status check. Should return false before initialisation and after recycle.
     * @return true if the decoder is ready to be used.
     */
    boolean isReady();

    /**
     * This method will be called when the decoder is no longer required. It should clean up any resources still in use.
     */
    void recycle();

}




Java Source Code List

com.davemorrissey.labs.subscaleview.ImageViewState.java
com.davemorrissey.labs.subscaleview.ScaleImageView.java
com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.java
com.davemorrissey.labs.subscaleview.decoder.ImageDecoder.java
com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder.java
com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder.java
com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder.java
com.davemorrissey.labs.subscaleview.sample.MainActivity.java
com.davemorrissey.labs.subscaleview.sample.SampleActivity.java
com.davemorrissey.labs.subscaleview.sample.animation.AnimationActivity.java
com.davemorrissey.labs.subscaleview.sample.basicfeatures.BasicFeaturesActivity.java
com.davemorrissey.labs.subscaleview.sample.configuration.ConfigurationActivity.java
com.davemorrissey.labs.subscaleview.sample.eventhandling.EventHandlingActivity.java
com.davemorrissey.labs.subscaleview.sample.eventhandlingadvanced.AdvancedEventHandlingActivity.java
com.davemorrissey.labs.subscaleview.sample.extension.ExtensionActivity.java
com.davemorrissey.labs.subscaleview.sample.extension.ExtensionCircleFragment.java
com.davemorrissey.labs.subscaleview.sample.extension.ExtensionFreehandFragment.java
com.davemorrissey.labs.subscaleview.sample.extension.ExtensionPinFragment.java
com.davemorrissey.labs.subscaleview.sample.extension.views.CircleView.java
com.davemorrissey.labs.subscaleview.sample.extension.views.FreehandView.java
com.davemorrissey.labs.subscaleview.sample.extension.views.PinView.java
com.davemorrissey.labs.subscaleview.sample.imagedisplay.ImageDisplayActivity.java
com.davemorrissey.labs.subscaleview.sample.imagedisplay.ImageDisplayLargeFragment.java
com.davemorrissey.labs.subscaleview.sample.imagedisplay.ImageDisplayRotateFragment.java
com.davemorrissey.labs.subscaleview.sample.imagedisplay.decoders.RapidImageDecoder.java
com.davemorrissey.labs.subscaleview.sample.imagedisplay.decoders.RapidImageRegionDecoder.java
com.davemorrissey.labs.subscaleview.sample.viewpager.ViewPagerActivity.java
com.davemorrissey.labs.subscaleview.sample.viewpager.ViewPagerFragment.java