List of usage examples for android.graphics Canvas getMaximumBitmapWidth
public int getMaximumBitmapWidth()
From source file:Main.java
/** * This method calculates maximum size of both width and height of bitmap. * It is twice the device screen diagonal for default implementation (extra quality to zoom image). * Size cannot exceed max texture size.//from w w w . ja v a2 s . c om * * @return - max bitmap size in pixels. */ @SuppressWarnings({ "SuspiciousNameCombination", "deprecation" }) public static int calculateMaxBitmapSize(@NonNull Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); int width, height; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); width = size.x; height = size.y; } else { width = display.getWidth(); height = display.getHeight(); } int screenDiagonal = (int) Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); Canvas canvas = new Canvas(); return Math.min(screenDiagonal * 2, Math.min(canvas.getMaximumBitmapWidth(), canvas.getMaximumBitmapHeight())); }
From source file:ecust.news.myWidgetTabPageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); ////w ww .j a va2s . c o m int w = Global.dimenConvert.dip2px(dp_FocusedLineHeight) / 2; int y = canvas.getHeight() - w / 2; paint.setColor(Color.WHITE); paint.setStrokeWidth(w); canvas.drawLine(0, y, canvas.getMaximumBitmapWidth(), y, paint); }
From source file:com.hippo.largeimageview.LargeImageView.java
private int getMaxBitmapSize(Canvas canvas) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { int maxSize = Math.min(canvas.getMaximumBitmapWidth(), canvas.getMaximumBitmapHeight()); // If hardware acceleration is not enabled, // getMaximumBitmapWidth() and getMaximumBitmapHeight() // will return Integer.MAX_VALUE. // In that case, use 2048 as default. if (maxSize == Integer.MAX_VALUE) { maxSize = 2048;/*from ww w .j ava 2s .c o m*/ } return maxSize; } else { // Before ICE_CREAM_SANDWICH, hardware acceleration is not supported, // bitmap max size is not limited. // Use 2048 as default. return 2048; } }