List of usage examples for android.graphics Bitmap getWidth
public final int getWidth()
From source file:Main.java
public static Bitmap scaleBitmap(Bitmap bitmap, float scale) { return resizeBitmap(bitmap, (int) (bitmap.getWidth() * scale), (int) (bitmap.getHeight() * scale)); }
From source file:Main.java
public static Bitmap scaleExistingBitmap(Bitmap bm, float scaleWidth, float scaleHeight) { int width = bm.getWidth(); int height = bm.getHeight(); Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); return resizedBitmap; }
From source file:Main.java
private static Bitmap resizeBitmap(Bitmap bmp, float width, float height) { float xscale = width / bmp.getWidth(); float yscale = height / bmp.getHeight(); Matrix matrix = new Matrix(); // resize original image matrix.postScale(xscale, yscale);// www .j av a 2 s . com Bitmap dstbmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); return dstbmp; }
From source file:Main.java
public static Bitmap blurLight(Context context, Bitmap image) { int width = Math.round(image.getWidth() * BITMAP_SCALE_LIGHT); int height = Math.round(image.getHeight() * BITMAP_SCALE_LIGHT); Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false); Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap); RenderScript rs = RenderScript.create(context); ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap); Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap); theIntrinsic.setRadius(BLUR_RADIUS_LIGHT); theIntrinsic.setInput(tmpIn);//from w w w.j a va2 s. c om theIntrinsic.forEach(tmpOut); tmpOut.copyTo(outputBitmap); return outputBitmap; }
From source file:Main.java
public static Bitmap setupFrame(Bitmap bitmap, int width, int color) { if (bitmap.getWidth() <= width * 2 || bitmap.getHeight() <= width * 2) { return bitmap; }// w ww . j ava2s . c o m Bitmap bp = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bp); canvas.drawBitmap(bitmap, 0, 0, new Paint()); Paint paint = new Paint(); paint.setColor(color); paint.setStrokeWidth(width); paint.setStyle(Style.STROKE); canvas.drawRect(0, 0, canvas.getWidth() - width, canvas.getHeight() - width, paint); bitmap.recycle(); return bp; }
From source file:Main.java
public static Bitmap overlay(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); canvas.drawBitmap(bmp2, 0, 0, null); return bmOverlay; }
From source file:Main.java
public static Bitmap getImageThumbnail(Bitmap input) { int desiredWidth = 500; Float width = new Float(input.getWidth()); Float height = new Float(input.getHeight()); Float ratio = width / height; return Bitmap.createScaledBitmap(input, (int) (desiredWidth * ratio), desiredWidth, false); }
From source file:Main.java
public static Bitmap GetBitmapClippedCircle(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Bitmap outputBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Path path = new Path(); path.addCircle((float) (width / 2), (float) (height / 2), (float) Math.min(width, (height / 2)), Path.Direction.CCW);// ww w . j a va 2 s .c o m Canvas canvas = new Canvas(outputBitmap); canvas.clipPath(path); canvas.drawBitmap(bitmap, 0, 0, null); return outputBitmap; }
From source file:Main.java
public static Bitmap revertImage(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, 0, 0, 1, 1, 0, -1, 0, 1, 1, 0, 0, -1, 1, 1, 0, 0, 0, 1, 0 }; ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.set(matrixs);/* w w w .j a va 2s .c o m*/ paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); canvas.drawBitmap(bm, 0, 0, paint); return bitmap; }
From source file:Main.java
public static Bitmap doInvert(Bitmap src) { Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig()); int A, R, G, B; int pixelColor; int w = src.getWidth(); int h = src.getHeight(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { pixelColor = src.getPixel(x, y); A = Color.alpha(pixelColor); R = 255 - Color.red(pixelColor); G = 255 - Color.green(pixelColor); B = 255 - Color.blue(pixelColor); bmOut.setPixel(x, y, Color.argb(A, R, G, B)); }/*from www . j a va 2 s. co m*/ } return bmOut; }