How to make the app more responsive that uses multiple bitmaps?

I am new to Android, so I don’t understand how to make my application more responsive, because it creates bitmap images for each processing and is installed in imageView. In general, what I'm trying to do is create a bitmap image, play with it, like transferring values ​​from seekBar to change its properties and set it to imageView. How to create a copy of a Bitmap object to avoid links. All offers? thanks in advance

0
source share
2 answers

You can try this library, which handles a bitmap very efficiently.
https://github.com/thest1/LazyList Its a very easy to use library of lazy lists. It caches the bitmap automatically: -

 ImageLoader imageLoader=new ImageLoader(context);
 imageLoader.DisplayImage(url, imageView);

NOTE:

Remember to add the following permissions for your AndroidManifest.xml:
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Create only one instance of ImageLoader and reuse it around your application. Thus, image caching will be much more efficient.

and also you can look in Nostras ImageLoader, since it efficiently handles loading images into containers of a certain size, i.e. resizes and compresses them before you have to process them. It also supports uris content that will help you all right away.

, 1024x768 , 128x96 ImageView.   . , : -

BitmapUtil.java

/**
* Provides static functions to decode bitmaps at the optimal size
*/
public class BitmapUtil {
private BitmapUtil() {}

/**
 * Returns Width or Height of the picture, depending on which size is smaller. Doesn't actually
 * decode the picture, so it is pretty efficient to run.
 */
public static int getSmallerExtentFromBytes(byte[] bytes) {
    final BitmapFactory.Options options = new BitmapFactory.Options();

    // don't actually decode the picture, just return its bounds
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);

    // test what the best sample size is
    return Math.min(options.outWidth, options.outHeight);
}

/**
 * Finds the optimal sampleSize for loading the picture
 * @param originalSmallerExtent Width or height of the picture, whichever is smaller
 * @param targetExtent Width or height of the target view, whichever is bigger.
 *
 * If either one of the parameters is 0 or smaller, no sampling is applied
 */
public static int findOptimalSampleSize(int originalSmallerExtent, int targetExtent) {
    // If we don't know sizes, we can't do sampling.
    if (targetExtent < 1) return 1;
    if (originalSmallerExtent < 1) return 1;

    // test what the best sample size is
    int extent = originalSmallerExtent;
    int sampleSize = 1;
    while ((extent >> 1) >= targetExtent) {
        sampleSize <<= 1;
        extent >>= 1;
    }

    return sampleSize;
}

/**
 * Decodes the bitmap with the given sample size
 */
public static Bitmap decodeBitmapFromBytes(byte[] bytes, int sampleSize) {
    final BitmapFactory.Options options;
    if (sampleSize <= 1) {
        options = null;
    } else {
        options = new BitmapFactory.Options();
        options.inSampleSize = sampleSize;
    }
    return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
  }
  }


http://developer.android.com/training/displaying-bitmaps/index.html

0

Lazy loading Image loader android, imageView,

1

2

0

All Articles