Android Open Source - Shutterbug Bitmap Factory Scale






From Project

Back to project page Shutterbug.

License

The source code is released under:

* Copyright (c) 2012, Applidium * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met...

If you think the Android project Shutterbug 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.applidium.shutterbug.utils;
//from   ww  w  .  j a  va 2 s  . co  m
import java.io.InputStream;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class BitmapFactoryScale {
    public interface InputStreamGenerator {
        public InputStream getStream();
    }

    public static Bitmap decodeSampledBitmapFromStream(InputStreamGenerator generator, DownloadRequest request) {
        if (generator == null || request == null) {
            return null;
        }
        try {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeStream(generator.getStream(), null, options);

            options.inSampleSize = request.getSampleSize(options);
            options.inJustDecodeBounds = false;
            return BitmapFactory.decodeStream(generator.getStream(), null, options);
        } catch (OutOfMemoryError e) {
            e.printStackTrace();
            return null;
        }
    }
}




Java Source Code List

com.applidium.shutterbug.FetchableImageView.java
com.applidium.shutterbug.cache.DiskLruCache.java
com.applidium.shutterbug.cache.ImageCache.java
com.applidium.shutterbug.cache.LruCache.java
com.applidium.shutterbug.downloader.ShutterbugDownloader.java
com.applidium.shutterbug.utils.BitmapFactoryScale.java
com.applidium.shutterbug.utils.DownloadRequest.java
com.applidium.shutterbug.utils.ShutterbugManager.java
com.applidium.shutterbugdemo.ShutterbugActivity.java