标签:lex option window jpg 1.2 display 获取 default bsp
1.1
1 WindowManager wm=(WindowManager)getSystemService(WINDOW_SERVICE); 2 Point point=new Point(); 3 wm.getDefaultDisplay().getSize(point); 4 int height=point.x; 5 int weight=point.y;
1.2
1 WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE); 2 int width = wm.getDefaultDisplay().getWidth(); 3 int height = wm.getDefaultDisplay().getHeight();
1.3
1 WindowManager manager = this.getWindowManager(); 2 DisplayMetrics outMetrics = new DisplayMetrics(); 3 manager.getDefaultDisplay().getMetrics(outMetrics); 4 int width2 = outMetrics.widthPixels; 5 int height2 = outMetrics.heightPixels;
1 BitmapFactory.Options options=new BitmapFactory.Options();
2 options.inJustDecodeBounds=true;//执行这句话并不会true解析位图 但还能获取图片的宽高信息 3 Bitmap bitmap=BitmapFactory.decodeFile("/mnt/sdcard/1.jpg",options); 4 //获取图片的宽和高信息 5 int weights=options.outWidth; 6 int heights=options.outHeight;
int scale=1; int scaleX=(weights/weight); int scaleY=(heights/height); if (scaleX>=scaleY&&scaleX>scale){ scale=scaleX; } if (scaleY>scaleX&&scaleY>scale){ scale=scaleY; }
options.inSampleSize=scale; options.inJustDecodeBounds=false; Bitmap bitmap1=BitmapFactory.decodeFile("/mnt/sdcard/1.jpg",options); iv.setImageBitmap(bitmap1);
标签:lex option window jpg 1.2 display 获取 default bsp
原文地址:http://www.cnblogs.com/liuyinghai87/p/7135783.html