List of usage examples for android.graphics BitmapFactory decodeResource
public static Bitmap decodeResource(Resources res, int id)
From source file:Main.java
public static Bitmap getBitmapFromResources(Context context, int resId) { Resources res = context.getResources(); return BitmapFactory.decodeResource(res, resId); }
From source file:Main.java
public static Bitmap getBitmapFromDrawable(Context context, int resId) { return BitmapFactory.decodeResource(context.getResources(), resId); }
From source file:Main.java
public static final Bitmap resourceToBitmap(int id) { Resources res = mContext.getResources(); Bitmap bmp = BitmapFactory.decodeResource(res, id); return bmp;//from www .j ava 2 s . co m }
From source file:Main.java
public static Bitmap decodeResource(Context paramContext, Resources paramResources, int paramInt) { try {// w w w. ja v a 2s .co m Bitmap localBitmap = BitmapFactory.decodeResource(paramResources, paramInt); return localBitmap; } catch (OutOfMemoryError localOutOfMemoryError) { } return null; }
From source file:Main.java
public static Bitmap getBitmapFromResources(Context context, int id) { Bitmap bmp = null;//from w w w .j av a2 s .co m Resources res = context.getResources(); bmp = BitmapFactory.decodeResource(res, id); return bmp; }
From source file:Main.java
public static Bitmap int2Icon(Context context, int i) { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), 0x7f020047); Bitmap bitmap1 = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), android.graphics.Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap1); Paint paint = new Paint(); paint.setDither(true);//w ww .ja va2 s . c om paint.setFilterBitmap(true); canvas.drawBitmap(bitmap, 0.0F, 0.0F, paint); bitmap.recycle(); Paint paint1 = new Paint(257); paint1.setColor(-1); paint1.setTypeface(Typeface.DEFAULT_BOLD); paint1.setTextAlign(android.graphics.Paint.Align.CENTER); canvas.drawText(String.valueOf(i), bitmap.getWidth() / 2, 3 + bitmap.getHeight() / 2, paint1); return bitmap1; }
From source file:Main.java
public static void setTaskDescription(final Activity activity, final String label, final int icon, final int color) { activity.setTaskDescription(new ActivityManager.TaskDescription(label, BitmapFactory.decodeResource(activity.getResources(), icon), color)); }
From source file:Main.java
/** * Return a Bitmap from an Android resource id (e.g. R.drawable...) * @param ctx//from w ww . j a v a2s . c o m * @param bitmapId * @return Bitmap */ public static Bitmap makeBitmap(Context ctx, int bitmapId) { return (BitmapFactory.decodeResource(ctx.getResources(), bitmapId)); }
From source file:Main.java
public static Bitmap rotateDrawable(Context context, @DrawableRes int resId, int angle) { Bitmap bmpOriginal = BitmapFactory.decodeResource(context.getResources(), resId); Bitmap bmResult = Bitmap.createBitmap(bmpOriginal.getWidth(), bmpOriginal.getHeight(), Bitmap.Config.ARGB_8888);/*from w w w . j ava 2 s .c om*/ Canvas tempCanvas = new Canvas(bmResult); tempCanvas.rotate(angle - 90, bmpOriginal.getWidth() / 2, bmpOriginal.getHeight() / 2); tempCanvas.drawBitmap(bmpOriginal, 0, 0, null); return bmResult; }
From source file:Main.java
public static void loadTexture(final Context context, int resId, GL10 gl, int[] textures) { Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), resId); gl.glGenTextures(1, textures, 0);//from w w w . j a v a 2s. c o m gl.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0); bmp.recycle(); }