List of usage examples for android.graphics Bitmap getHeight
public final int getHeight()
From source file:Main.java
public static Bitmap rotateBitmap(Bitmap origin, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle);// w w w . j ava 2 s . c om return Bitmap.createBitmap(origin, 0, 0, origin.getWidth(), origin.getHeight(), matrix, true); }
From source file:Main.java
public static int[] getPixels(final Bitmap bit) { if (bit == null) { return null; }//from w ww . ja v a 2 s . com int width = bit.getWidth(); int height = bit.getHeight(); int pixels[] = new int[width * height]; bit.getPixels(pixels, 0, width, 0, 0, width, height); return pixels; }
From source file:Main.java
public static Bitmap getDrawable(String path, int zoom, int mItemwidth, int mItemHerght) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;/*ww w . jav a 2 s.c om*/ BitmapFactory.decodeFile(path, options); int mWidth = options.outWidth; int mHeight = options.outHeight; int s = 1; while ((mWidth / s > mItemwidth * 2 * zoom) || (mHeight / s > mItemHerght * 2 * zoom)) { s *= 2; } options = new BitmapFactory.Options(); options.inPreferredConfig = Config.ARGB_8888; options.inSampleSize = s; Bitmap bm = BitmapFactory.decodeFile(path, options); if (bm != null) { int h = bm.getHeight(); int w = bm.getWidth(); float ft = (float) ((float) w / (float) h); float fs = (float) ((float) mItemwidth / (float) mItemHerght); int neww = ft >= fs ? mItemwidth * zoom : (int) (mItemHerght * zoom * ft); int newh = ft >= fs ? (int) (mItemwidth * zoom / ft) : mItemHerght * zoom; float scaleWidth = ((float) neww) / w; float scaleHeight = ((float) newh) / h; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); bm = Bitmap.createBitmap(bm, 0, 0, w, h, matrix, true); return bm; } return null; }
From source file:Main.java
public static Bitmap getMosaic(Bitmap bmpOriginal) { int width = bmpOriginal.getWidth(); int height = bmpOriginal.getHeight(); int sizeW = width / STEP; int sizeH = height / STEP; int resultW = sizeW * STEP; int resultH = sizeH * STEP; Bitmap bmpMosaic = Bitmap.createBitmap(resultW, resultH, Bitmap.Config.RGB_565); int col;/*w w w .ja va 2 s .c o m*/ for (int i = 0; i < sizeH; i++) for (int j = 0; j < sizeW; j++) { col = computeAverageColor(j, i, bmpOriginal); fillRigeon(col, j, i, bmpMosaic); } return bmpMosaic; }
From source file:Main.java
public static Bitmap cropJpgFile(String inFl, String outFl) throws IOException { Bitmap bmpIn = BitmapFactory.decodeFile(inFl); Bitmap bmOverlay = Bitmap.createBitmap(bmpIn.getWidth(), bmpIn.getHeight(), Bitmap.Config.ARGB_8888); Paint p = new Paint(); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); Canvas c = new Canvas(bmOverlay); c.drawBitmap(bmpIn, 0, 0, null);/*from w w w . j ava 2s . c o m*/ //c.drawRect(30, 30, 100, 100, p); File fileOut = new File(outFl); FileOutputStream out = new FileOutputStream(fileOut); bmOverlay = drawTextToBitmap(bmOverlay, "Image Viewer"); bmOverlay.compress(Bitmap.CompressFormat.JPEG, 100, out); return bmOverlay; }
From source file:Main.java
public static Bitmap cutImage(Bitmap src, int cutY) { //DLOG.d("choices", "cutImage!!"); int bit_x, bit_y, bit_width, bit_height; bit_y = cutY;/*from w w w.j ava 2s. c om*/ bit_height = src.getHeight() - 2 * bit_y; bit_width = bit_height * 10 / 16; bit_x = (src.getWidth() - bit_width) / 2 + 1; return Bitmap.createBitmap(src, bit_x, bit_y, bit_width, bit_height); }
From source file:Main.java
public static BitmapDrawable sizeChanger(Context context, ImageView imageView, int sizeOnDps, int orientation) { Drawable drawing = imageView.getDrawable(); if (drawing == null) { return null; }//from w w w .j ava 2 s.c om Bitmap bitmap = ((BitmapDrawable) drawing).getBitmap(); int width = bitmap.getWidth(); int height = bitmap.getHeight(); int bounding = dpToPx(250, context); float xScale = ((float) bounding) / width; float yScale = ((float) bounding) / height; float scale = (xScale <= yScale) ? xScale : yScale; Matrix matrix = new Matrix(); matrix.postScale(scale, scale); matrix.postRotate(orientation, imageView.getDrawable().getBounds().width() / 2, imageView.getDrawable().getBounds().height() / 2); Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); width = scaledBitmap.getWidth(); height = scaledBitmap.getHeight(); return new BitmapDrawable(scaledBitmap); }
From source file:Main.java
public static Bitmap imageRotate(Bitmap bitmap, int angle) { Matrix mat = new Matrix(); mat.postRotate(angle);//w w w .ja v a2s . c o m return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mat, true); }
From source file:Main.java
public static Bitmap reliefImage(Bitmap bm) { int width = bm.getWidth(); int height = bm.getHeight(); int color;/*from ww w .j ava 2 s . c o m*/ int r, g, b, a; Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); int[] oldPx = new int[width * height]; int[] newPx = new int[width * height]; bm.getPixels(oldPx, 0, width, 0, 0, width, height); for (int i = 1; i < oldPx.length; i++) { color = oldPx[i - 1]; r = Color.red(color); g = Color.green(color); b = Color.blue(color); a = Color.alpha(color); int nextColor = oldPx[i]; int r1 = Color.red(nextColor); int g1 = Color.green(nextColor); int b1 = Color.blue(nextColor); r = r1 - r + 127; g = g1 - g + 127; b = b1 - b + 127; if (r > 255) { r = 255; } else if (r < 0) { r = 0; } if (g > 255) { g = 255; } else if (g < 0) { g = 0; } if (b > 255) { b = 255; } else if (b < 0) { b = 0; } newPx[i] = Color.argb(a, r, g, b); } bitmap.setPixels(newPx, 0, width, 0, 0, width, height); return bitmap; }
From source file:Main.java
public static Bitmap RotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle);//from w w w . ja va 2 s. c o m return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); }