Example usage for android.graphics Point Point

List of usage examples for android.graphics Point Point

Introduction

In this page you can find the example usage for android.graphics Point Point.

Prototype

public Point(int x, int y) 

Source Link

Usage

From source file:Main.java

/**
 * Returns the screen/display size/*  www  . ja v  a2s  .  c om*/
 *
 * @param context
 * @return
 */
@SuppressWarnings("deprecation")
public static Point getDisplaySize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    return new Point(width, height);
}

From source file:Main.java

public static Point getScreenSize(Context context) {
    if (screenSize != null) {
        return screenSize;
    }//w w  w.j  a va  2 s  . c  o  m
    int pxWidth;
    int pxHeight;

    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    pxWidth = display.getWidth();
    pxHeight = display.getHeight();

    screenSize = new Point(pxWidth, pxHeight);
    return screenSize;
}

From source file:Main.java

public static Point getBitmapSize(String path) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;//from  www .  j av  a  2s.  c  om
    decodeFile(path, options);
    int realWidth = options.outWidth;
    int realHeight = options.outHeight;

    Log.d("loadimage", "realWidth: " + realWidth);
    Log.d("loadimage", "realHeight: " + realHeight);

    return new Point(realWidth, realHeight);
}

From source file:Main.java

/**
 * get image size by path/*from  w  w w . j  av  a2  s.com*/
 */
public static Point getImageSize(String path) throws IOException {
    if (TextUtils.isEmpty(path)) {
        return null;
    }
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    if (path.startsWith("http")) {
        BitmapFactory.decodeStream(new URL(path).openStream(), null, options);
    } else {
        BitmapFactory.decodeFile(path, options);
    }
    return new Point(options.outWidth, options.outHeight);
}

From source file:Main.java

public static Point getCameraResolution(android.hardware.Camera.Parameters parameters, Point screenResolution) {
    String previewSizeValueString = parameters.get("preview-size-values");
    if (previewSizeValueString == null) {
        previewSizeValueString = parameters.get("preview-size-value");
    }//  w w w . j  a v  a  2s  . c om

    Point cameraResolution = null;
    if (previewSizeValueString != null) {
        cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution);
    }
    if (cameraResolution == null) {
        cameraResolution = new Point((screenResolution.x >> 3) << 3, (screenResolution.y >> 3) << 3);
    }

    return cameraResolution;
}

From source file:Main.java

public static Point getScreenSize() {
    DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
    return new Point(displayMetrics.widthPixels, displayMetrics.heightPixels);
}

From source file:Main.java

public static Point getBitmapSize(InputStream is) {
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inJustDecodeBounds = true;/*from  w ww . j av  a 2  s  . com*/
    BitmapFactory.decodeStream(is, null, opt);
    int x = opt.outWidth;
    int y = opt.outHeight;
    Point p = new Point(x, y);
    return p;
}

From source file:Main.java

/** Convert coordination of face point to screen rect that will be draw on canvas<br> */
public static List<Point> convertFacePoint(boolean frontCamera, float displayOrientation, float viewWidth,
        float viewHeight, Point... points) {
    Matrix matrix = createConvertMatrix(frontCamera, displayOrientation, viewWidth, viewHeight);
    float[] pts = new float[points.length * 2];
    for (int i = 0; i < points.length; ++i) {
        pts[i * 2] = points[i].x;/*  w  w  w .j a  v  a  2 s . c  o m*/
        pts[i * 2 + 1] = points[i].y;
    }
    matrix.mapPoints(pts);
    List<Point> result = new LinkedList<>();
    for (int j = 0; j < pts.length; j += 2) {
        result.add(new Point((int) pts[j], (int) pts[j + 1]));
    }
    return result;
}

From source file:Main.java

public static Point getImageSize(String filePath) {
    try {//from ww w  .j  a  va 2s  .  c o m
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, options);
        return new Point(options.outWidth, options.outHeight);
    } catch (OutOfMemoryError ignored) {
    } catch (Exception ignored) {
    }

    return new Point(0, 0);
}

From source file:Main.java

public static void initDiplaySize(Activity context) {
    if (screenWidth > 0 && screenHeight > 0)
        return;/*from  w  ww  .j a v  a2s.  c o m*/

    Display dis = context.getWindowManager().getDefaultDisplay();
    Point outSize = new Point(0, 0);
    dis.getSize(outSize);
    if (outSize != null) {
        screenWidth = outSize.x;
        screenHeight = outSize.y;
    }
}