List of usage examples for android.graphics Bitmap getHeight
public final int getHeight()
From source file:Main.java
public static Bitmap highSaturationImage(Bitmap bm) { Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); float[] matrixs = new float[] { 1.438f, -0.122f, -0.016f, 0, -0.03f, -0.062f, 1.378f, -0.016f, 0, 0.05f, -0.062f, -0.122f, 1.438f, 0, -0.02f, 0, 0, 0, 1, 0 }; ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.set(matrixs);//from w w w . java2s . co m paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); canvas.drawBitmap(bm, 0, 0, paint); return bitmap; }
From source file:Main.java
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); float roundPx = w / 2; Bitmap output = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, w, h); final RectF rectF = new RectF(rect); paint.setAntiAlias(true);/*from www .j a v a2 s.com*/ canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidht = (float) width / w; float scaleHeight = (float) height / h; matrix.postScale(scaleWidht, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); }
From source file:Main.java
public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap) { int i = bitmap.getWidth(); int j = bitmap.getHeight(); Matrix matrix = new Matrix(); matrix.preScale(1.0F, -1F);/* w w w .j a va2 s . c om*/ Bitmap bitmap1 = Bitmap.createBitmap(bitmap, 0, j / 2, i, j / 2, matrix, false); Bitmap bitmap2 = Bitmap.createBitmap(i, j + j / 2, android.graphics.Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap2); canvas.drawBitmap(bitmap, 0.0F, 0.0F, null); Paint paint = new Paint(); canvas.drawRect(0.0F, j, i, j + 4, paint); canvas.drawBitmap(bitmap1, 0.0F, j + 4, null); Paint paint1 = new Paint(); paint1.setShader(new LinearGradient(0.0F, bitmap.getHeight(), 0.0F, 4 + bitmap2.getHeight(), 0x70ffffff, 0xffffff, android.graphics.Shader.TileMode.CLAMP)); paint1.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.DST_IN)); canvas.drawRect(0.0F, j, i, 4 + bitmap2.getHeight(), paint1); return bitmap2; }
From source file:Main.java
public static Bitmap zoom(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = ((float) w / width); float scaleHeight = ((float) h / height); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); }
From source file:Main.java
public static Bitmap resize(Bitmap bMap) { if ((float) bMap.getHeight() / (float) bMap.getWidth() == .5625 || (float) bMap.getWidth() / (float) bMap.getHeight() == .5625) { //16/9 if (bMap.getHeight() < bMap.getWidth()) { //bMap = Bitmap.createScaledBitmap(bMap, 1024, 576, false); bMap = Bitmap.createScaledBitmap(bMap, 1280, 720, false); //720p } else {/*from w w w . j av a2 s . c o m*/ //bMap = Bitmap.createScaledBitmap(bMap, 576, 1024, false); bMap = Bitmap.createScaledBitmap(bMap, 720, 1280, false); //720p } } else if ((float) bMap.getHeight() / (float) bMap.getWidth() == .625 || (float) bMap.getWidth() / (float) bMap.getHeight() == .625) { //16/10 if (bMap.getHeight() < bMap.getWidth()) { //bMap = Bitmap.createScaledBitmap(bMap, 960, 600, false); bMap = Bitmap.createScaledBitmap(bMap, 1152, 720, false); //720p } else { //bMap = Bitmap.createScaledBitmap(bMap, 600, 960, false); bMap = Bitmap.createScaledBitmap(bMap, 720, 1152, false); //720p } } else if ((float) bMap.getHeight() / (float) bMap.getWidth() == .75 || (float) bMap.getWidth() / (float) bMap.getHeight() == .75) { //4/3 if (bMap.getHeight() < bMap.getWidth()) { bMap = Bitmap.createScaledBitmap(bMap, 960, 720, false); } else { bMap = Bitmap.createScaledBitmap(bMap, 720, 960, false); } } return bMap; }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = ((float) width / w); float scaleHeight = ((float) height / h); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true); }
From source file:Main.java
public static Bitmap resizeBitmap(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scaleWidth = ((float) w) / width; float scaleHeight = ((float) h) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); }
From source file:Main.java
public static Bitmap toSepia(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight(); width = bmpOriginal.getWidth();//from www.j a va 2 s . com Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix grMatrix = new ColorMatrix(); grMatrix.setSaturation(0); ColorMatrix scMatrix = new ColorMatrix(); scMatrix.setScale(1f, .85f, .72f, 1.0f); grMatrix.setConcat(scMatrix, grMatrix); ColorMatrixColorFilter f = new ColorMatrixColorFilter(grMatrix); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; }
From source file:Main.java
public static Bitmap overlayToDownCenter(Bitmap bmp1, Bitmap bmp2) { Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig()); Canvas canvas = new Canvas(bmOverlay); canvas.drawBitmap(bmp1, new Matrix(), null); Matrix matrix = new Matrix(); matrix.setTranslate(((float) bmp1.getWidth() - bmp2.getWidth()) / 2, bmp1.getHeight() - bmp2.getHeight()); canvas.drawBitmap(bmp2, matrix, null); return bmOverlay; }