Creating a path from the edge of an image

后端 未结 2 880
盖世英雄少女心
盖世英雄少女心 2021-01-02 08:26

I have a binary image (e.g., .png) with background transparency. Let\'s say it looks like a blob with an irregular, but solid shape (no holes and it\'s all in one piece).

2条回答
  •  萌比男神i
    2021-01-02 09:14

    This is pure JS solution without depending on any 3rd party library.

    function getOutline(ctx,pointX,pointY,w,h){
        var imageData = ctx.getImageData(pointX, pointY, w, h);
        var data = imageData.data;
        var outline=[];
        for(var x=0;x

    Demo

提交回复
热议问题