Node JS canvas image data

后端 未结 2 1124
青春惊慌失措
青春惊慌失措 2020-12-16 07:58

I am trying to read a image and the result i want to get is the same when you use a HTML canvas \"Uint8ClampedArray\"? var imageData = ctx.getImageData(0, 0, width, he

2条回答
  •  一个人的身影
    2020-12-16 09:02

    Do not realy know what i did to get canvas to work. I used pixel-util to set image data.

    var pixelUtil = require('pixel-util'),
        Canvas = require('canvas');
    
    var image = new Canvas.Image,
    
    pixelUtil.createBuffer('http://127.0.0.1:8080/image/test.jpg').then(function(buffer){
        image.src = buffer;
    
        canvas = new Canvas(image.width, image.height);
    
        var ctx = canvas.getContext('2d');
        ctx.drawImage(image, 0, 0);
        runImage(ctx.getImageData(0, 0, canvas.width, canvas.height));
    });
    

提交回复
热议问题