2013-04-06 71 views
5

我從數據庫獲取圖像的斑點格式圖像。我想將它轉換成位圖圖像。我用來將位圖轉換爲Blob的代碼放在下面,但請告訴我如何將其反轉。獲取斑點圖像並將該圖像轉換爲位圖圖像

ByteArrayOutputStream boas = new ByteArrayOutputStream(); 
btmap.compress(Bitmap.CompressFormat.JPEG, 100, boas); //bm is the bitmap object 
byte[] byteArrayImage = boas .toByteArray(); 
String encodedImage = Base64.encodeToString(byteArrayImage, Base64.DEFAULT); 
+0

編輯和格式正確你的問題 – 2013-04-06 10:39:51

+0

我做哥哥... :-) – 2013-04-06 10:42:38

+0

可能重複[如何存儲圖片爲BLOB SQLite中及如何檢索?](http://stackoverflow.com/questions/7331310/how-to-store-image-as-blob-in-sqlite-how-to-retrieve-it) – 2013-04-06 10:42:38

回答

24

這將工作

byte[] byteArray = DBcursor.getBlob(columnIndex); 

Bitmap bm = BitmapFactory.decodeByteArray(byteArray, 0 ,byteArray.length); 
+0

謝謝。我知道了 – 2013-04-06 10:56:35