2011-05-16 120 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