Bitmapfactory. options opt = new bitmapfactory. options (); // This isjustdecodebounds is very important OPT. injustdecodebounds = true; Bm = bitmapfactory. decodefile (absolutepath, OPT); // obtain the original width and height of the image. Int picwidth = OPT. outwidth; int picheight = OPT. outheight; // obtain the screen width and height. windowmanager = getwindowmanager (); display = windowmanager. getdefadisplay display (); int screenwidth = display. getwidth (); int screenheight = display. getheight (); // issamplesize indicates the degree to which the image is scaled. For example, the width and height of the image whose value is 2 are changed to the previous one/2opt. insamplesize = 1; // calculate the zoom ratio based on the screen size and image size. If (picwidth> picheight) {If (picwidth> screenwidth) OPT. insamplesize = picwidth/screenwidth;} else {If (picheight> screenheight) OPT. insamplesize = picheight/screenheight;} // this time, a scaled bitmapopt with pixels is generated. injustdecodebounds = false; Bm = bitmapfactory. decodefile (absolutepath, OPT); // use imageview to display bitmapiv. setimagebitmap (BM );