简体   繁体   中英

To get a RGB value for each pixel from SVG rect element

I need to get the color value for each pixel in svg rect element.In canvas we can get it through the method getImageData(x,y,width,height).

In svg,is there any way to do it??If so please give some working examples.

If you create a standalone SVG file and include that in your document via an image element eg a html <img> element then you can copy the image data into canvas via drawImage and you already know how to extract colour values from canvas.

This indirect route is the only way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM