使用 Phonegap 在 iOS 上的相机预览上叠加图像
我正在创建一个应用程序,其中半透明图像叠加在相机预览上。我知道他们的原生 Phonegap 相机 api 不支持这一点。我想知道是否有编写 Phonegap 插件经验的人可以给我任何关于插件是否可以实现这一点的建议。我想我已经看到这种技术可以通过本机代码实现,所以在我看来,可以编写一个 Phonegap 插件来访问此功能,我只是没有任何使用 Phonegap 插件的经验。
I am looking to create an app in which a semi transparent image is overlaid on the camera preview. I know their is no support for this in the native Phonegap camera api. I'm wondering if anyone who has some experience with writing Phonegap plugins can give me any advice on whether this would be possible with a plugin. I think I have seen that this technique is possible through native code so it seems to me that it would be possible to write a Phonegap plugin to access this functionality, I just don't have any experience with Phonegap plugins.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道,有点晚了,但有办法(仅限 iPad)。您可以使用标准的 org.apache.cordova.camera 插件。但你必须稍微调整一下它
首先将
CDVCameraPicker
子类化,以便你可以通过 cordova-api 切换覆盖:CDVCameraPicker+Overlay.h:
CDVCameraPicker+Overlay.m:
然后将这些行添加到 CDVCamera。 m 检查完 ImagePickerSourceType(第 132 行)后
不要忘记在 CDVCamera.m 中导入您的子类 CameraPicker
#import "CDVCameraPicker+Overlay.h"
不,您必须编辑
Camera.js
文件将此行添加到其他选项下方
,然后将
var
添加到args
-Array 的最后一个索引处。就是这样。现在您可以像这样切换叠加层:I know, it's a little bit too late but there is a way (iPad only). You can use the standard
org.apache.cordova.camera
-Plugin. But you have to tweak it a bitFirst subclasse the
CDVCameraPicker
so you can toggle the overlay via cordova-api:CDVCameraPicker+Overlay.h:
CDVCameraPicker+Overlay.m:
Then add these lines to the CDVCamera.m right after checking the ImagePickerSourceType (Line 132)
Don't forget to import your subclassed CameraPicker in the CDVCamera.m
#import "CDVCameraPicker+Overlay.h"
No you have to edit the
Camera.js
-FileAdd this line underneath the other options
Then add the
var
to theargs
-Array at last index. And that's it. Now you can toggle your overlay like this:我尝试了接受的答案,但不幸的是对我不起作用。
相反,我找到了一个更简单的解决方案。在
CDVCamera.m
中:使用 Grand Central Dispatch 执行叠加非常重要。
I tried the accepted answer, but unfortunately did not work for me.
Instead I found a much simpler solution. In the
CDVCamera.m
:It's important to perform the overlay using Grand Central Dispatch.