gpu.js icon indicating copy to clipboard operation
gpu.js copied to clipboard

Getting wrong color when drawing large image

Open naeemy opened this issue 4 years ago • 2 comments

First of all , thank you for your great work. I've been trying to follow wobbling cat example but first I started by redrawing an image. I use nodejs and getPixels() method instead of getting a canvas. It all works fine with cat.jpg and other 1000 x 1000 images but when I use large (3634x5451) image this is what happened.

rotated

CODE

const kernel = function(image) {
      let x = this.thread.x,
          y = this.thread.y;
          
      const n = 4 * ( x + this.constants.w * (this.constants.h - y) );
      this.color(image[n] / 256, image[n+1] / 256, image[n+2] / 256, image[n+3] / 256)
    }

const drawImage = gpu.createKernel(kernel)
      .setConstants({ w: width, h: height})
      .setOutput([width, height])
      .setGraphical(true)

drawImage(buffer)
const pixels = drawImage.getPixels()
gpu.destroy()

// write image file with returned pixels

Running on

  • NodeJS : 14.17.3
  • gpu.js : 2.11.3
  • jpeg-js : 0.4.3
  • AMD Radeon Pro 5300M

Original image It should just redraw the same image.

car

Importance : 3

naeemy avatar Jul 29 '21 11:07 naeemy

I have the same problem and it seems that the color exceptions start from the image pixel index greater than 2048*2048.

oubenruing avatar Jan 28 '22 07:01 oubenruing

I have the same problem too so I have to reduce the size of the image.

thesunfei avatar Feb 14 '22 08:02 thesunfei