问题描述
我开发了的自定义的Android设备的应用程序。它仍处于发展初期,这是可能的,相机可能物理上旋转90度,以在设备的其余部分。这意味着,对纵向和横向之间巨大的困惑需要的任何图像范围。出于这个原因,我想了,该相机拍摄的任何图像的Exif数据中绝对控制权。画像VS相机参数的景观信息可能是不正确的。出于这个原因,我想能够迫使里面onPictureTaken的Exif数据中的变化,保存图像前。这是可能的,如果又如何?
I am developing an app for a custom android device. It is still early in the development and it is possible that the camera may physically be rotated 90 degrees to the rest of the device. This means that there is scope for great confusion between portrait and landscape for any images it takes. For this reason I would like absolute control over the Exif data in any images that the camera takes. The portrait vs landscape information in the camera parameters may be incorrect. For this reason I would like to be able to force a change in the Exif data inside onPictureTaken, before the image is saved. Is this possible, and if so how?
我奋力因为与EXIF数据打例子似乎通过更改相机参数的工作,或对已经保存的文件工作 - 所以这是不是太过早或过迟
I am struggling because examples of playing with exif data seem to either work by changing camera parameters, or by working on an already saved file - so that's either too early or too late!
public void onPictureTaken(byte[] jpg_data, Camera camera)
{
// can I change exif data here?
try
{
FileOutputStream buf = new FileOutputStream(filename);
buf.write(jpg_data);
//... etc.
编辑:也许我误解的东西在这里...有没有已经包含了获取传递给onPictureTaken的jpg_data内的Exif数据中?抑或是随意添加?
Maybe I am misunderstanding something here... is there Exif data already contained within the jpg_data that gets passed to onPictureTaken? Or is it optionally added?
推荐答案
在Android的写EXIF数据的标准方法是使用ExifInterface这可悲的是仅适用于那些已经被写入到磁盘文件。
The standard way of writing exif data in Android is by using the ExifInterface which sadly only works on files that have already been written to disk.
如果你希望做的EXIF写不使用库,那么你就必须经过做你的的FileOutputStream
完成写入文件。
If you wish to do the exif write without using a library, then you would have to do it after your FileOutputStream
is finished writing the file.
如果你不介意使用图书馆,Sanselan()可能需要它做一个byte []数组的能力,但文档是pretty有限。
If you don't mind using a library, Sanselan (http://commons.apache.org/proper/commons-imaging/) might have the ability to do it to a byte[] array, but the documentation is pretty limited.
这篇关于变化与QUOT;&的Exif QUOT; onPictureTaken与写之间的数据()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!