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

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

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

Bitmap.sameAs介绍

暂无

代码示例

代码示例来源:origin: Yalantis/uCrop

public static Bitmap transformBitmap(@NonNull Bitmap bitmap, @NonNull Matrix transformMatrix) {
  try {
    Bitmap converted = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), transformMatrix, true);
    if (!bitmap.sameAs(converted)) {
      bitmap = converted;
    }
  } catch (OutOfMemoryError error) {
    Log.e(TAG, "transformBitmap: ", error);
  }
  return bitmap;
}

代码示例来源:origin: steelkiwi/cropiwa

private static Bitmap transformBitmap(@NonNull Bitmap bitmap, @NonNull Matrix transformMatrix) {
  Bitmap result = bitmap;
  try {
    Bitmap converted = Bitmap.createBitmap(
        bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(),
        transformMatrix,
        true);
    if (!bitmap.sameAs(converted)) {
      result = converted;
      bitmap.recycle();
    }
  } catch (OutOfMemoryError error) {
    CropIwaLog.e(error.getMessage(), error);
  }
  return result;
}

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

@Test
public void sameAs_bitmapsSamePixels() {
 int[] pixels = new int[] {0, 1, 2, 3};
 Bitmap original1 = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888);
 original1.setPixels(pixels, 0, 1, 0, 0, 2, 2);
 Bitmap original2 = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888);
 original2.setPixels(pixels, 0, 1, 0, 0, 2, 2);
 assertThat(original1.sameAs(original2)).isTrue();
}

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

@Test
public void sameAs_bitmapsDifferentPixels() {
 int[] pixels1 = new int[] {0, 1, 2, 3};
 Bitmap original1 = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888);
 original1.setPixels(pixels1, 0, 1, 0, 0, 2, 2);
 int[] pixels2 = new int[] {3, 2, 1, 0};
 Bitmap original2 = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888);
 original2.setPixels(pixels2, 0, 1, 0, 0, 2, 2);
 assertThat(original1.sameAs(original2)).isFalse();
}

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

@Test
public void sameAs_bitmapsDifferentHeight() {
 Bitmap original1 = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 Bitmap original2 = Bitmap.createBitmap(100, 101, Bitmap.Config.ARGB_8888);
 assertThat(original1.sameAs(original2)).isFalse();
}

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

@Test
public void sameAs_bitmapsDifferentConfig() {
 Bitmap original1 = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 Bitmap original2 = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_4444);
 assertThat(original1.sameAs(original2)).isFalse();
}

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

@Test
public void sameAs_bitmapsDifferentWidth() {
 Bitmap original1 = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 Bitmap original2 = Bitmap.createBitmap(101, 100, Bitmap.Config.ARGB_8888);
 assertThat(original1.sameAs(original2)).isFalse();
}

代码示例来源:origin: JakeWharton/butterknife

@Test public void asBitmap() {
  Target target = new Target();
  Bitmap expected = BitmapFactory.decodeResource(context.getResources(), R.drawable.pixel);

  Unbinder unbinder = new BindBitmapTest$Target_ViewBinding(target, context);
  assertTrue(target.actual.sameAs(expected));

  unbinder.unbind();
  assertTrue(target.actual.sameAs(expected));
 }
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

final BitmapDrawable endDrawable = (BitmapDrawable) endVals.get(PROPNAME_DRAWABLE);
if (Transition.DBG) {
  Log.d(LOG_TAG, "StartBitmap.sameAs(endBitmap) = " + startBitmap.sameAs(endBitmap) +
      " for start, end: " + startBitmap + ", " + endBitmap);
if (startDrawable != null && endDrawable != null && !startBitmap.sameAs(endBitmap)) {
  ViewGroupOverlayUtils.addCrossfadeOverlay(useParentOverlay, view,
      mFadeBehavior, startDrawable, endDrawable);

代码示例来源:origin: bumptech/glide

public void sameAs(Bitmap other) {
 if (!actual().sameAs(other)) {
  fail("is the same as " + getDisplayString(other));
 }
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

final BitmapDrawable endDrawable = (BitmapDrawable) endVals.get(PROPNAME_DRAWABLE);
if (startDrawable != null && endDrawable != null && !startBitmap.sameAs(endBitmap)) {
  ViewOverlay overlay = useParentOverlay ?
      ((ViewGroup) view.getParent()).getOverlay() : view.getOverlay();

代码示例来源:origin: bumptech/glide

public void isNotSameAs(Bitmap other) {
  if (actual().sameAs(other)) {
   fail("is not the same as " + getDisplayString(other));
  }
 }
}

代码示例来源:origin: CameraKit/blurkit-android

@Test
  public void blurTest() {
    blur1 = blurKit.blur(blur1, 10);
    blur2 = blurKit.blur(blur2, 10);

    assertTrue(blur1.sameAs(blur2));
    assertFalse(blur1.sameAs(original));
  }
}

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

Bitmap BitRed = ((BitmapDrawable)getResources().getDrawable(R.drawable.redsquare)).getBitmap();

Bitmap BitClick = ((BitmapDrawable) v.getBackground()).getBitmap();

if (BitClick.sameAs(BitRed)) 
{ 
  //Your Button with Red Square Clicked
}

代码示例来源:origin: Swati4star/Images-to-PDF

private void checkAndAddIfBitmapExists(Bitmap bitmap, int position) {
  Boolean add = true;
  for (Bitmap b : mBitmaps) {
    if (b.sameAs(bitmap))
      add = false;
  }
  if (add) {
    mBitmaps.add(bitmap);
    mSequence.append(position).append(",");
  }
}

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

//comapre objects returns false
   Log.i("EQ", (imageList.get(0).getDrawable().equals(imageList.get(1).getDrawable())) + "");
   Log.i("EQ", imageList.get(0).getDrawable().toString()); //android.graphics.drawable.BitmapDrawable@89c323c
   Log.i("EQ", imageList.get(1).getDrawable().toString()); //android.graphics.drawable.BitmapDrawable@837dbc5
   BitmapDrawable bitmapDrawable0 = ((BitmapDrawable) imageList.get(0).getDrawable());
   Bitmap bitmap0 = bitmapDrawable0 .getBitmap();
   BitmapDrawable bitmapDrawable1 = ((BitmapDrawable) imageList.get(1).getDrawable());
   Bitmap bitmap1 = bitmapDrawable1 .getBitmap();
   //comapre the image returns true
   Log.i("EQ2", Boolean.toString(bitmap0.sameAs(bitmap1)));

代码示例来源:origin: pruas/Biscuit

private Bitmap transformBitmap(@NonNull Bitmap bitmap, @NonNull Matrix transformMatrix) {
    try {
      Bitmap converted = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), transformMatrix, false);
      if (!bitmap.sameAs(converted)) {
        bitmap = converted;
      }
    } catch (OutOfMemoryError error) {
      log(TAG, "transformBitmap: " + error);
    }
    return bitmap;
  }
}

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

public void onBackPressed(@NonNull Bitmap alteredBitmap) {
  if (!mBitmap.sameAs(alteredBitmap)) {
    getViewState().showAlertDialog();
  } else {
    getViewState().navigateBack(false);
  }
}

代码示例来源:origin: derry/delion

/**
 * Sets the poster bitmap to display on the TransportControl.
 */
public final void setPosterBitmap(Bitmap posterBitmap) {
  if (mPosterBitmap == posterBitmap
      || (mPosterBitmap != null && mPosterBitmap.sameAs(posterBitmap))) {
    return;
  }
  mPosterBitmap = posterBitmap;
  if (mNotificationBuilder == null || mMediaRouteController == null) return;
  mNotificationBuilder.setLargeIcon(mMediaRouteController.getPoster());
  updateNotification();
}

代码示例来源:origin: kinecosystem/kin-ecosystem-android-sdk

@Test
public void saveAndLoad() throws Exception {
  Bitmap bitmap = TestUtils.loadBitmapFromResource(this.getClass(), "qr_test.png");
  Uri uri = fileUriHandler.saveFile(bitmap);
  Bitmap loadedBitmap = fileUriHandler.loadFile(uri);
  assertThat(bitmap.sameAs(loadedBitmap), equalTo(true));
}

相关文章