(Bitmap OOM) BitmapFactory.nativeDecodeStream

/**
	 * 一种挺有效的方法,规避BitmapFactory.decodeStream或者decodeFile函数,使用BitmapFactory.decodeFileDescriptor
	 * @param path
	 * @return
	 */
	public static  Bitmap readBitmapByPath(String path)   {
	    BitmapFactory.Options bfOptions=new BitmapFactory.Options();
	    bfOptions.inDither=false;                     
	    bfOptions.inPurgeable=true;                 
	    bfOptions.inInputShareable=true;             
	    bfOptions.inTempStorage=new byte[32 * 1024]; 

	    File file=new File(path);
	    FileInputStream fs=null;
	    try {
	    	fs = new FileInputStream(file);
	        if(fs!=null) 
	        	return BitmapFactory.decodeFileDescriptor(fs.getFD(), null, bfOptions);
	    } catch (IOException e) {
	        e.printStackTrace();
	    } finally{ 
	        if(fs!=null) {
	                try {
						fs.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
	        }
	    }
	    return null;
	}

你可能感兴趣的:((Bitmap OOM) BitmapFactory.nativeDecodeStream)