本文整理汇总了Java中com.android.camera.exif.ExifInterface类的典型用法代码示例。如果您正苦于以下问题:Java ExifInterface类的具体用法?Java ExifInterface怎么用?Java ExifInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExifInterface类属于com.android.camera.exif包,在下文中一共展示了ExifInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveAndFinish
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
@Override
public synchronized void saveAndFinish(byte[] data, int width, int height, int orientation,
ExifInterface exif, final OnMediaSavedListener listener) {
if (mNoPlaceHolderRequired) {
mMediaSaver.addImage(
data, mTitle, mSessionStartMillis, null, width, height,
orientation, exif, listener, mContentResolver);
return;
}
if (mPlaceHolderSession == null) {
throw new IllegalStateException(
"Cannot call saveAndFinish without calling startSession first.");
}
// TODO: This needs to happen outside the UI thread.
mContentUri = mPlaceholderManager.finishPlaceholder(mPlaceHolderSession, mLocation,
orientation, exif, data, width, height, LocalData.MIME_TYPE_JPEG);
removeSession(mUri.toString());
notifyTaskDone(mPlaceHolderSession.outputUri);
}
示例2: storeImage
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
private void storeImage(final byte[] data, Location loc) {
long dateTaken = System.currentTimeMillis();
String title = CameraUtil.createJpegName(dateTaken);
ExifInterface exif = Exif.getExif(data);
int orientation = Exif.getOrientation(exif);
String flashSetting = mActivity.getSettingsManager()
.getString(mAppController.getCameraScope(), Keys.KEY_VIDEOCAMERA_FLASH_MODE);
Boolean gridLinesOn = Keys.areGridLinesOn(mActivity.getSettingsManager());
UsageStatistics.instance().photoCaptureDoneEvent(
eventprotos.NavigationChange.Mode.VIDEO_STILL, title + ".jpeg", exif,
isCameraFrontFacing(), false, currentZoomValue(), flashSetting, gridLinesOn,
null, null, null);
getServices().getMediaSaver().addImage(
data, title, dateTaken, loc, orientation,
exif, mOnPhotoSavedListener, mContentResolver);
}
示例3: getExif
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
public static List<ExifTag> getExif(ContentResolver resolver, Uri uri) {
String path = getLocalPathFromUri(resolver, uri);
if (path != null) {
Uri localUri = Uri.parse(path);
String mimeType = getMimeType(localUri);
if (!JPEG_MIME_TYPE.equals(mimeType)) {
return null;
}
try {
ExifInterface exif = new ExifInterface();
exif.readExif(path);
List<ExifTag> taglist = exif.getAllTags();
return taglist;
} catch (IOException e) {
Log.w(TAG, "Failed to read EXIF tags", e);
}
}
return null;
}
示例4: addImage
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
@Override
public void addImage(final byte[] data, String title, long date, Location loc, int width,
int height, int orientation, ExifInterface exif, OnMediaSavedListener l,
ContentResolver resolver) {
if (isQueueFull()) {
Log.e(TAG, "Cannot add image when the queue is full");
return;
}
ImageSaveTask t = new ImageSaveTask(data, title, date,
(loc == null) ? null : new Location(loc),
width, height, orientation, exif, resolver, l);
mMemoryUse += data.length;
if (isQueueFull()) {
onQueueFull();
}
t.execute();
}
示例5: getExif
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
public static List<ExifTag> getExif(Context context, Uri uri) {
String path = getLocalPathFromUri(context, uri);
if (path != null) {
Uri localUri = Uri.parse(path);
String mimeType = getMimeType(localUri);
if (!JPEG_MIME_TYPE.equals(mimeType)) {
return null;
}
try {
ExifInterface exif = new ExifInterface();
exif.readExif(path);
List<ExifTag> taglist = exif.getAllTags();
return taglist;
} catch (IOException e) {
Log.w(LOGTAG, "Failed to read EXIF tags", e);
}
}
return null;
}
示例6: 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);
}
示例7: addImage
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
public void addImage(final byte[] data, String title, long date, Location loc,
int width, int height, int orientation, ExifInterface exif,
OnMediaSavedListener l, ContentResolver resolver) {
if (isQueueFull()) {
Log.e(TAG, "Cannot add image when the queue is full");
return;
}
ImageSaveTask t = new ImageSaveTask(data, title, date,
(loc == null) ? null : new Location(loc),
width, height, orientation, exif, resolver, l);
mMemoryUse += data.length;
if (isQueueFull()) {
onQueueFull();
}
t.execute();
}
示例8: 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();
}
示例9: cropJpegDataToAspectRatio
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
/**
* @return Cropped image if the target aspect ratio is larger than the jpeg
* aspect ratio on the long axis. The original jpeg otherwise.
*/
private ResizeBundle cropJpegDataToAspectRatio(ResizeBundle dataBundle) {
final byte[] jpegData = dataBundle.jpegData;
final ExifInterface exif = dataBundle.exif;
float targetAspectRatio = dataBundle.targetAspectRatio;
Bitmap original = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
int originalWidth = original.getWidth();
int originalHeight = original.getHeight();
int newWidth;
int newHeight;
if (originalWidth > originalHeight) {
newHeight = (int) (originalWidth / targetAspectRatio);
newWidth = originalWidth;
} else {
newWidth = (int) (originalHeight / targetAspectRatio);
newHeight = originalHeight;
}
int xOffset = (originalWidth - newWidth)/2;
int yOffset = (originalHeight - newHeight)/2;
if (xOffset < 0 || yOffset < 0) {
return dataBundle;
}
Bitmap resized = Bitmap.createBitmap(original,xOffset,yOffset,newWidth, newHeight);
exif.setTagValue(ExifInterface.TAG_PIXEL_X_DIMENSION, new Integer(newWidth));
exif.setTagValue(ExifInterface.TAG_PIXEL_Y_DIMENSION, new Integer(newHeight));
ByteArrayOutputStream stream = new ByteArrayOutputStream();
resized.compress(Bitmap.CompressFormat.JPEG, 90, stream);
dataBundle.jpegData = stream.toByteArray();
return dataBundle;
}
示例10: saveImage
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
@Override
public void saveImage(byte[] data, String title, long date, Location loc,
int width, int height, int orientation, ExifInterface exif,
OnMediaSavedListener listener) {
mMediaSaver.addImage(data, title, date, loc, width, height, orientation, exif,
listener, mContentResolver);
}
示例11: addLocationToExif
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
/**
* Adds the given location to the given exif.
*
* @param exif The exif to add the location tag to.
* @param location The location to add.
*/
public static void addLocationToExif(ExifInterface exif, Location location) {
exif.addGpsTags(location.getLatitude(), location.getLongitude());
exif.addGpsDateTimeStampTag(location.getTime());
double altitude = location.getAltitude();
if (altitude == 0) {
return;
}
short altitudeRef = altitude < 0 ? ExifInterface.GpsAltitudeRef.SEA_LEVEL_NEGATIVE
: ExifInterface.GpsAltitudeRef.SEA_LEVEL;
exif.setTag(exif.buildTag(ExifInterface.TAG_GPS_ALTITUDE_REF, altitudeRef));
}
示例12: getExif
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
public static ExifInterface getExif(byte[] jpegData) {
ExifInterface exif = new ExifInterface();
try {
exif.readExif(jpegData);
} catch (IOException e) {
Log.w(TAG, "Failed to read EXIF data", e);
}
return exif;
}
示例13: getOrientation
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
public static int getOrientation(ExifInterface exif) {
Integer val = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION);
if (val == null) {
return 0;
} else {
return ExifInterface.getRotationForOrientationValue(val.shortValue());
}
}
示例14: ImageSaveTask
import com.android.camera.exif.ExifInterface; //导入依赖的package包/类
public ImageSaveTask(byte[] data, String title, long date, Location loc,
int width, int height, int orientation, ExifInterface exif,
ContentResolver resolver, OnMediaSavedListener listener) {
this.data = data;
this.title = title;
this.date = date;
this.loc = loc;
this.width = width;
this.height = height;
this.orientation = orientation;
this.exif = exif;
this.resolver = resolver;
this.listener = listener;
}
示例15: 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;
}