【问题标题】:How do you save an HTML5 <canvas> as an ICO image (icon file) or a .cur file (static mouse cursor) rather than a PNG in JavaScript?如何将 HTML5 <canvas> 保存为 ICO 图像(图标文件)或 .cur 文件(静态鼠标光标)而不是 JavaScript 中的 PNG?
【发布时间】:2021-10-28 16:16:10
【问题描述】:

我一直在寻找如何在Google 上将 HTML5 &lt;canvas&gt; 元素保存为 .ico 图像或 .cur 文件(静态鼠标光标文件),但我得到了如何另存为的结果PNG,而不是另一种格式。在 JavaScript 中如何将&lt;canvas&gt; 保存为除 PNG 以外的任何格式的图像? (例如 JPEG、BMP、GIF、ICO)

【问题讨论】:

  • 您必须将正确的 mime 类型传递给 toBlob 和其他方法,例如 image/jpeg 但如果浏览器不默认为 png 格式,则必须支持该格式

标签: javascript html image canvas


【解决方案1】:

an example at MDN - A way to convert a canvas to an ico 可能会对您有所帮助。它只说 Mozilla,但建议其他浏览器也可以工作。

【讨论】:

  • 我当然希望它适用于Chrome
猜你喜欢
  • 1970-01-01
  • 2012-06-07
  • 1970-01-01
  • 2011-11-05
  • 2014-04-02
  • 1970-01-01
  • 2013-07-19
  • 2017-04-16
  • 1970-01-01
相关资源
最近更新 更多