2011-06-13 41 views
1

您好我正在嘗試不加載存儲在卡上的圖像,並認爲它更好地加載位圖,但我希望具有完整路徑和縮略圖路徑。我怎麼做?我希望我的適配器向我顯示縮略圖列表,但是當我單擊時,我需要重定向到預覽,所以我還需要一個完整路徑。所以如果我的對象是Image,我需要同時加載imagePath和imageThumbPath。android-如何從DCIM/CAMERA通過採樣縮略圖來拉圖像

這裏是我現在如何加載它們:

新的圖像(數據),其中數據是路徑到實際圖像。如何將拇指路徑同時加載到同一個對象中?

public static List<Image> getCameraImages(Context context) { 
         final String[] projection = { MediaStore.Images.Media.DATA }; 
         final String selection = MediaStore.Images.Media.BUCKET_ID + " = ?"; 
         final String[] selectionArgs = { CAMERA_IMAGE_BUCKET_ID }; 
         final Cursor cursor = context.getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI, 
           projection, 
           selection, 
           selectionArgs, 
           null); 
         List<Image> result = new ArrayList<Image>(cursor.getCount()); 
         if (cursor.moveToFirst()) { 
          final int dataColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 
          do { 
           final String data = cursor.getString(dataColumn); 
           result.add(new Image(data)); 
          } while (cursor.moveToNext()); 
         } 
         cursor.close(); 
         return result; 
        } 

    public static final String CAMERA_IMAGE_BUCKET_NAME = 
        Environment.getExternalStorageDirectory().toString() 
        + "/DCIM/Camera"; 
       public static final String CAMERA_IMAGE_BUCKET_ID = getBucketId(CAMERA_IMAGE_BUCKET_NAME); 

    public static String getBucketId(String path) { 
        return String.valueOf(path.toLowerCase().hashCode()); 
       } 

回答

0

我發現如何做帽子纔會發現拇指的尺寸與原件大小相同!可怕!