Search in sources :

Example 6 with Display

use of android.view.Display in project OpenPanodroid by duerrfk.

the class PanoViewerActivity method convertCubicPano.

private void convertCubicPano() {
    Assert.assertTrue(pano != null);
    Log.i(LOG_TAG, "Converting panorama ...");
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String str = prefs.getString("textureSize", "");
    int maxTextureSize = GlobalConstants.DEFAULT_MAX_TEXTURE_SIZE;
    if (!str.equals("")) {
        try {
            maxTextureSize = Integer.parseInt(str);
        } catch (NumberFormatException ex) {
            maxTextureSize = GlobalConstants.DEFAULT_MAX_TEXTURE_SIZE;
        }
    }
    // On the one hand, we don't want to waste memory for textures whose resolution 
    // is too large for the device. On the other hand, we want to have a resolution
    // that is high enough to give us good quality on any device. However, we don't
    // know the resolution of the GLView a priori, and it could be resized later.
    // Therefore, we use the display size to calculate the optimal texture size.
    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    int maxDisplaySize = width > height ? width : height;
    int optimalTextureSize = getOptimalFaceSize(maxDisplaySize, pano.getWidth(), GlobalConstants.DEFAULT_FOV_DEG);
    int textureSize = toPowerOfTwo(optimalTextureSize);
    textureSize = textureSize <= maxTextureSize ? textureSize : maxTextureSize;
    Log.i(LOG_TAG, "Texture size: " + textureSize + " (optimal size was " + optimalTextureSize + ")");
    panoConversionTask = new PanoConversionTask(textureSize);
    panoConversionTask.execute(pano);
}
Also used : SharedPreferences(android.content.SharedPreferences) Display(android.view.Display) WindowManager(android.view.WindowManager)

Example 7 with Display

use of android.view.Display in project AnimeTaste by daimajia.

the class DensityUtils method getScreenHeight.

@SuppressWarnings("deprecation")
public static int getScreenHeight(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    return display.getHeight();
}
Also used : WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 8 with Display

use of android.view.Display in project barcodescanner by dm77.

the class CameraPreview method getDisplayOrientation.

public int getDisplayOrientation() {
    if (mCameraWrapper == null) {
        //If we don't have a camera set there is no orientation so return dummy value
        return 0;
    }
    Camera.CameraInfo info = new Camera.CameraInfo();
    if (mCameraWrapper.mCameraId == -1) {
        Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, info);
    } else {
        Camera.getCameraInfo(mCameraWrapper.mCameraId, info);
    }
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    int rotation = display.getRotation();
    int degrees = 0;
    switch(rotation) {
        case Surface.ROTATION_0:
            degrees = 0;
            break;
        case Surface.ROTATION_90:
            degrees = 90;
            break;
        case Surface.ROTATION_180:
            degrees = 180;
            break;
        case Surface.ROTATION_270:
            degrees = 270;
            break;
    }
    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        // compensate the mirror
        result = (360 - result) % 360;
    } else {
        // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }
    return result;
}
Also used : Camera(android.hardware.Camera) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 9 with Display

use of android.view.Display in project barcodescanner by dm77.

the class DisplayUtils method getScreenResolution.

public static Point getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point screenResolution = new Point();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        display.getSize(screenResolution);
    } else {
        screenResolution.set(display.getWidth(), display.getHeight());
    }
    return screenResolution;
}
Also used : Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 10 with Display

use of android.view.Display in project UltimateRecyclerView by cymcsg.

the class GridLayoutRVTest method dimension_columns.

private void dimension_columns() {
    Display display = getWindowManager().getDefaultDisplay();
    DisplayMetrics outMetrics = new DisplayMetrics();
    display.getMetrics(outMetrics);
    float density = getResources().getDisplayMetrics().density;
    float dpWidth = outMetrics.widthPixels / density;
    columns = Math.round(dpWidth / 300);
}
Also used : DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display)

Aggregations

Display (android.view.Display)468 Point (android.graphics.Point)224 WindowManager (android.view.WindowManager)193 DisplayMetrics (android.util.DisplayMetrics)75 SuppressLint (android.annotation.SuppressLint)28 Resources (android.content.res.Resources)25 Bitmap (android.graphics.Bitmap)25 LinearLayout (android.widget.LinearLayout)25 Rect (android.graphics.Rect)23 View (android.view.View)23 RemoteException (android.os.RemoteException)22 Canvas (android.graphics.Canvas)21 Method (java.lang.reflect.Method)21 VirtualDisplay (android.hardware.display.VirtualDisplay)20 TextView (android.widget.TextView)18 Dialog (android.app.Dialog)17 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 ViewGroup (android.view.ViewGroup)16 ImageView (android.widget.ImageView)15