Code example for BitmapFactory.Options

Methods: decodeStream

0
            if(options.outWidth != reusedBitmap.getWidth() || options.outHeight != reusedBitmap.getHeight()) {
                options = getDefaultOptions();
                options.inBitmap = reusedBitmap;
                options.inSampleSize = 1;
                try { 
                    srcBitmap = BitmapFactory.decodeStream(streamLoader.get(), null, options);
                    streamLoader.close();
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } 
            } 
            if(srcBitmap == null)
                reusedBitmap.recycle();
        } 
 
        if(srcBitmap != null)
        { 
            if(destWidth > 0 && destHeight > 0)
                srcBitmap = scaleBitmapToDesire(srcBitmap, destWidth, destHeight, true);
        } else 
        { 
            srcBitmap = getBitmap(streamLoader, destWidth, destHeight);
        } 
        return srcBitmap;
    } 
 
    public static final BitmapFactory.Options getBitmapSize(String filePath)
    { 
        return getBitmapSize(new InputStreamLoader(filePath));
    } 
 
    public static final BitmapFactory.Options getBitmapSize(InputStreamLoader streamLoader)
    { 
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        try {         
            BitmapFactory.decodeStream(streamLoader.get(), null, options);
            streamLoader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null; 
        } 
 
        return options;
    } 
 
    public static BitmapFactory.Options getDefaultOptions()
    { 
        BitmapFactory.Options opt = new BitmapFactory.Options();
        opt.inDither = false;
        opt.inJustDecodeBounds = false;
        opt.inSampleSize = 1;
        opt.inScaled = false;
        return opt;