1. <tfoot id='ka8NZ'></tfoot>

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

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

        使用javascript获取Base64 PNG的像素颜色?

        Get pixel color of Base64 PNG using javascript?(使用javascript获取Base64 PNG的像素颜色?)

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

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

                • <bdo id='mUAJH'></bdo><ul id='mUAJH'></ul>
                    <tbody id='mUAJH'></tbody>
                • 本文介绍了使用javascript获取Base64 PNG的像素颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 base64 编码的 PNG.我需要使用 javascript 获取像素的颜色.我想我必须将它转换回普通的 PNG.谁能指出我正确的方向?

                  I have a base64 encoded PNG. I need to get the color of a pixel using javascript. I assume I'll have to convert it back to a normal PNG. Can anyone point me in the right direction?

                  推荐答案

                  创建一个Image对象,以base64图像为源.然后你可以将图像绘制到画布上,并使用 getImageData 函数来获取像素数据.

                  Create an Image object with the base64 image as the source. Then you can draw the image to a canvas and use the getImageData function to get the pixel data.

                  这是基本的想法(我没有测试过):

                  Here's the basic idea (I haven't tested this):

                  var image = new Image();
                  image.onload = function() {
                      var canvas = document.createElement('canvas');
                      canvas.width = image.width;
                      canvas.height = image.height;
                  
                      var context = canvas.getContext('2d');
                      context.drawImage(image, 0, 0);
                  
                      var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
                  
                      // Now you can access pixel data from imageData.data.
                      // It's a one-dimensional array of RGBA values.
                      // Here's an example of how to get a pixel's color at (x,y)
                      var index = (y*imageData.width + x) * 4;
                      var red = imageData.data[index];
                      var green = imageData.data[index + 1];
                      var blue = imageData.data[index + 2];
                      var alpha = imageData.data[index + 3];
                  };
                  image.src = base64EncodedImage;
                  

                  这篇关于使用javascript获取Base64 PNG的像素颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))
                      <tbody id='Jru0Z'></tbody>
                    <i id='Jru0Z'><tr id='Jru0Z'><dt id='Jru0Z'><q id='Jru0Z'><span id='Jru0Z'><b id='Jru0Z'><form id='Jru0Z'><ins id='Jru0Z'></ins><ul id='Jru0Z'></ul><sub id='Jru0Z'></sub></form><legend id='Jru0Z'></legend><bdo id='Jru0Z'><pre id='Jru0Z'><center id='Jru0Z'></center></pre></bdo></b><th id='Jru0Z'></th></span></q></dt></tr></i><div id='Jru0Z'><tfoot id='Jru0Z'></tfoot><dl id='Jru0Z'><fieldset id='Jru0Z'></fieldset></dl></div>
                    <tfoot id='Jru0Z'></tfoot>

                      • <legend id='Jru0Z'><style id='Jru0Z'><dir id='Jru0Z'><q id='Jru0Z'></q></dir></style></legend>
                          <bdo id='Jru0Z'></bdo><ul id='Jru0Z'></ul>

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