List of usage examples for android.graphics Bitmap getHeight
public final int getHeight()
From source file:Main.java
public static int getByteCount(Bitmap bitmap) { // This approach invokes API Level 1 methods unlike the Bitmap.getBytesCount() one from API level 12. return bitmap != null ? bitmap.getRowBytes() * bitmap.getHeight() : 0; }
From source file:Main.java
/** * * @param source//from w w w.jav a2s .c o m * @param angle * @return */ private static Bitmap rotateImage(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); }
From source file:Main.java
public static Bitmap rotaingImageView(int angle, Bitmap bitmap) { Matrix matrix = new Matrix(); matrix.postRotate(angle);/* w w w .j a v a 2s. com*/ Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return resizedBitmap; }
From source file:Main.java
public static Bitmap rotateImage(int angle, Bitmap bitmap) { Matrix matrix = new Matrix(); matrix.postRotate(angle);/* w w w. j av a 2 s. co m*/ Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return resizedBitmap; }
From source file:Main.java
public static Bitmap formatBitmap(Bitmap bitmap, int width, int height) { int wh = Math.max(bitmap.getWidth(), bitmap.getHeight()); Bitmap mBitmap = Bitmap.createBitmap(wh, wh, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mBitmap); canvas.drawBitmap(bitmap, -(bitmap.getWidth() - wh) / 2, -(bitmap.getHeight() - wh) / 2, null); bitmap = Bitmap.createScaledBitmap(mBitmap, width, height, true); return bitmap; }
From source file:Main.java
public static Drawable rotateBitmap(Bitmap inputBitmap) { Matrix matrix = new Matrix(); matrix.setRotate(90, (float) inputBitmap.getWidth() / 2, (float) inputBitmap.getHeight() / 2); float outputX = inputBitmap.getHeight(); float outputY = 0; final float[] values = new float[9]; matrix.getValues(values);/*from www . j ava2 s . c o m*/ float x1 = values[Matrix.MTRANS_X]; float y1 = values[Matrix.MTRANS_Y]; matrix.postTranslate(outputX - x1, outputY - y1); Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap.getHeight(), inputBitmap.getWidth(), Bitmap.Config.ARGB_8888); Paint paint = new Paint(); Canvas canvas = new Canvas(outputBitmap); canvas.drawBitmap(inputBitmap, matrix, paint); return new BitmapDrawable(null, outputBitmap); }
From source file:Main.java
public static Bitmap getRoundBitmap(Bitmap bmp, float roundDP) { // roundDP *= Constants.screen_density; Bitmap bmpOut = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888); Canvas c = new Canvas(bmpOut); final Paint p = new Paint(); final RectF rectF = new RectF(0, 0, bmp.getWidth(), bmp.getHeight()); p.setAntiAlias(true);//ww w .java 2 s . c o m c.drawARGB(0, 0, 0, 0); p.setColor(Color.BLACK); c.drawRoundRect(rectF, roundDP, roundDP, p); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); c.drawBitmap(bmp, 0, 0, p); return bmpOut; }
From source file:Main.java
public static Bitmap rotaingBitmap(int angle, Bitmap bitmap) { Matrix matrix = new Matrix(); matrix.postRotate(angle);/*www. j ava 2s .com*/ Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return resizedBitmap; }
From source file:Main.java
public static Point getImageMaxDimension(Context context, int[] imgRes) { final Point point = new Point(); for (int i = 0, length = imgRes.length; i < length; i++) { Bitmap tmp = BitmapFactory.decodeResource(context.getResources(), imgRes[i]); int width = tmp.getWidth(); int height = tmp.getHeight(); tmp.recycle();//from w w w.j a v a 2 s.c om tmp = null; if (point.x < width) { point.x = width; } if (point.y < height) { point.y = height; } } return point; }
From source file:Main.java
public static Bitmap clipRoundCornerBitmap(Bitmap bitmap, float radius, int borderColor) { if (bitmap == null) { return null; }// w w w . j a v a 2 s . c om final int h = bitmap.getHeight(); final int w = bitmap.getWidth(); final Bitmap output = Bitmap.createBitmap(w, h, Config.ARGB_8888); final Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, w, h); final RectF rectF = new RectF(rect); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(borderColor); canvas.drawRoundRect(rectF, radius, radius, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; }