app/src/main/java/xyz/kongjing/prerect/util/ImgUtil.java
private static final Bitmap storeThumbnail(ContentResolver cr, Bitmap source, long id,
        float width, float height, int kind) {

        // create the matrix to scale it
        Matrix matrix = new Matrix();

        float scaleX = width / source.getWidth();
        float scaleY = height / source.getHeight();

        matrix.setScale(scaleX, scaleY);

        Bitmap thumb =
            Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);

        ContentValues values = new ContentValues(4);
        values.put(MediaStore.Images.Thumbnails.KIND, kind);
        values.put(MediaStore.Images.Thumbnails.IMAGE_ID, (int) id);
        values.put(MediaStore.Images.Thumbnails.HEIGHT, thumb.getHeight());
        values.put(MediaStore.Images.Thumbnails.WIDTH, thumb.getWidth());

        Uri url = cr.insert(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, values);

        try {
            OutputStream thumbOut = cr.openOutputStream(url);
            thumb.compress(Bitmap.CompressFormat.JPEG, 100, thumbOut);
            thumbOut.close();
            return thumb;
        } catch (FileNotFoundException ex) {
            return null;
        } catch (IOException ex) {
            return null;
        }
    }
/**
     * A copy of the Android internals StoreThumbnail method, it used with the
     * insertImage to populate the
     * android.provider.MediaStore.Images.Media#insertImage with all the correct
     * meta data. The StoreThumbnail method is private so it must be duplicated
     * here.
     *
     * @see MediaStore.Images.Media (StoreThumbnail private
     * method)
     */
A copy of the Android internals StoreThumbnail method, it used with the
insertImage to populate the
android.provider.MediaStore.Images.Media#insertImage with all the correct
meta data. The StoreThumbnail method is private so it must be duplicated
here.


A copy of the Android internals StoreThumbnail method it used with the insertImage to populate the android . provider . MediaStore . Images . Media#insertImage with all the correct meta data . The StoreThumbnail method is private so it must be duplicated here .
private static final Bitmap storeThumbnail(ContentResolver cr, Bitmap source, long id,
        float width, float height, int kind) {
        Matrix matrix = new Matrix();
        float scaleX = width / source.getWidth();
        float scaleY = height / source.getHeight();
        matrix.setScale(scaleX, scaleY);
        Bitmap thumb =
            Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
        ContentValues values = new ContentValues(4);
        values.put(MediaStore.Images.Thumbnails.KIND, kind);
        values.put(MediaStore.Images.Thumbnails.IMAGE_ID, (int) id);
        values.put(MediaStore.Images.Thumbnails.HEIGHT, thumb.getHeight());
        values.put(MediaStore.Images.Thumbnails.WIDTH, thumb.getWidth());
        Uri url = cr.insert(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, values);
        try {
            OutputStream thumbOut = cr.openOutputStream(url);
            thumb.compress(Bitmap.CompressFormat.JPEG, 100, thumbOut);
            thumbOut.close();
            return thumb;
        } catch (FileNotFoundException ex) {
            return null;
        } catch (IOException ex) {
            return null;
        }
    }
private static final Bitmap storeThumbnail ( ContentResolver cr , Bitmap source , long id , float width , float height , int kind ) { Matrix matrix = new Matrix ( ) ; float scaleX = width / source . getWidth ( ) ; float scaleY = height / source . getHeight ( ) ; matrix . setScale ( scaleX , scaleY ) ; Bitmap thumb = Bitmap . createBitmap ( source , 0 , 0 , source . getWidth ( ) , source . getHeight ( ) , matrix , true ) ; ContentValues values = new ContentValues ( 4 ) ; values . put ( MediaStore . Images . Thumbnails . KIND , kind ) ; values . put ( MediaStore . Images . Thumbnails . IMAGE_ID , ( int ) id ) ; values . put ( MediaStore . Images . Thumbnails . HEIGHT , thumb . getHeight ( ) ) ; values . put ( MediaStore . Images . Thumbnails . WIDTH , thumb . getWidth ( ) ) ; Uri url = cr . insert ( MediaStore . Images . Thumbnails . EXTERNAL_CONTENT_URI , values ) ; try { OutputStream thumbOut = cr . openOutputStream ( url ) ; thumb . compress ( Bitmap . CompressFormat . JPEG , 100 , thumbOut ) ; thumbOut . close ( ) ; return thumb ; } catch ( FileNotFoundException ex ) { return null ; } catch ( IOException ex ) { return null ; } }
A copy of the Android internals StoreThumbnail method, it used with the
 insertImage to populate the
 android.provider.MediaStore.Images.Media#insertImage with all the correct
 meta data.
A copy of the Android internals StoreThumbnail method it used with the insertImage to populate the android . provider . MediaStore . Images . Media#insertImage with all the correct meta data .
// create the matrix to scale it
