<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 元素

        时间:2023-06-20
          <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 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 SVG 路径数据在 Canvas 中绘制路径(SVG 路径到 Canvas 路径) 下一篇:使用 Web Workers 使用本机画布函数进行绘图

                  相关文章

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

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

                      <legend id='m7PKS'><style id='m7PKS'><dir id='m7PKS'><q id='m7PKS'></q></dir></style></legend>
                    1. <tfoot id='m7PKS'></tfoot>
                    2. <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>