本文整理汇总了Java中com.android.camera.exif.ExifInterface.writeExif方法的典型用法代码示例。如果您正苦于以下问题:Java ExifInterface.writeExif方法的具体用法?Java ExifInterface.writeExif怎么用?Java ExifInterface.writeExif使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.camera.exif.ExifInterface
的用法示例。
在下文中一共展示了ExifInterface.writeExif方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addImage
import com.android.camera.exif.ExifInterface; //导入方法依赖的package包/类
public static Uri addImage(ContentResolver resolver, String title,
long date, Location location, int orientation, ExifInterface exif,
byte[] jpeg, int width, int height) {
// Save the image.
String path = generateFilepath(title);
if (exif != null) {
try {
exif.writeExif(jpeg, path);
} catch (Exception e) {
Log.e(TAG, "Failed to write data", e);
}
} else {
writeFile(path, jpeg);
}
return addImage(resolver, title, date, location, orientation,
jpeg.length, path, width, height);
}
示例2: addExif
import com.android.camera.exif.ExifInterface; //导入方法依赖的package包/类
/**
* Adds basic EXIF data to the tiny planet image so it an be rewritten
* later.
*
* @param jpeg the JPEG data of the tiny planet.
* @return The JPEG data containing basic EXIF.
*/
private byte[] addExif(byte[] jpeg) {
ExifInterface exif = new ExifInterface();
exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, System.currentTimeMillis(),
TimeZone.getDefault());
ByteArrayOutputStream jpegOut = new ByteArrayOutputStream();
try {
exif.writeExif(jpeg, jpegOut);
} catch (IOException e) {
Log.e(TAG, "Could not write EXIF", e);
}
return jpegOut.toByteArray();
}
示例3: writeFile
import com.android.camera.exif.ExifInterface; //导入方法依赖的package包/类
/**
* Writes the JPEG data to a file. If there's EXIF info, the EXIF header
* will be added.
*
* @param path The path to the target file.
* @param jpeg The JPEG data.
* @param exif The EXIF info. Can be {@code null}.
*
* @return The size of the file. -1 if failed.
*/
private static long writeFile(String path, byte[] jpeg, ExifInterface exif) {
if (exif != null) {
try {
exif.writeExif(jpeg, path);
File f = new File(path);
return f.length();
} catch (Exception e) {
Log.e(TAG, "Failed to write data", e);
}
} else {
return writeFile(path, jpeg);
}
return -1;
}
示例4: savePanorama
import com.android.camera.exif.ExifInterface; //导入方法依赖的package包/类
private Uri savePanorama(byte[] jpegData, int width, int height, int orientation) {
if (jpegData != null) {
String filename = PanoUtil.createName(
mActivity.getResources().getString(R.string.pano_file_name_format), mTimeTaken);
String filepath = Storage.generateFilepath(filename);
Location loc = mLocationManager.getCurrentLocation();
ExifInterface exif = new ExifInterface();
try {
exif.readExif(jpegData);
exif.addGpsDateTimeStampTag(mTimeTaken);
exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, mTimeTaken,
TimeZone.getDefault());
exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION,
ExifInterface.getOrientationValueForRotation(orientation)));
writeLocation(loc, exif);
exif.writeExif(jpegData, filepath);
} catch (IOException e) {
Log.e(TAG, "Cannot set exif for " + filepath, e);
Storage.writeFile(filepath, jpegData);
}
int jpegLength = (int) (new File(filepath).length());
return Storage.addImage(mContentResolver, filename, mTimeTaken,
loc, orientation, jpegLength, filepath, width, height);
}
return null;
}