久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<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="qwawimqqmiuu" 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 將圖像繪制到畫布上不工作)
        • <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="qwawimqqmiuu" 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" 將圖像繪制到畫布上不工作的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在客戶端獨立的 JS 應用程序中,我正在嘗試制作它,以便可以在畫布上調用 toDataURL(),在該畫布上我繪制了一些由 URL 指定的圖像.即,我可以在文本框中輸入要在畫布上繪制的任何圖像(托管在 imgur 上)的 URL,單擊繪制"按鈕,它將在畫布上繪制.最終用戶應該能夠將他們的最終渲染保存為單個圖像,為此我使用 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().

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

                  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.

                  這是我的代碼的完整工作簡化版本(但實際上會有更多功能):

                  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>
                  

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

                  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.

                  我需要改變什么來解決這個問題?我真的需要能夠為最終用戶實現保存最終圖像的功能,而編寫 html5 規范的人故意引入了這個 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 之前設置 CORS 請求 - 只需將這些行換成:

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

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

                  您還需要為圖像添加一個 onload 處理程序,因為加載是異步的:

                  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;
                  

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

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  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 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  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="qwawimqqmiuu" 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>
                          • 主站蜘蛛池模板: 超碰在线观看97 | 国产精品五月天 | 久久久精彩视频 | 亚av在线 | 国产精品亚洲欧美日韩一区在线 | hitomi一区二区三区精品 | 色综合av | 日韩精品免费一区二区在线观看 | 一区精品国产欧美在线 | 精品视频在线播放 | 天天久久| 99久久中文字幕三级久久日本 | 超碰成人免费 | 亚洲欧美日韩在线不卡 | 亚洲v区 | 欧美色综合一区二区三区 | 中文字幕一区二区三 | 国精品一区 | 国产成人精品午夜视频免费 | 亚州综合在线 | 国产精品毛片久久久久久 | 天堂一区二区三区 | 国产欧美一区二区三区在线看 | 视频精品一区 | 国产日韩欧美91 | 精品福利av导航 | 久久区二区 | 亚洲电影一级片 | 中文字幕黄色大片 | 国产精品成人一区二区 | 日本黄色影片在线观看 | 亚洲va欧美va天堂v国产综合 | avhd101在线成人播放 | 欧洲一级毛片 | 日韩在线电影 | 亚洲免费人成在线视频观看 | 国产一区二区三区久久久久久久久 | 一区二区三区不卡视频 | www.国产| 欧美精品一区三区 | 国产日韩精品一区 |