List of usage examples for android.graphics Rect height
public final int height()
From source file:Main.java
/** * calculates the approximate height of a text, depending on a demo text * avoid repeated calls (e.g. inside drawing methods) * * @param paint/*from w w w . ja v a 2 s . c o m*/ * @param demoText * @return */ public static int calcTextHeight(Paint paint, String demoText) { Rect r = new Rect(); paint.getTextBounds(demoText, 0, demoText.length(), r); return r.height(); }
From source file:Main.java
public static float calculateScale(Rect startBounds, Rect finalBounds) { float scale;/*from w w w . j a va 2 s . c om*/ if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { /* Extend start bounds horizontally*/ scale = (float) startBounds.height() / finalBounds.height(); float startWidth = scale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { /* Extend start bounds vertically*/ scale = (float) startBounds.width() / finalBounds.width(); float startHeight = scale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } return scale; }
From source file:Main.java
public static Bitmap crop(Bitmap bitmap, Rect cropRect) { return Bitmap.createBitmap(bitmap, cropRect.left, cropRect.top, cropRect.width(), cropRect.height()); }
From source file:Main.java
public static Bitmap resizeOuterFit(Bitmap src, Rect rect) { float aspectRatio = Math.max((float) rect.width() / src.getWidth(), (float) rect.height() / src.getHeight()); int newWidth = (int) (src.getWidth() * aspectRatio); int newHeight = (int) (src.getHeight() * aspectRatio); return Bitmap.createScaledBitmap(src, newWidth, newHeight, false); }
From source file:Main.java
public static int getWindowHeight(Activity activity) { Rect out = new Rect(); activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getHitRect(out); return out.height(); }
From source file:Main.java
public static Rect getBestFitRect(Bitmap bitmap, Rect destination) { return getBestFitRect(bitmap, (float) destination.width() / (float) destination.height()); }
From source file:Main.java
/** * to judge whether items take full page * if not ,even if last item is visible ,we should not call listener * * @return whether items take up full page *///from w w w .ja va 2 s . com public static boolean itemTakeFullPage(ListView list) { if (list.getChildCount() > 0) { int totalHeight = 0; for (int i = 0; i < list.getChildCount(); i++) { View child = list.getChildAt(i); Rect childRect = new Rect(); child.getDrawingRect(childRect); totalHeight += childRect.height(); } Rect visibleRect = new Rect(); list.getGlobalVisibleRect(visibleRect); return (visibleRect.bottom - visibleRect.top) - totalHeight < VISIBLE_SLOP; } return false; }
From source file:Main.java
static boolean validSurface(SurfaceHolder holder) { if (holder.getSurface() != null) { Rect r = holder.getSurfaceFrame(); System.out.println("ExoVlcUtil.validSurface() r = " + r); return (r.width() * r.height()) > 0; }/*from ww w .ja v a2s . c o m*/ return false; }
From source file:Main.java
public static Bitmap cropCenterInside(Bitmap src, Rect rect) { int width = Math.min(src.getWidth(), rect.width()); int height = Math.min(src.getHeight(), rect.height()); int[] rowData = new int[width]; int stride = src.getWidth(); int x = (src.getWidth() - width) / 2; int y = (src.getHeight() - height) / 2; Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); int delta = 0; while (delta < height) { src.getPixels(rowData, 0, stride, x, y + delta, width, 1); dest.setPixels(rowData, 0, stride, 0, delta, width, 1); delta++;/*from w w w. jav a2s .co m*/ } return dest; }
From source file:Main.java
/** * calculates the approximate height of a text, depending on a demo text * avoid repeated calls (e.g. inside drawing methods) * * @param paint/*w w w .java2s . c o m*/ * @param demoText * @return */ public static int calcTextHeight(Paint paint, String demoText) { Rect r = mCalcTextHeightRect; r.set(0, 0, 0, 0); paint.getTextBounds(demoText, 0, demoText.length(), r); return r.height(); }