Suivez le tag #bitmap en quelques secondes.

Inscription

I dont like gifs, i like jpegs on my pngs, so i can bag tiff. -Damn that was corny- Only a little bit....map LMAO im a nerdclown

Part 109: Accessing the Images/media on a device

To access all the images on your device, you can use a cursor:

Cursor mImageCursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                null, null, null, null );
if(mImageCursor.moveToFirst())
     do {
        String s[] = mImageCursor.getColumnNames();
        int column = mImageCursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        String filename = mImageCursor.getString(column);
        Bitmap bm = BitmapFactory.decodeFile(filename);
   } while ( mImageCursor.moveToNext());

This grabs all the images on the device, goes to the first image, gets its name via access its column called DATA.

You can then create a Bitmap resource from the filename using BitmapFactory.

Not that, if you’ve just added an image to the filesystem, it won’t show up. Not there and not if you try to access the devices images using the Intent choose way:.

Intent intent = new Intent();
intent.setType(“image/*”);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, “Select Picture”),0);

You must refresh the system’s cache of images in the device. You’ll learn how to do that next.

Chargement des billets...