2011-05-16 153 views
1

有没有办法查找这种方法的实现/源代码?它在API中需要这样来比较两个图像,因为它会覆盖原始图像,并且在将图像视图转换为位图多次后,图像看起来不再漂亮。 http://developer.android.com/reference/android/graphics/Bitmap.html#sameAs(android.graphics.Bitmap)位图图像比较

我正在做这种方法从图像创建一个位图,并将其设置为一个ImageView,让用户编辑他的图片。

public static Bitmap getBitmap(ImageView imageView) { 

    BitmapDrawable mDrawable = (BitmapDrawable) imageView.getDrawable(); 

    Bitmap b = mDrawable.getBitmap(); 
    return b; 
} 

然而,在保存和从数据库中检索它来编辑它的好几倍,将图像从这个变成:enter image description here

这样: enter image description here

,最后这一点: enter image description here

所以我需要一种方法来检测图像是否没有改变,我不重新保存这个位图的字节数组到t他数据库。

+0

能否请您详细说明,因为我没有帮你吗? – 2011-05-16 11:11:52

+0

基本上我需要一种方法来比较两个位图图像,无论是逐个像素还是整个位图。 – louieansonng 2011-05-16 11:34:10

+0

@ louieansonng你有什么解决方案吗? – dipali 2015-12-21 10:12:12

回答

1

EDIT(基于其他信息)

你可能保存图像为JPEG,这是一种有损格式。每次你节省,你都会失去质量。如果多次加载并保存图像,请使用PNG或使用文本保留图像文本的另一个副本 - 当需要更新图像时,再次从原始图像开始。

OLD答:

它可能有无关sameAs的,而在其他地方,你在做什么来改变形象。

来源这里https://android.googlesource.com

sameAs是用C语言实现JNI的功能,你可以在这里找到:
https://android.googlesource.com/platform/frameworks/base/+/master/core/jni/android/graphics/Bitmap.cpp

+0

我正在考虑使用sameAs来检查两个图像是否相同,而不是实现我自己的 – louieansonng 2011-05-16 11:34:47