Back to project page Shutterbug.
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.
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; } } }