Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions core/java/android/provider/MediaStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,8 @@ private static final Bitmap StoreThumbnail(
}

/**
* Insert an image and create a thumbnail for it.
* Insert an image and create a thumbnail for it. The image is encoded using a default
* format indicated by {@code STORED_COMPRESSION_FORMAT} and with a default quality parameter.
*
* @param cr The content resolver to use
* @param source The stream to use for the image
Expand All @@ -792,7 +793,7 @@ public static final String insertImage(ContentResolver cr, Bitmap source,
ContentValues values = new ContentValues();
values.put(Images.Media.TITLE, title);
values.put(Images.Media.DESCRIPTION, description);
values.put(Images.Media.MIME_TYPE, "image/jpeg");
values.put(Images.Media.MIME_TYPE, STORED_CONTENT_TYPE);

Uri url = null;
String stringUrl = null; /* value to be returned */
Expand All @@ -803,7 +804,7 @@ public static final String insertImage(ContentResolver cr, Bitmap source,
if (source != null) {
OutputStream imageOut = cr.openOutputStream(url);
try {
source.compress(Bitmap.CompressFormat.JPEG, 50, imageOut);
source.compress(STORED_COMPRESSION_FORMAT, 50, imageOut);
} finally {
imageOut.close();
}
Expand Down Expand Up @@ -861,12 +862,21 @@ public static Uri getContentUri(String volumeName) {
getContentUri("external");

/**
* The MIME type of of this directory of
* images. Note that each entry in this directory will have a standard
* image MIME type as appropriate -- for example, image/jpeg.
* The MIME type of this directory of images. Note that each entry in this directory will have
* a standard image MIME type as specified by STORED_CONTENT_TYPE.
*/
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/image";

/**
* The MIME type of the underlying data when stored.
*/
public static final String STORED_CONTENT_TYPE = "image/jpeg";

/**
* The compression format used to compress the images stored in this media store.
*/
public static final Bitmap.CompressFormat STORED_COMPRESSION_FORMAT = Bitmap.CompressFormat.JPEG;

/**
* The default sort order for this table
*/
Expand Down