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

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

        将 HTML5 画布转换为 IMG 元素

        Convert HTML5 canvas to IMG element(将 HTML5 画布转换为 IMG 元素)
          <tbody id='H302T'></tbody>

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

                <tfoot id='H302T'></tfoot>

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

                • 本文介绍了将 HTML5 画布转换为 IMG 元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想调整 HTML5 画布的大小、拉伸 HTML5 画布,使画布像 IMG 元素一样:按像素设置宽度-高度、百分比...

                  I would like to resize, stretch an HTML5 canvas in a way that the canvas act like an IMG element: set width-height by pixel, percent...

                  我想知道是否有任何方法可以将 HTML5 画布转换/导出为 IMG 元素,或者任何可以直接在画布上实现这一点的方法.

                  I wonder if is there any way to convert/export an HTML5 canvas to an IMG element, or any way that can make this possible directly on the canvas.

                  我正在使用 KineticJS 库,了解详情.

                  I'm using KineticJS library, for details.

                  请帮忙!

                  推荐答案

                  首先,给你的画布一个 id(例如 example).然后,使用纯 JavaScript,您可以基于该画布创建图像并为其设置样式:

                  First, give your canvas an id (e.g. example). Then, using plain JavaScript you can create an image based on that canvas and style it:

                  var canvas = document.getElementById('example'),
                      dataUrl = canvas.toDataURL(),
                      imageFoo = document.createElement('img');
                  imageFoo.src = dataUrl;
                  
                  // Style your image here
                  imageFoo.style.width = '100px';
                  imageFoo.style.height = '100px';
                  
                  // After you are done styling it, append it to the BODY element
                  document.body.appendChild(imageFoo);
                  

                  这篇关于将 HTML5 画布转换为 IMG 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to make rooftext effect and valley text effect in HTML5 (or Fabric.js)(如何在 HTML5(或 Fabric.js)中制作屋顶文字效果和山谷文字效果)
                  Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                  dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                  What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                  I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)
                  How to upload image into HTML5 canvas(如何将图像上传到 HTML5 画布中)

                    • <bdo id='m7PKS'></bdo><ul id='m7PKS'></ul>
                        <tbody id='m7PKS'></tbody>

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

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