Google 致力于为黑人社区推动种族平等。查看具体举措

ImageCapture.OutputFileOptions.Builder

public static final class ImageCapture.OutputFileOptions.Builder
extends Object

java.lang.Object
   ↳ androidx.camera.core.ImageCapture.OutputFileOptions.Builder


Builder class for ImageCapture.OutputFileOptions.

Summary

Public constructors

Builder(File file)

Creates options to write captured image to a File.

Builder(ContentResolver contentResolver, Uri saveCollection, ContentValues contentValues)

Creates options to write captured image to MediaStore.

Builder(OutputStream outputStream)

Creates options that write captured image to a OutputStream.

Public methods

ImageCapture.OutputFileOptions build()

Builds ImageCapture.OutputFileOptions.

ImageCapture.OutputFileOptions.Builder setMetadata(ImageCapture.Metadata metadata)

Sets the metadata to be stored with the saved image.

Inherited methods

Public constructors

Builder

public Builder (File file)

Creates options to write captured image to a File.

Parameters
file File: save location of the image.

Builder

public Builder (ContentResolver contentResolver, 
                Uri saveCollection, 
                ContentValues contentValues)

Creates options to write captured image to MediaStore. Example:

ContentValues contentValues = new ContentValues();
 contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "NEW_IMAGE");
 contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg");

 ImageCapture.OutputFileOptions options = new ImageCapture.OutputFileOptions.Builder(
         getContentResolver(),
         MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
         contentValues).build();

 

Parameters
contentResolver ContentResolver: to access MediaStore

saveCollection Uri: The URL of the table to insert into.

contentValues ContentValues: to be included in the created image file.

Builder

public Builder (OutputStream outputStream)

Creates options that write captured image to a OutputStream.

Parameters
outputStream OutputStream: save location of the image.

Public methods

setMetadata

public ImageCapture.OutputFileOptions.Builder setMetadata (ImageCapture.Metadata metadata)

Sets the metadata to be stored with the saved image.

For JPEG this will be included in the EXIF.

Parameters
metadata ImageCapture.Metadata: Metadata to be stored with the saved image. For JPEG this will be included in the EXIF.

Returns
ImageCapture.OutputFileOptions.Builder