【问题标题】:android How to get width and height of the image blob?android如何获取图像blob的宽度和高度?
【发布时间】:2011-06-08 10:17:16
【问题描述】:

我已将图像存储到数据库。我可以获得 blob,但无法找到其正确的高度和宽度,并且硬编码每个图像的宽度和高度并不是一个好主意。请帮帮我

【问题讨论】:

  • 同一个问题不要问两次,人家会回答的。

标签: android image height width blob


【解决方案1】:
位图位图=BitmapFactory.decodeResource(getResources(), R.drawable.img); int WIDTH=bitmap.getWidth(); int HEIGHT=bitmap.getHeight(); bitmap.recycle();

img 将是您在drawable 中的图像。

【讨论】:

    【解决方案2】:

    得到答案

    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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-31
      • 1970-01-01
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      • 2011-11-26
      相关资源
      最近更新 更多