0
我已將圖像存儲到數據庫。我可以得到blob,但無法找到其正確的高度和寬度,硬編碼每個圖像的寬度和高度不是一個好主意。好心幫我出android如何獲得圖像blob的寬度和高度?
我已將圖像存儲到數據庫。我可以得到blob,但無法找到其正確的高度和寬度,硬編碼每個圖像的寬度和高度不是一個好主意。好心幫我出android如何獲得圖像blob的寬度和高度?
得到的答案從
http://apachejava.blogspot.com/2011/01/get-width-and-height-of-image-blob.html
public Bitmap convertBlobToBitmap(byte[] blobByteArray) {
Bitmap tempBitmap=null;
if(blobByteArray!=null)
tempBitmap = BitmapFactory.decodeByteArray(blobByteArray, 0, blobByteArray.length);
return tempBitmap;
}
Bitmap temp_bitmapImg = convertBlobToBitmap(BitmapArrayOfImage());
int height = temp_bitmapImg .getHeight();
int width = temp_bitmapImg .getWidth();
Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.img); int WIDTH=bitmap.getWidth(); int HEIGHT=bitmap.getHeight(); bitmap.recycle();
其中img
將在drawable
你的形象。
不要問同樣的問題兩次,會有人接聽時,他們可以。 – 2011-01-13 10:51:55