use of android.view.Display in project platform_frameworks_base by android.
the class WallpaperManagerService method getMaximumSizeDimension.
private int getMaximumSizeDimension() {
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
return d.getMaximumSizeDimension();
}
use of android.view.Display in project grafika by google.
the class MiscUtils method getDisplayRefreshNsec.
/**
* Obtains the approximate refresh time, in nanoseconds, of the default display associated
* with the activity.
* <p>
* The actual refresh rate can vary slightly (e.g. 58-62fps on a 60fps device).
*/
public static long getDisplayRefreshNsec(Activity activity) {
Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
double displayFps = display.getRefreshRate();
long refreshNs = Math.round(1000000000L / displayFps);
Log.d(TAG, "refresh rate is " + displayFps + " fps --> " + refreshNs + " ns");
return refreshNs;
}
use of android.view.Display in project QuickReturn by lawloretienne.
the class QuickReturnUtils method px2dp.
public static int px2dp(Context context, int px) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
DisplayMetrics displaymetrics = new DisplayMetrics();
display.getMetrics(displaymetrics);
return (int) (px / displaymetrics.density + 0.5f);
}
use of android.view.Display in project QuickReturn by lawloretienne.
the class QuickReturnUtils method dp2px.
public static int dp2px(Context context, int dp) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
DisplayMetrics displaymetrics = new DisplayMetrics();
display.getMetrics(displaymetrics);
return (int) (dp * displaymetrics.density + 0.5f);
}
use of android.view.Display in project LiveSDK-for-Android by liveservices.
the class SkyDriveActivity method extractScaledBitmap.
/**
* Extract a photo from SkyDrive and creates a scaled bitmap according to the device resolution, this is needed to
* prevent memory over-allocation that can cause some devices to crash when opening high-resolution pictures
*
* Note: this method should not be used for downloading photos, only for displaying photos on-screen
*
* @param photo The source photo to download
* @param imageStream The stream that contains the photo
* @return Scaled bitmap representation of the photo
* @see http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object/823966#823966
*/
private Bitmap extractScaledBitmap(SkyDrivePhoto photo, InputStream imageStream) {
Display display = getWindowManager().getDefaultDisplay();
int IMAGE_MAX_SIZE = Math.max(display.getWidth(), display.getHeight());
int scale = 1;
if (photo.getHeight() > IMAGE_MAX_SIZE || photo.getWidth() > IMAGE_MAX_SIZE) {
scale = (int) Math.pow(2, (int) Math.ceil(Math.log(IMAGE_MAX_SIZE / (double) Math.max(photo.getHeight(), photo.getWidth())) / Math.log(0.5)));
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
options.inSampleSize = scale;
return BitmapFactory.decodeStream(imageStream, (Rect) null, options);
}
Aggregations