Skip to content Skip to sidebar Skip to footer

How To Find Origid For Getthumbnail When Taking A Picture With Camera.takepicture

For getThumbnail, the android documentation has: public static Bitmap getThumbnail (ContentResolver cr, long origId, long groupId, int kind, BitmapFactory.Options options) I have

Solution 1:

I ended up not being able to use getThumbnail, as I could not find any working way to use the path to the location of the image succsessfully, and (at the time at least, I believe there have been reports submitted) it had issues with devices not storing their thumbnails in the expected location.

My solution to this ended up being what I had hoped I could avoid, writing my own little thumbnail generator instead of using Android's getThumbnail.

publicclassCreateThumbnailextendsActivity {
    Bitmap imageBitmap;
    public Bitmap notTheBestThumbnail(String file) {
        byte[] imageData = null;
        try     
        {

            finalintTHUMBNAIL_SIZE=95;

            FileInputStreamfis=newFileInputStream(file); //file is the path to the image-to-be-thumbnailed.
            imageBitmap = BitmapFactory.decodeStream(fis);
            imageBitmap = Bitmap.createScaledBitmap(imageBitmap, THUMBNAIL_SIZE, THUMBNAIL_SIZE, false);

            ByteArrayOutputStreambaos=newByteArrayOutputStream();  
            imageBitmap.compress(Bitmap.CompressFormat.JPEG, 10, baos); //What image format and level of compression to use.
            imageData = baos.toByteArray();

        }
        catch(Exception ex) {
            Log.e("Something did not work", "True");
        }
        return imageBitmap;
    }   
}

I use the class like:

CreateThumbnailthumb=newCreateThumbnail();
thumb.notTheBestThumbnail(Environment.getExternalStorageDirectory() + "/exampleDir" + "/" + exampleVar  + "/example_img.jpg");
BitmapmBitmap= thumb.imageBitmap; //Assigns the thumbnail to a bitmap variable, for manipulation.

While I didn't actually figure out how to get the ID, hopefully this will help anybody facing similar problems with getThumbnail.

Post a Comment for "How To Find Origid For Getthumbnail When Taking A Picture With Camera.takepicture"