[英]android How to get width and height of the image blob?
I have stored an Image to Database. 我已将图像存储到数据库。 I can get the blob but unable to find its correct height and width and hard coding each image width and height is not a good idea.
我可以获得斑点,但找不到正确的高度和宽度,并且很难对每个图像的宽度和高度进行编码不是一个好主意。 kindly help me out
请帮我
Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.img); int WIDTH=bitmap.getWidth(); int HEIGHT=bitmap.getHeight(); bitmap.recycle();
where img
will be your image in drawable
. img
将是您在drawable
的图像。
Got the answer from
得到了答案
http://apachejava.blogspot.com/2011/01/get-width-and-height-of-image-blob.html
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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.