繁体   English   中英

android如何获取图像斑点的宽度和高度?

[英]android How to get width and height of the image blob?

我已将图像存储到数据库。 我可以获得斑点,但找不到正确的高度和宽度,并且很难对每个图像的宽度和高度进行编码不是一个好主意。 请帮我

Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.img);
        int WIDTH=bitmap.getWidth();
        int HEIGHT=bitmap.getHeight();
        bitmap.recycle();

img将是您在drawable的图像。

得到了答案

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM