安卓判断bitmap是否相等
2024-06-24 本文已影响0人
不会弹钢琴de大叔
public static boolean isSameBitmap(Bitmap bitmap1, Bitmap bitmap2) {
ByteBuffer buffer1 = ByteBuffer.allocate(bitmap1.getHeight() * bitmap1.getRowBytes());
bitmap1.copyPixelsToBuffer(buffer1);
ByteBuffer buffer2 = ByteBuffer.allocate(bitmap2.getHeight() * bitmap2.getRowBytes());
bitmap2.copyPixelsToBuffer(buffer2);
boolean equals = Arrays.equals(buffer1.array(), buffer2.array());
Log.d("ZHJ++", "zhj isSameBitmap: " + equals);
return equals;
}