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

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

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

Bitmap.isPremultiplied介绍

暂无

代码示例

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

@TargetApi(JELLY_BEAN_MR1)
public BitmapAssert isPremultiplied() {
 isNotNull();
 assertThat(actual.isPremultiplied()) //
   .overridingErrorMessage("Expected to be premultiplied but was not premultiplied.") //
   .isTrue();
 return this;
}

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

@TargetApi(JELLY_BEAN_MR1)
public BitmapAssert isNotPremultiplied() {
 isNotNull();
 assertThat(actual.isPremultiplied()) //
   .overridingErrorMessage("Expected to not be premultiplied but was premultiplied.") //
   .isFalse();
 return this;
}

代码示例来源:origin: Bilibili/DanmakuFlameMaster

boolean result = (bitmap != null && bitmap.getWidth() == 2 && bitmap.getHeight() == 2);
if (result) {
  if (android.os.Build.VERSION.SDK_INT >= 17 && !bitmap.isPremultiplied()) {
    bitmap.setPremultiplied(true);
  canvas.drawText("TestLib", 0, 0, paint);
  if (android.os.Build.VERSION.SDK_INT >= 17) {
    result = bitmap.isPremultiplied();

代码示例来源:origin: Bilibili/DanmakuFlameMaster

private void accessBitmap(Bitmap bitmap) {
  boolean result = (bitmap != null && bitmap.getWidth() == BITMAP_WIDTH && bitmap.getHeight() == BITMAP_HEIGHT);
  if (result) {
    if (android.os.Build.VERSION.SDK_INT >= 17 && !bitmap.isPremultiplied()) {
      bitmap.setPremultiplied(true);
    }
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setColor(Color.RED);
    paint.setTextSize(20f);
    canvas.drawRect(0f, 0f, (float) bitmap.getWidth(), (float) bitmap.getHeight(),
        paint);
    canvas.drawText("TestLib", 0, 0, paint);
  }
}

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

@Config(sdk = Build.VERSION_CODES.KITKAT)
@Test
public void setPremultiplied() {
 Bitmap original = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 assertThat(original.isPremultiplied()).isFalse();
 original.setPremultiplied(true);
 assertThat(original.isPremultiplied()).isTrue();
 original.setPremultiplied(false);
 assertThat(original.isPremultiplied()).isFalse();
}

代码示例来源:origin: ChillingVan/android-openGL-canvas

protected void throwIfCannotDraw(Bitmap bitmap) {
  if (bitmap.isRecycled()) {
    throw new RuntimeException("Canvas: trying to use a recycled bitmap " + bitmap);
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    if (!bitmap.isPremultiplied() && bitmap.getConfig() == Bitmap.Config.ARGB_8888 &&
        bitmap.hasAlpha()) {
      throw new RuntimeException("Canvas: trying to use a non-premultiplied bitmap "
          + bitmap);
    }
  }
}

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

protected static void throwIfCannotDraw(Bitmap bitmap) {
  if (bitmap.isRecycled()) {
    throw new RuntimeException("Canvas: trying to use a recycled bitmap " + bitmap);
  }
  if (!bitmap.isPremultiplied() && bitmap.getConfig() == Bitmap.Config.ARGB_8888 &&
      bitmap.hasAlpha()) {
    throw new RuntimeException("Canvas: trying to use a non-premultiplied bitmap "
        + bitmap);
  }
}

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

@TargetApi(JELLY_BEAN_MR1)
public BitmapAssert isPremultiplied() {
 isNotNull();
 assertThat(actual.isPremultiplied()) //
   .overridingErrorMessage("Expected to be premultiplied but was not premultiplied.") //
   .isTrue();
 return this;
}

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

@TargetApi(JELLY_BEAN_MR1)
public BitmapAssert isNotPremultiplied() {
 isNotNull();
 assertThat(actual.isPremultiplied()) //
   .overridingErrorMessage("Expected to not be premultiplied but was premultiplied.") //
   .isFalse();
 return this;
}

代码示例来源:origin: jbruchanov/AnUitor

@Override
  protected HashMap<String, Object> fillValues(Bitmap b, HashMap<String, Object> data, HashMap<String, Object> contextData) {

    data.put("DescribeContents", b.describeContents());
    data.put("Config", String.valueOf(b.getConfig()));
    data.put("Density", b.getDensity());
    data.put("Height", b.getHeight());
    data.put("NinePatchChunk", Arrays.toString(b.getNinePatchChunk()));
    data.put("RowBytes", b.getRowBytes());
    data.put("Width", b.getWidth());
    data.put("HasAlpha", b.hasAlpha());
    data.put("IsMutable", b.isMutable());
    data.put("IsRecycled", b.isRecycled());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      data.put("AllocationByteCount", b.getAllocationByteCount());
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
      data.put("ByteCount", b.getByteCount());
      data.put("GenerationId", b.getGenerationId());
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      data.put("HasMipMap", b.hasMipMap());
      data.put("IsPremultiplied", b.isPremultiplied());
    }

    return data;
  }
}

代码示例来源:origin: chengzichen/KrGallery

bitmap.setHasAlpha(source.hasAlpha());
if (Build.VERSION.SDK_INT >= 19) {
  bitmap.setPremultiplied(source.isPremultiplied());

相关文章