@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd = new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
public BitmapAssert hasDensity(int density) { isNotNull(); int actualDensity = actual.getDensity(); assertThat(actualDensity) // .overridingErrorMessage("Expected density <%s> but was <%s>.", density, actualDensity) // .isEqualTo(density); return this; }
@Test @Config(minSdk = JELLY_BEAN_MR1) public void shouldSetDensity() { final Bitmap bitmap = Bitmap.createBitmap(new DisplayMetrics(), 100, 100, Bitmap.Config.ARGB_8888); bitmap.setDensity(1000); assertThat(bitmap.getDensity()).isEqualTo(1000); }
@Test @Config(minSdk = JELLY_BEAN_MR1) public void shouldCreateMutableBitmapWithDisplayMetrics() throws Exception { final DisplayMetrics metrics = new DisplayMetrics(); metrics.densityDpi = 1000; final Bitmap bitmap = Bitmap.createBitmap(metrics, 100, 100, Bitmap.Config.ARGB_8888); assertThat(bitmap.isMutable()).isTrue(); assertThat(bitmap.getDensity()).isEqualTo(1000); }
File camDir = new File(Environment.getExternalStorageDirectory().getAbsoluteFile() + "/DCIM/Camera"); File[] files = camDir.listFiles(); FileInputStream FI = new FileInputStream (files[1].getAbsolutePath()); Bitmap img = BitmapFactory.decodeStream(FI); img.getDensity();
public static void logBitmap(@NonNull String prefix, @NonNull Bitmap bitmap) { Log.i(TAG, "Bitmap - " + prefix + " -->" + "\n" + "Height = " + bitmap.getHeight() + "\n" + "Width = " + bitmap.getWidth() + "\n" + "Density = " + bitmap.getDensity() ); }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd=new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd = new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd=new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd=new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") public static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd = new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd=new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd=new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd = new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
@SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } BitmapDrawable bd = new BitmapDrawable(bm); bd.setTargetDensity(bm.getDensity()); return new BitmapDrawable(bm); } }
protected Bitmap adjustImage(Bitmap image) { int dpi = image.getDensity(); if (dpi == mDpi) return image; else { int width = (image.getWidth() * mDpi + dpi / 2) / dpi; int height = (image.getHeight() * mDpi + dpi / 2) / dpi; Bitmap adjustedImage = Bitmap.createScaledBitmap(image, width, height, true); adjustedImage.setDensity(mDpi); return adjustedImage; } }
public BitmapAssert hasDensity(int density) { isNotNull(); int actualDensity = actual.getDensity(); assertThat(actualDensity) // .overridingErrorMessage("Expected density <%s> but was <%s>.", density, actualDensity) // .isEqualTo(density); return this; }
private void GetMP4Info(){ MediaMetadataRetriever retr = new MediaMetadataRetriever(); try { retr.setDataSource(VIDEO_PATH); }catch (Exception e){ return; } Bitmap bm = retr.getFrameAtTime(); mFileWidth = bm.getWidth(); mFileHeight = bm.getHeight(); mFileDensity = bm.getDensity(); Log.v(TAG,"mScreenWidth is :"+mScreenWidth+";mScreenHeight is :"+mScreenHeight+"mScreenDensity is :"+mScreenDensity); }
public static CmnIcon create(LargeHash iconId, Bitmap bitmap, boolean cachePersist) { CmnIcon ret = BitmapUtils.getIcon(iconId, bitmap.getDensity()); if (ret != null) return ret; else { ret = new CmnIcon(iconId, bitmap); BitmapUtils.addIcon(ret, cachePersist); return ret; } }
/** * Pokud je true, tak se ikona perzistuje do souboru (pouziti u online dat) - ZATIM NEIMPLEMENTOVANO! */ public static void addIcon(CmnIcon icon, boolean persist) { if (persist) throw new RuntimeException("Not implemented"); synchronized (cache) { cache.put(new BitmapKey(icon.getIconId(), icon.getBitmap().getDensity()), icon); } }