2014-03-13 46 views
0
Bitmap foto = b.getBitmap(); 

byte[] bytes = null; 
ByteArrayOutputStream ba = new ByteArrayOutputStream(); 
foto.compress(Bitmap.CompressFormat.JPEG, 100, ba); 
foto.recycle(); 
foto = null; 

bytes = ba.toByteArray(); 

String bBytes = Arrays.toString(bytes); 

我想這個方法返回字節值的字符串。例如,它將是:"12,23,34 ...."將字節數組轉換爲字符串 - - 使用Performace Android

+0

所以你期望人們首先__translate__你的問題? – devnull

+0

我試圖解決我在他的問題中理解的內容。 – Manitoba

+0

你用這種方法表示哪種方法?! – mok

回答

1

這裏是你如何做到這一點。

import java.util.Arrays; 

public class Test { 

    public static void main(String[] args) { 
     byte[] bytes = {1,2,3,12}; 
     String bBytes = Arrays.toString(bytes); 
     bBytes = bBytes.replaceAll(" ", ""); 
     bBytes = bBytes.replaceAll("\\[", ""); 
     bBytes = bBytes.replaceAll("\\]", ""); 
     System.out.println(bBytes);  
    } 

} 
+0

當小位圖工作的很好時,但是當位圖很大時,這種轉換花費的時間太長,已經考慮過用NDK來做這個,可能性能很好。 問題是這樣一行: String bBytes = Arrays.toString(bytes); – ISJ

+0

第一次提到性能問題。發表另一個問題,我會建議。 –

+0

你可以建議? – ISJ

相關問題