package com.example.talk;

import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.util.Log;

public class LLBitmap {
	
	private static final String TAG = "LLBitmap";
	
	/**
	 * 
	 * @param res
	 * @param resId
	 */
	public static void loadOptions(Resources res,int resId){
		BitmapFactory.Options options = new BitmapFactory.Options();
		options.inJustDecodeBounds = true;	// 设置为true会返回null而不是Bitmap
		BitmapFactory.decodeResource(res, resId,options);
		// 读取属性
		int resWidth = options.outWidth;
		int resHeight = options.outHeight;
		String imageType = options.outMimeType;
		// 读取结束后要切换回来
		options.inJustDecodeBounds = false;
		
		Log.e(TAG, "resWidth="+resWidth);
		Log.e(TAG, "resHeight="+resHeight);
		Log.e(TAG, "imageType="+imageType);
	}
}

@@ -88,23 +88,16 @@
 s.Bitmap
-Factory
 ;%0Aimport
@@ -109,16 +109,30 @@
 oid.
-util.Log
+graphics.BitmapFactory
 ;%0A%0Ap
@@ -154,17 +154,45 @@
 itmap %7B%0A
-%09
+%0A%09@SuppressWarnings(%22unused%22)
 %0A%09privat
@@ -235,88 +235,941 @@
 p%22;%0A
-%09
 %0A%09/
-**%0A%09 * %0A%09 * @param res%0A%09 * @param resId%0A%09 */%0A%09public static void loadOptions
+/ **%E8%AE%A1%E7%AE%97%E5%9B%BE%E7%89%87%E9%9C%80%E8%A6%81%E7%BC%A9%E5%B0%8F%E7%9A%84%E6%AF%94%E4%BE%8B**//%0A%09public static int calculateInSampleSize(BitmapFactory.Options options,%0A%09%09%09int reqWidth, int reqHeight) %7B%0A%09%09// The Origins inSampleSize is 1 , no scale%0A%09%09int inSampleSize = 1;%0A%09%09// The Image's Width&Height%0A%09%09final int width = options.outWidth;%0A%09%09final int height = options.outHeight;%0A%09%09// While The Width&&Height greatter than the required dimessions%0A%09%09if (height %3E reqHeight %7C%7C width %3E reqWidth) %7B%0A%09%09%09// The two value divided 2%0A%09%09%09// because inSampleSize will be multiplied 2 in the while statement%0A%09%09%09final int halfHeight = height / 2;%0A%09%09%09final int halfWidth = width / 2;%0A%09%09%09// While the halfValue divided inSampleSize greater than reqValue%0A%09%09%09// Make the inSampleSize Double%0A%09%09%09while ((halfWidth / inSampleSize) %3E reqWidth%0A%09%09%09%09%09&& (halfHeight / inSampleSize) %3E reqHeight) %7B%0A%09%09%09%09inSampleSize *= 2;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return inSampleSize;%0A%09%7D%0A%0A%09// **%E4%BB%8EResources%E4%B8%AD%E8%8E%B7%E5%8F%96Bitmap**//%0A%09public static Bitmap loadBitmapFromResource
 (Res
@@ -1179,16 +1179,20 @@
 ces res,
+%0A%09%09%09
 int resI
@@ -1196,13 +1196,113 @@
 esId
-)
+, int reqWidth, int reqHeight) 
 %7B%0A
+%0A
 %09%09
+// First set the inJustDecodeBounds=true to check dimensions%0A%09%09final 
 Bitm
@@ -1398,35 +1398,8 @@
 rue;
-%09// %E8%AE%BE%E7%BD%AE%E4%B8%BAtrue%E4%BC%9A%E8%BF%94%E5%9B%9Enull%E8%80%8C%E4%B8%8D%E6%98%AFBitmap
 %0A%09%09B
@@ -1437,16 +1437,17 @@
 , resId,
+ 
 options)
@@ -1457,142 +1457,145 @@
 %09// 
-%E8%AF%BB%E5%8F%96%E5%B1%9E%E6%80%A7%0A%09%09int resWidth = options.outWidth;%0A%09%09int resHeight = options.out
+Caculate the inSampleSize%0A%09%09options.inSampleSize = calculateInSampleSize(options, reqWidth, req
 Height
+)
 ;%0A%09%09
-String imageType = options.outMimeType;%0A%09%09// %E8%AF%BB%E5%8F%96%E7%BB%93%E6%9D%9F%E5%90%8E%E8%A6%81%E5%88%87%E6%8D%A2%E5%9B%9E%E6%9D%A5
+// Close the inJustDecodeBounds
 %0A%09%09o
@@ -1633,120 +1633,66 @@
 se;%0A
-%09%09
 %0A%09%09
-Log.e(TAG, %22resWidth=%22+resWidth);%0A%09%09Log.e(TAG, %22resHeight=%22+resHeight);%0A%09%09Log.e(TAG, %22imageType=%22+imageType
+return BitmapFactory.decodeResource(res, resId, options
 );%0A%09

add LLBitmap's method