天天看點

android 擷取 圖檔 縮略圖

byte[] imageByte=getImageFromURL(urlPath.trim());   

            //以下是把圖檔轉化為縮略圖再加載  

            BitmapFactory.Options options = new BitmapFactory.Options();   

            options.inJustDecodeBounds = true;  

            BitmapFactory.decodeByteArray(imageByte, 0, imageByte.length,options);   <span style="font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25px; white-space: normal;"> //此時傳回bitmap為空 </span>  

            options.inJustDecodeBounds = false;  

            int be = (int)(options.outHeight / (float)200);   

            if (be <= 0){  

                be = 1;   

            }  

            options.inSampleSize = be;       

            return BitmapFactory.decodeByteArray(imageByte, 0, imageByte.length,options);  //傳回縮略圖  

繼續閱讀