• <legend id='TJkDG'><style id='TJkDG'><dir id='TJkDG'><q id='TJkDG'></q></dir></style></legend>

    <tfoot id='TJkDG'></tfoot>

      1. <i id='TJkDG'><tr id='TJkDG'><dt id='TJkDG'><q id='TJkDG'><span id='TJkDG'><b id='TJkDG'><form id='TJkDG'><ins id='TJkDG'></ins><ul id='TJkDG'></ul><sub id='TJkDG'></sub></form><legend id='TJkDG'></legend><bdo id='TJkDG'><pre id='TJkDG'><center id='TJkDG'></center></pre></bdo></b><th id='TJkDG'></th></span></q></dt></tr></i><div id='TJkDG'><tfoot id='TJkDG'></tfoot><dl id='TJkDG'><fieldset id='TJkDG'></fieldset></dl></div>
          <bdo id='TJkDG'></bdo><ul id='TJkDG'></ul>

      2. <small id='TJkDG'></small><noframes id='TJkDG'>

      3. 如何在 Windows 8 Metro 应用程序中将 html5 画布保存为图像文件?

        How to save html5 canvas as an image file in window 8 metro app?(如何在 Windows 8 Metro 应用程序中将 html5 画布保存为图像文件?)

          1. <tfoot id='ntLnF'></tfoot>
                <bdo id='ntLnF'></bdo><ul id='ntLnF'></ul>

                    <tbody id='ntLnF'></tbody>

                  <small id='ntLnF'></small><noframes id='ntLnF'>

                  <legend id='ntLnF'><style id='ntLnF'><dir id='ntLnF'><q id='ntLnF'></q></dir></style></legend>
                • <i id='ntLnF'><tr id='ntLnF'><dt id='ntLnF'><q id='ntLnF'><span id='ntLnF'><b id='ntLnF'><form id='ntLnF'><ins id='ntLnF'></ins><ul id='ntLnF'></ul><sub id='ntLnF'></sub></form><legend id='ntLnF'></legend><bdo id='ntLnF'><pre id='ntLnF'><center id='ntLnF'></center></pre></bdo></b><th id='ntLnF'></th></span></q></dt></tr></i><div id='ntLnF'><tfoot id='ntLnF'></tfoot><dl id='ntLnF'><fieldset id='ntLnF'></fieldset></dl></div>
                • 本文介绍了如何在 Windows 8 Metro 应用程序中将 html5 画布保存为图像文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  var myImage = canvas.toDataURL("image/png");
                  

                  我认为 myImage 具有以 png 格式编码的图像字节现在如何将 myImage 保存为文件(在 images 文件夹中)?

                  I think myImage has the image bytes encoded in png format now how to save myImage as a file (in images folder)?

                  推荐答案

                  不使用.toDataUrl,需要使用.msToBlob:

                  var blob = canvas.msToBlob();
                  

                  然后,您需要将其写入磁盘:

                  Then, you'll need to write this out to disk:

                  var output;
                  var input;
                  var outputStream;
                  
                  Windows.Storage.ApplicationData.current.localFolder.createFileAsync("yourFile", 
                            Windows.Storage.CreationCollisionOption.replaceExisting).
                      then(function(file) {
                          return file.openAsync(Windows.Storage.FileAccessMode.readWrite);
                      }).then(function(stream) {
                          outputStream = stream;
                          output = stream.getOutputStreamAt(0);
                          input = blob.msDetachStream();
                          return Windows.Storage.Streams.RandomAccessStream.copyAsync(input, output);
                      }).then(function() {
                          return output.flushAsync();
                      }).done(function() {
                          input.close();
                          output.close();
                          outputStream.close();
                      });
                  

                  在您的应用程序数据文件夹中,您现在将图像写入磁盘.

                  In your applications app data folder, you will now have the image written to disk.

                  如果你想把它放在其他地方——例如.我的图片等 - 然后您只需要使用其他存储文件夹之一.请在此处查看示例.请注意,要访问图片库,您需要将该功能添加到清单中(只是 VS 中 package.appxmanifest 编辑器中的一个复选框)

                  If you wish to place it somewhere else -- e.g. my pictures etc -- then you'll just need to use one of the other storage folders. See the sample here. Note that to access the pictures library you need to add that capability to your manifest (just a checkbox in the package.appxmanifest editor in VS)

                  还有许多其他成像选项可用于对输出文件进行更复杂的操作.有关代码,请参阅成像示例.

                  There are many other imaging options too for more complex manipulation of the output file. See the imaging sample for code.

                  这篇关于如何在 Windows 8 Metro 应用程序中将 html5 画布保存为图像文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))
                • <legend id='rOxv5'><style id='rOxv5'><dir id='rOxv5'><q id='rOxv5'></q></dir></style></legend>
                      <bdo id='rOxv5'></bdo><ul id='rOxv5'></ul>
                      <tfoot id='rOxv5'></tfoot>

                      <small id='rOxv5'></small><noframes id='rOxv5'>

                        <i id='rOxv5'><tr id='rOxv5'><dt id='rOxv5'><q id='rOxv5'><span id='rOxv5'><b id='rOxv5'><form id='rOxv5'><ins id='rOxv5'></ins><ul id='rOxv5'></ul><sub id='rOxv5'></sub></form><legend id='rOxv5'></legend><bdo id='rOxv5'><pre id='rOxv5'><center id='rOxv5'></center></pre></bdo></b><th id='rOxv5'></th></span></q></dt></tr></i><div id='rOxv5'><tfoot id='rOxv5'></tfoot><dl id='rOxv5'><fieldset id='rOxv5'></fieldset></dl></div>
                              <tbody id='rOxv5'></tbody>