src/utils/canvas.js
// given the RLE array returns the DOM Image element with loaded image
given the RLE array returns the DOM Image element with loaded image
given the RLE array returns the DOM Image element with loaded image
function RLE2Region(rle, image) {
  const nw = image.naturalWidth,
    nh = image.naturalHeight;
  var canvas = document.createElement("canvas");
  var ctx = canvas.getContext("2d");
  canvas.width = nw;
  canvas.height = nh;
  const newdata = ctx.createImageData(nw, nh);
  newdata.data.set(decode(rle));
  ctx.putImageData(newdata, 0, 0);
  var image = new Image();
  image.src = canvas.toDataURL();
  return image;
}
function RLE2Region ( rle , image ) { const nw = image . naturalWidth , nh = image . naturalHeight ; var canvas = document . createElement ( "canvas" ) ; var ctx = canvas . getContext ( "2d" ) ; canvas . width = nw ; canvas . height = nh ; const newdata = ctx . createImageData ( nw , nh ) ; newdata . data . set ( decode ( rle ) ) ; ctx . putImageData ( newdata , 0 , 0 ) ; var image = new Image ( ) ; image . src = canvas . toDataURL ( ) ; return image ; }
given the RLE array returns the DOM Image element with loaded image
given the RLE array returns the DOM Image element with loaded image