android.graphics.Bitmap.getDensity()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中android.graphics.Bitmap.getDensity()方法的一些代码示例,展示了Bitmap.getDensity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.getDensity()方法的具体详情如下:
包路径:android.graphics.Bitmap
类名称:Bitmap
方法名:getDensity

Bitmap.getDensity介绍

暂无

代码示例

代码示例来源:origin: xinghongfei/LookLook

@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);
  }
}

代码示例来源:origin: square/assertj-android

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;
}

代码示例来源:origin: robolectric/robolectric

@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);
}

代码示例来源:origin: robolectric/robolectric

@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);
}

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: iQueSoft/iQuePhoto

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()
  );
}

代码示例来源:origin: huangfangyi/FanXin

@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);
  }
}

代码示例来源:origin: huangfangyi/YiChat

@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);
  }
}

代码示例来源:origin: sym900728/LockPattern

@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);
  }
}

代码示例来源:origin: Jasonchenlijian/MemorySpinner

@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);
  }
}

代码示例来源:origin: Jerey-Jobs/KeepGank

@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);
  }
}

代码示例来源:origin: liudao01/EventCollect

@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);
  }
}

代码示例来源:origin: xkzh/yduoduo

@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);
  }
}

代码示例来源:origin: wutq/AndroidModuleDemo

@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);
  }
}

代码示例来源:origin: YiChat/android_YiChat_Lite

@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);
  }
}

代码示例来源:origin: stackoverflow.com

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;
  }
}

代码示例来源:origin: com.squareup.assertj/assertj-android

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;
}

代码示例来源:origin: lijundacom/AndroidRTSPLib2

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);
}

代码示例来源:origin: trezor/trezor-android

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;
  }
}

代码示例来源:origin: trezor/trezor-android

/**
 * 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);
  }
}

相关文章