Here you can find the source of getBitmapFromRes(Context context, int resId)
public static Bitmap getBitmapFromRes(Context context, int resId)
//License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import org.ixming.android.utils.FrameworkLog; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; public class Main{ static final String TAG = "sharebind_bitmaputil"; public static Bitmap getBitmapFromRes(Context context, int resId) { Bitmap bitmap = null;/*from w w w . j a v a2 s .com*/ try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Config.RGB_565; options.inPurgeable = true; options.inInputShareable = true; bitmap = BitmapFactory.decodeResource(context.getResources(), resId, options); } catch (Exception e) { bitmap = null; FrameworkLog.e(TAG, "getBitmapFromRes Exception: " + e.getMessage()); } return bitmap; } }