簡體   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