pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

      <bdo id='7XNmm'></bdo><ul id='7XNmm'></ul>

        <small id='7XNmm'></small><noframes id='7XNmm'>

      1. 使用 img.crossOrigin = "Anonymous" 將圖像繪制到

        Drawing images to canvas with img.crossOrigin = quot;Anonymousquot; doesn#39;t work(使用 img.crossOrigin = Anonymous 將圖像繪制到畫(huà)布上不工作)
        • <bdo id='4cHuf'></bdo><ul id='4cHuf'></ul>

          <legend id='4cHuf'><style id='4cHuf'><dir id='4cHuf'><q id='4cHuf'></q></dir></style></legend>

            • <i id='4cHuf'><tr id='4cHuf'><dt id='4cHuf'><q id='4cHuf'><span id='4cHuf'><b id='4cHuf'><form id='4cHuf'><ins id='4cHuf'></ins><ul id='4cHuf'></ul><sub id='4cHuf'></sub></form><legend id='4cHuf'></legend><bdo id='4cHuf'><pre id='4cHuf'><center id='4cHuf'></center></pre></bdo></b><th id='4cHuf'></th></span></q></dt></tr></i><div class="q2qkaeo" id='4cHuf'><tfoot id='4cHuf'></tfoot><dl id='4cHuf'><fieldset id='4cHuf'></fieldset></dl></div>
              <tfoot id='4cHuf'></tfoot>
              • <small id='4cHuf'></small><noframes id='4cHuf'>

                  <tbody id='4cHuf'></tbody>
                  本文介紹了使用 img.crossOrigin = "Anonymous" 將圖像繪制到畫(huà)布上不工作的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  在客戶端獨(dú)立的 JS 應(yīng)用程序中,我正在嘗試制作它,以便可以在畫(huà)布上調(diào)用 toDataURL(),在該畫(huà)布上我繪制了一些由 URL 指定的圖像.即,我可以在文本框中輸入要在畫(huà)布上繪制的任何圖像(托管在 imgur 上)的 URL,單擊繪制"按鈕,它將在畫(huà)布上繪制.最終用戶應(yīng)該能夠?qū)⑺麄兊淖罱K渲染保存為單個(gè)圖像,為此我使用 toDataURL().

                  In a client-side standalone JS application, I'm trying to make it so I can call toDataURL() on a canvas on which I've drawn some images specified by a URL. Ie I can input into a textbox the url to any image (hosted on, say, imgur) that I want to draw on the canvas, click a "draw" button and it will draw on the canvas. The end user should be able to save their final render as a single image, for this I'm using toDataURL().

                  無(wú)論如何,直到他們真正解決了那個(gè)煩人的操作不安全"錯(cuò)誤(天哪,你要告訴最終用戶他們可以用自己的數(shù)據(jù)做什么和不能做什么?)我遵循了一個(gè)變通方法,說(shuō)將圖像添加到 DOM 并將其 crossOrigin 屬性設(shè)置為Anonmyous",然后將其繪制到畫(huà)布上.

                  Anyway, until they actually fix that annoying "operation is insecure" error (gee, you're going to tell the end user what they can and can't do with their own data?) I followed a workaround that said to add the image to the DOM and set its crossOrigin property to "Anonmyous" and then draw it to the canvas.

                  這是我的代碼的完整工作簡(jiǎn)化版本(但實(shí)際上會(huì)有更多功能):

                  Here's a full working simplified version of my code (but in reality there will be many more features):

                  <!DOCTYPE html5>
                  <html>
                  <head>
                  <style>
                  #canvas {border:10px solid green;background-color:black;}
                  #imgbox {border:2px solid black;}
                  </style>
                  </head>
                  <body>
                  <canvas id="canvas" width=336 height=336></canvas>
                  <br><br>
                  <input size=60 id="imgbox">
                  <input type="submit" value="Draw" onclick=draw()>
                  <script>
                  function draw() {
                      var canvas = document.getElementById("canvas");
                      var context = canvas.getContext("2d");
                      var img = new Image();
                      img.src = document.getElementById("imgbox").value;
                      img.crossOrigin = "Anonymous";
                      context.drawImage(img, 40, 40);
                  }
                  </script>
                  </body>
                  </html>
                  

                  沒(méi)有 img.crossOrigin = "Anonymous"; 行,我可以在文本框中輸入 http://i.imgur.com/c2wRzfD.jpg 并點(diǎn)擊畫(huà),它會(huì)工作.但是,一旦我添加了那條線,整個(gè)東西就壞了,甚至根本不會(huì)被繪制到畫(huà)布上.

                  Without the img.crossOrigin = "Anonymous"; line, I could input http://i.imgur.com/c2wRzfD.jpg into the textbox and click draw and it would work. However as soon as I added that line, the whole thing broke and it won't even be drawn to the canvas at all.

                  我需要改變什么來(lái)解決這個(gè)問(wèn)題?我真的需要能夠?yàn)樽罱K用戶實(shí)現(xiàn)保存最終圖像的功能,而編寫(xiě) html5 規(guī)范的人故意引入了這個(gè) bug,這非常煩人.

                  What do I need to change to fix this? I really need to be able to implement the functionality for the end user to save their final image and it's extremely annoying that the people who wrote the html5 spec purposely introduced this bug.

                  推薦答案

                  您必須在 src 之前設(shè)置 CORS 請(qǐng)求 - 只需將這些行換成:

                  You must set the CORS request before the src - just swap the lines into:

                  img.crossOrigin = "Anonymous";
                  img.src = document.getElementById("imgbox").value;
                  

                  您還需要為圖像添加一個(gè) onload 處理程序,因?yàn)榧虞d是異步的:

                  You will also need to add an onload handler to the image as loading is asynchronous:

                  img.onload = function() {
                      context.drawImage(this, 40, 40);
                      // call next step in your code here, f.ex: nextStep();
                  };
                  img.crossOrigin = "Anonymous";
                  img.src = document.getElementById("imgbox").value;
                  

                  這篇關(guān)于使用 img.crossOrigin = "Anonymous" 將圖像繪制到畫(huà)布上不工作的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無(wú)法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)

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

                      <tbody id='MZ1Np'></tbody>

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

                            <bdo id='MZ1Np'></bdo><ul id='MZ1Np'></ul>
                            <legend id='MZ1Np'><style id='MZ1Np'><dir id='MZ1Np'><q id='MZ1Np'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 胃口福饺子加盟官网_新鲜现包饺子云吞加盟 - 【胃口福唯一官网】 | 美名宝起名网-在线宝宝、公司、起名平台 | 北京开业庆典策划-年会活动策划公司-舞龙舞狮团大鼓表演-北京盛乾龙狮鼓乐礼仪庆典策划公司 | 玖容气动液压设备有限公司-气液增压缸_压力机_增压机_铆接机_增压器 | 岸电电源-60HZ变频电源-大功率变频电源-济南诚雅电子科技有限公司 | LZ-373测厚仪-华瑞VOC气体检测仪-个人有毒气体检测仪-厂家-深圳市深博瑞仪器仪表有限公司 | 踏板力计,制动仪,非接触多功能速度仪,逆反射系数测试仪-创宇 | 北京律师咨询_知名专业北京律师事务所_免费法律咨询 | 建大仁科-温湿度变送器|温湿度传感器|温湿度记录仪_厂家_价格-山东仁科 | 工程管道/塑料管材/pvc排水管/ppr给水管/pe双壁波纹管等品牌管材批发厂家-河南洁尔康建材 | 高精度-恒温冷水机-螺杆式冰水机-蒸发冷冷水机-北京蓝海神骏科技有限公司 | 江苏皓越真空设备有限公司 | 立刷【微电签pos机】-嘉联支付立刷运营中心 | 物流之家新闻网-最新物流新闻|物流资讯|物流政策|物流网-匡匡奈斯物流科技 | 【MBA备考网】-2024年工商管理硕士MBA院校/报考条件/培训/考试科目/提前面试/考试/学费-MBA备考网 | 河南彩印编织袋,郑州饲料编织袋定制,肥料编织袋加工厂-盛军塑业 河南凯邦机械制造有限公司 | 雪花制冰机(实验室雪花制冰机)百科 | Trimos测长机_测高仪_TESA_mahr,WYLER水平仪,PWB对刀仪-德瑞华测量技术(苏州)有限公司 | 山东螺杆空压机,烟台空压机,烟台开山空压机-烟台开山机电设备有限公司 | 3d打印服务,3d打印汽车,三维扫描,硅胶复模,手板,快速模具,深圳市精速三维打印科技有限公司 | 代理记账_免费注册公司_营业执照代办_资质代办-【乐财汇】 | 证券新闻,热播美式保罗1984第二部_腾讯1080p-仁爱影院 | 生物制药洁净车间-GMP车间净化工程-食品净化厂房-杭州波涛净化设备工程有限公司 | 薪动-人力资源公司-灵活用工薪资代发-费用结算-残保金优化-北京秒付科技有限公司 | 超声波_清洗机_超声波清洗机专业生产厂家-深圳市好顺超声设备有限公司 | 发电机组|柴油发电机组-批发,上柴,玉柴,潍柴,康明斯柴油发电机厂家直销 | 西安耀程造价培训机构_工程预算实训_广联达实作实操培训 | 进口试验机价格-进口生物材料试验机-西安卡夫曼测控技术有限公司 | 真空搅拌机-行星搅拌机-双行星动力混合机-广州市番禺区源创化工设备厂 | 外贮压-柜式-悬挂式-七氟丙烷-灭火器-灭火系统-药剂-价格-厂家-IG541-混合气体-贮压-非贮压-超细干粉-自动-灭火装置-气体灭火设备-探火管灭火厂家-东莞汇建消防科技有限公司 | 深圳市人通智能科技有限公司 | 红酒招商加盟-葡萄酒加盟-进口红酒代理-青岛枞木酒业有限公司 | 物联网卡_物联网卡购买平台_移动物联网卡办理_移动联通电信流量卡通信模组采购平台? | 热熔胶网膜|pes热熔网膜价格|eva热熔胶膜|热熔胶膜|tpu热熔胶膜厂家-苏州惠洋胶粘制品有限公司 | 氧化锆纤维_1800度高温退火炉_1800度高温烧结炉-南京理工宇龙新材料股份有限公司 | 道达尔润滑油-食品级润滑油-道达尔导热油-合成导热油,深圳道达尔代理商合-深圳浩方正大官网 | 紫外线老化试验箱_uv紫外线老化试验箱价格|型号|厂家-正航仪器设备 | vr安全体验馆|交通安全|工地安全|禁毒|消防|安全教育体验馆|安全体验教室-贝森德(深圳)科技 | 喷砂机厂家_自动喷砂机生产_新瑞自动化喷砂除锈设备 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 美侍宠物-专注宠物狗及宠物猫训练|喂养|医疗|繁育|品种|价格 |