Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

android - How to save the canvas text/image in gallery

I have develop the canvas image to store the gallery.I have add the plugins from

**cordova plugin add https://github.com/devgeeks/Canvas2ImagePlugin.git**

I have write the signature in the device, But unable to save in the gallery.

Here following code:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <meta name="format-detection" content="telephone=no" />    

             <script type="text/javascript" src="cordova.js"></script>         
             <script type="text/javascript" src="js/jquery.js"></script>       
             <script type="text/javascript" src="js/modernizr.custom.34982.js"></script> 
             <script type="text/javascript" src="js/signatureCapture.js"></script>           
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.2.css" />
       <link rel="stylesheet" type="text/css" href="css/styles.css" />                   
             <script type="text/javascript">
             var sigCapture;
             $(document).ready(function(e) 
            {       
                    sigCapture = new SignatureCapture( "signature" );
                    document.addEventListener("deviceready", onDeviceReady, false);         
                    function onDeviceReady()  
                    {
                        window.canvas2ImagePlugin.saveImageDataToLibrary(
                                function(msg){
                                    console.log("Save =========>"+msg);
                                },
                                function(err){
                                    console.log("Error =====>"+err);
                                },
                                document.getElementById('signature')
                            );
                    }
                    $("#submit").click( onSubmitClick );
                    $("#cancel").click( onCancelClick );
                });
             function onSubmitClick(event ) { }
             function onCancelClick( event ) {
                 sigCapture.clear();
                }

             </script>
        </head>
        <body>

       <h2>SIGNATURE</h2>
        <div id="canvasContainer"  >
            <canvas id="signature" />
        </div>

       <button data-role="button" id="submit" data-theme="b">Save</button>
        <button data-role="button" id="cancel" data-theme="b">Cancel</button>       



        </body>
    </html>

Error console :

The image could not be decoded at file:///android_asset/www/index.html:55

please some one can help me how to save the canvas text in image gallery.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...