加载图像到ExifInterface [英] Load image into ExifInterface
问题描述
我试着加载一个硬$ C $光盘镜像到Android的ExifInterface,但它似乎无法找到它。这就是我想:
Im trying to load a hardcoded image into the android ExifInterface but it can't seem to find it. This is what I am trying:
ExifInterface mExif = new ExifInterface("images/IMG_20150411_194725.jpg");
图像位于RES / images目录中。有什么我需要为Android做的,把它捡起来?
The images is located in res/images directory. Is there something i need to do for android to pick it up?
推荐答案
首先, RES /
通常是指资源。不仅那些只存在作为开发机器上的文件,但你不能创造新的资源目录,并且有一个名为没什么<$ C $ C> RES /图像/ Android中。
First, res/
usually refers to resources. Not only do those only exist as files on your development machine, but you cannot invent new resource directories, and there is nothing named res/images/
in Android.
二, ExifInterface
只加载文件系统删除文件,而不是资源。毕竟,这将是完全没有意义的一个开发商想用 ExifInterface
上的资源。资源是只读的,所以你不能使用 ExifInterface
修改EXIF头中的资源。和而不是浪费用户的时间,CPU和电池读数只读映像文件提取元数据,开发人员会做到这一点的时间提前,将这些数据在其他地方,如字符串或整数的资源。
Second, ExifInterface
only loads files off of the filesystem, not resources. After all, it would be completely pointless for a developer to want to use ExifInterface
on a resource. Resources are read-only, so you cannot use ExifInterface
to modify EXIF headers in a resource. And rather than wasting users' time, CPU, and battery reading in a read-only image file to extract metadata, developers would do that ahead of time, putting that data somewhere else, such as string or integer resources.
三, ExifInterface
需要在文件系统中的文件的完全限定路径。所以,即使你有一个图像/
目录中的文件系统中的某个位置的文件(例如,使用创建的 getFilesDir()
作为为基础),您需要提供该文件的完全合格的路径。
Third, ExifInterface
needs a fully-qualified path to the file on the filesystem. So even if you have a file somewhere in the filesystem in an images/
directory (e.g., created using getFilesDir()
as as base), you would need to provide a fully-qualified path to that file.
这篇关于加载图像到ExifInterface的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!