在 symbian 上使用带有phonegap的Camera api

发布于 2024-12-07 17:14:02 字数 1931 浏览 0 评论 0原文

我不明白为什么这不起作用.. 无法在诺基亚模拟器上检查这一点,因为它不模拟相机。 手机应用程序要么崩溃,要么不带任何图片 我尝试了 Base64 方法和 imageURI 方法(在 html 页面上使用不同的按钮),

这是 javascript(相机的重复 js 的原因是尝试不同的方法):

function camera (){

    $('#showpic').css('display','block').html("getting an image");
    navigator.camera.getPicture(camerasuccess,camerafail,null);
};        
function camerasuccess(imageBASE) {

    $('#showpic').css('display','block').html("we have an image");
    var imgsrc = "data:image/jpeg;base64,"+imageBASE[0];
    $('#imageplace').html('<img src ="'+imgsrc+'"/>');
    //var useimg = document.getElementById('useimage');
    //
    //useimg.style.display = 'block';
    //useimg.src = "data:image/jpeg;base64,"+imageBASE;

}

function camerafail(error) {
    $('#showpic').css('display','block').html("some error:"+error);
};

function camera2(){
    $('#showpic').css('display','block').html("getting an image");
    navigator.camera.getPicture(camera2success,camerafail,null);

};

function camera2success (imageURI){
    $('#showpic').css('display','block').html("we have an image");
    $('#debug').html(imageURI[0]);
    if (!imageURI[0]) {
        $('#debug').html("no imageURI here");
    }
    $('#imageplace').html('<img src ="'+imageURI[0]+'"/>');

这是标记(这里也是我采取的不同方法):

   <div id = "camera">
        <input type = "button" id = "camera" value = "base">
        <input type = "button" id = "camera2" value = "imageURi"></br>
        <span id = "showpic" style = "display:none;">showpic</span><br/>
        <span id = "debug"></span></br>
        <div id = "imageplace"></div></br>
        <img id = "useimage" style = "display:none; width:60px; height:60px " src = ''/> 
    </div>

另一个注意事项:如果它有任何意义,那么你应该知道我不使用 make 来关闭 wgz 文件,只需压缩 www 文件夹并将结尾更改为 wgz,大多数 js 函数(包括地理定位)都可以工作美好的。

I can't figure out why this isn't working..
can't check this on the nokia simulator because it doesn't simulate a camera..
and the phone app either crashes or just don't bring any picture
I tried both Base64 method and imageURI method (with different buttons on the html page)

this is the javascript (the reason for the duplicate js for the camera is trying the different methods):

function camera (){

    $('#showpic').css('display','block').html("getting an image");
    navigator.camera.getPicture(camerasuccess,camerafail,null);
};        
function camerasuccess(imageBASE) {

    $('#showpic').css('display','block').html("we have an image");
    var imgsrc = "data:image/jpeg;base64,"+imageBASE[0];
    $('#imageplace').html('<img src ="'+imgsrc+'"/>');
    //var useimg = document.getElementById('useimage');
    //
    //useimg.style.display = 'block';
    //useimg.src = "data:image/jpeg;base64,"+imageBASE;

}

function camerafail(error) {
    $('#showpic').css('display','block').html("some error:"+error);
};

function camera2(){
    $('#showpic').css('display','block').html("getting an image");
    navigator.camera.getPicture(camera2success,camerafail,null);

};

function camera2success (imageURI){
    $('#showpic').css('display','block').html("we have an image");
    $('#debug').html(imageURI[0]);
    if (!imageURI[0]) {
        $('#debug').html("no imageURI here");
    }
    $('#imageplace').html('<img src ="'+imageURI[0]+'"/>');

and this is the markup (here also the remains of the different approaches I took):

   <div id = "camera">
        <input type = "button" id = "camera" value = "base">
        <input type = "button" id = "camera2" value = "imageURi"></br>
        <span id = "showpic" style = "display:none;">showpic</span><br/>
        <span id = "debug"></span></br>
        <div id = "imageplace"></div></br>
        <img id = "useimage" style = "display:none; width:60px; height:60px " src = ''/> 
    </div>

another notice: if it has any meaning then you should know I don't use make to close the wgz file, just zip the www folder and change the ending to wgz, most js functions (including geolocation) work fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫七 2024-12-14 17:14:02

我也有类似的问题。我正在使用诺基亚 N8。它触发 getPicture 方法,我可以拍照。然而,退出“拍照”应用程序的唯一方法是单击“返回”。这会触发成功函数,但不会返回图像数据。

查看Phonegap的API文档,它说这些是Camera API支持的平台:

  • Android
  • Blackberry WebWorks(OS 5.0及更高版本)
  • iPhone
  • Windows Phone 7(Mango)

经过多次尝试和错误,这显然只有在您期望的情况下才有效Camera API 将图像作为 URI 返回(而不是实际的图像数据),并将 editable 设置为 true。尝试这样的事情:

navigator.camera.getPicture(camerasuccess, onFail, { quality: 20, allowEdit: true }); 

$('#imageplace').html('<img src ="'+imageBASE+'"/>');

I've got a similar problem. I am using a Nokia N8. It fires the getPicture method, and I can take a photo. However the only way to exit from the 'taking a photo' app is to click Back. This fires the success function, but no image data is returned.

Looking at the API docs for Phonegap, it says that these are the supported platforms for the Camera API:

  • Android
  • Blackberry WebWorks (OS 5.0 and higher)
  • iPhone
  • Windows Phone 7 ( Mango )

After much trial and error, this apparently only works if you expect the Camera API to return images as URIs (not the actual image data), and also set editable to true. Try something like this:

navigator.camera.getPicture(camerasuccess, onFail, { quality: 20, allowEdit: true }); 

$('#imageplace').html('<img src ="'+imageBASE+'"/>');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文