1

尝试从缓冲区创建 Jimp 对象时出现此错误。

奇怪的是,当屏幕截图是完整的东西但在屏幕截图的某些裁剪时不起作用时,这始终有效

IE。当我以各种尺寸和形状输入屏幕各个部分的屏幕截图时,它的大小/比例要么有效,要么不一致

export function saveScreenshot(screenshot, fileName) {
  let img = screenshot.image
  let width = screenshot.width
  let height = screenshot.height
  let fixedImg = new Uint8Array(img.length); 
  for (let i=0; i < img.length; i+=4) { 
    fixedImg[i] = img[i+2]; // r 
    fixedImg[i+1] = img[i+1]; // g 
    fixedImg[i+2] = img[i+0]; // b 
    fixedImg[i+3] = 255; // a
  }
  new Jimp({data: fixedImg, width: width, height: height}, (err, image) => {
    console.log(err)
    image.resize(DETECTION_WIDTH, DETECTION_HEIGHT).write(fileName);
  });
}
4

0 回答 0