Vor kurzem muss ich die WeChat Sharing -Methode der App für die WebView öffnen, die die gemeinsam genutzten Bilder beinhaltet. Wenn Sie sich über die Übertragung von Bildern verbinden, erhalten Sie die Bilddatei erneut im Hintergrund, was sich auf die Geschwindigkeit auswirkt. Ich habe WebView ausgewählt, um das Bild an die lokale Anwendung in Base64-Bit-Codierung weiterzugeben. Hier ist der Implementierungsreferenzcode:
<! DocType html> <html> <kopf> <meta http-äquiv = "content-type" content = "text/html; charset = utf-8"> <title> Bild zu Base64-JSFIDDLE-Demo von Handtrix </title> <script type = 'text/javascript' src = '// code.jquery.com/jquery-2.0.2.js'> </script> <link rel = "styleSheet" type = "text/csS" href = "/css/result-light.css" rel = "externe nofollow"> <style type URL ('// netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css'); Körper {Padding: 20px; } </style> <script type = 'text/javaScript'> // <! [cdata [$ (window) .load (function (function convertImgtobase64 ('http://goo.gl/aoxhal', function (Base64Img) {console.log ('Bild:', Base64Img);}) */Funktion convertImgtobase64 (URL, Callback, OutputFormat) {var canvas = document canvas.getContext ('2d'); 'Image/png'); convertiMgtobase64 (ImageRl, Funktion (Base64Img) {$ ('. Output') .find ('textArea') .val (Base64Img) .end () .find ('a') .attr ('href', Base64Img) .Text (Base64Img) .Dend () .Find () .Find () .Find (). () .Find () .D () .Find (). () .Find (). () .Find (). () .Find (). () .Find (). () .Find (). () .Find (). () .Find (). () .Find (). () .Find (). () .Find (). Base64Img); }); Event.PreventDefault (); }); }); //]]> </script> </head> <body> <h2> Eingabe </H2> <Form ID = "img2b64"> <Eingabe type = "url" name = "url" placeholder = "Einlagen Sie eine Bild-URL ein." value="http://upload.wikimedia.org/wikipedia/commons/4/4a/Logo_2013_Google.png" required> <span> <input type="submit"> </span> </form> <hr> <h2>Output</h2> <div> <textarea></textarea><br> <a> </a> <br> <br> <img> <br> </div> </body> </html>PS: Hier ist ein Tool für Online -Image Conversion Base64 -Codierung für Ihre Referenz:
Bildkonvertierung in Base64 Codierung Online -Tool : http://tools.vevb.com/transcoding/img2base64