Public StaticBitmap Readbitmap (String path) {bitmapfactory.options Options=Newbitmapfactory.options (); Options.inpreferredconfig=Bitmap.Config.RGB_565; Options.inpurgeable=true; Options.ininputshareable=true; Options.insamplesize= Computesamplesize (Options,-1, 128 * 128); Options.injustdecodebounds=true; //Create a 12K-size memory space on Android and store images in that memoryOptions.intempstorage =New byte[12 * 1024]; //get a picture of a resourceInputStream is; Try{ is=NewFileInputStream (path); returnBitmapfactory.decodestream (IS,NULL, Options); } Catch(FileNotFoundException e) {//TODO auto-generated Catch blockE.printstacktrace (); } return NULL; } Public Static intcomputesamplesize (bitmapfactory.options Options,intMinsidelength,intmaxnumofpixels) { intInitialSize =computeinitialsamplesize (Options, Minsidelength, maxnumofpixels); introundedsize; if(InitialSize <= 8) {roundedsize= 1; while(Roundedsize <initialsize) {Roundedsize<<= 1; } } Else{roundedsize= (initialsize + 7)/8 * 8; } returnroundedsize; } Private Static intcomputeinitialsamplesize (bitmapfactory.options Options,intMinsidelength,intmaxnumofpixels) { DoubleW =Options.outwidth; Doubleh =Options.outheight; intLowerbound = (Maxnumofpixels = =-1)? 1: (int) Math.ceil (Math. sqrt (w* H/maxnumofpixels)); intUpperbound = (Minsidelength = =-1)? 128: (int) Math.min (Math.floor (w/minsidelength), Math.floor (H/minsidelength)); if(Upperbound <lowerbound) { returnlowerbound; } if((Maxnumofpixels = =-1) && (minsidelength = =-1)) { return1; } Else if(Minsidelength = =-1) { returnlowerbound; } Else { returnUpperbound; } }