你能“包裹”吗? droid 手机上的库存相机功能如何?
我的公司需要在机器人拍摄的图像上打印时间戳。另一位开发人员提到,我们可以封装库存相机的全部功能,然后在拍摄照片后将时间戳嵌入其中。这可以做到吗?如果可以的话,会有多简单/复杂?
My company has a need to print a timestamp on images taken on a droid. Another developer mentioned that we could wrap the entire functionality of the stock camera, then once a photo is taken, embed the timestamp on it. Can this be done, and if so, how simple/complex would it be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
其实很简单。绝对比从头开始编写相机应用更简单。
以下是一个简短的概述,为您提供了一些关键字:
您需要触发
ACTION_IMAGE_CAPTURE
意图,这将启动设备相机应用程序并提示用户拍照(库存应用程序与否并不重要)。拍摄照片后,它将返回到您的应用程序。此时,您将获得所拍摄图像的文件 URI,通常指向 JPEG。
完成后,通过
BitmapFactory
加载图像 转换为Bitmap
对象并使用Canvas
对其进行编辑。您可以使用Canvas.drawText()
绘制文本。然后将其存储在您需要的地方、将其从设备上发送出去或执行您想要的任何操作。这就是全部的魔力。1 这里是一个如何做到这一点的小例子,通过谷歌找到,还有更多
Pretty simple actually. Definitely way simpler then writing a camera app from scratch.
Here is a short overview to give you a few keywords:
You need to fire a
ACTION_IMAGE_CAPTURE
intent,this launches the devices camera app and prompts the user to take a picture (stock app or not doesn't even matter). When the picture is taken it will return to your app¹. At this point you'll get a file URI of the taken image that points to a JPEG usually.
Once you have that, load the image via the
BitmapFactory
into aBitmap
object and edit it by using aCanvas
. You can useCanvas.drawText()
to draw the text. Then store it where you need it, send it off the device or do whatever you want with it. And that's all the magic.¹ here is a small example how to do that, found via google, there are plenty more out there