hidden api sameAs() to compare the pixels of 2 bitmaps for equality

This commit is contained in:
Mike Reed
2010-03-05 17:42:30 -05:00
parent 43dcdb2ec5
commit 76d1e01d5e
2 changed files with 63 additions and 1 deletions

View File

@@ -971,6 +971,19 @@ public final class Bitmap implements Parcelable {
return bm;
}
/**
* Given another bitmap, return true if it has the same dimensions, config,
* and pixel data as this bitmap. If any of those differ, return false.
* If other is null, return false.
*
* @hide (just needed internally right now)
*/
public boolean sameAs(Bitmap other) {
return this == other ||
(other != null &&
nativeSameAs(mNativeBitmap, other.mNativeBitmap));
}
/**
* Rebuilds any caches associated with the bitmap that are used for
* drawing it. In the case of purgeable bitmaps, this call will attempt to
@@ -1042,6 +1055,7 @@ public final class Bitmap implements Parcelable {
private static native void nativePrepareToDraw(int nativeBitmap);
private static native void nativeSetHasAlpha(int nBitmap, boolean hasAlpha);
private static native boolean nativeSameAs(int nb0, int nb1);
/* package */ final int ni() {
return mNativeBitmap;