Load large picture to memory step: Step One:
Obtain the width and height data of the product screen; [HD1]
Step Two:
Get the width height of the picture; [HD2]
Step Three:
Calculate the width and height ratio of screen and picture, and scale processing according to the biggest difference; [HD3]
Step Four:
Zoom processing of the image; [HD4]
[HD1] // get the form size of the phone's screen
WindowManager WindowManager = (windowmanager) getsystemservice (window_service);
Display display = Windowmanager.getdefaultdisplay ();
windowheight = display. GetHeight();
windowwidth = display. GetWidth();
[HD2] // class for picture resolution configuration
Options options = new options ();
// do not really do the picture parsing , just get the header information to the picture : width X height date, etc.
Options. Injustdecodebounds = true ;
// set the target file for the image resolution class
bitmapfactory. DecodeFile ("/sdcard/x.jpg", options);
// get the picture's height X width
int imageheight = options. Outheight ;
int imagewidth = options. Outwidth ;
System. out . println (" high of the picture :" + imageheight + " width of the picture :" + imagewidth);
[HD3] // Use the width height of the picture and the width of the screen to calculate , figure out the proportions
int ScaleX = imagewidth/windowwidth;
int ScaleY = imageheight/windowheight;
// Default scale
int scale = 1;
if (ScaleX > ScaleY & ScaleY >= 1) {
scale = ScaleX;
}
if (ScaleY > ScaleX & ScaleX >= 1) {
scale = ScaleY;
}
[HD4] // Set image parser to really parse the picture
Options. Injustdecodebounds = false ;
// Set the resolution's sample rate , Set the value to scale 1/scale
Options. insamplesize = scale;
// get the picture bitmap again and set the sample rate
Bitmap Bitmap = bitmapfactory. DecodeFile ("/sdcard/x.jpg", options);
iv.setimagebitmap (bitmap);