Skip to content

Commit

Permalink
Added ACS encoding for #7
Browse files Browse the repository at this point in the history
  • Loading branch information
metafloor committed Apr 1, 2022
1 parent 5395ae8 commit 56a1234
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions zpl-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function imageToZ64(img, opts) {

cvs.width = +img.width || img.offsetWidth;
cvs.height = +img.height || img.offsetHeight;
ctx.imageSmoothingQuality = 'high'; // in case canvas needs to scale image
ctx.drawImage(img, 0, 0, cvs.width, cvs.height);
ctx.imageSmoothingQuality = 'high'; // in case canvas needs to scale image
ctx.drawImage(img, 0, 0, cvs.width, cvs.height);

let pixels = ctx.getImageData(0, 0, cvs.width, cvs.height);
return rgbaToZ64(pixels.data, pixels.width, opts);
Expand All @@ -50,7 +50,8 @@ function imageToACS(img, opts) {

cvs.width = +img.width || img.offsetWidth;
cvs.height = +img.height || img.offsetHeight;
ctx.drawImage(img, 0, 0);
ctx.imageSmoothingQuality = 'high'; // in case canvas needs to scale image
ctx.drawImage(img, 0, 0, cvs.width, cvs.height);

let pixels = ctx.getImageData(0, 0, cvs.width, cvs.height);
return rgbaToACS(pixels.data, pixels.width, opts);
Expand Down

0 comments on commit 56a1234

Please sign in to comment.