feat: add download mask button

This commit is contained in:
2021-03-10 14:32:45 +01:00
parent 3a69f43f23
commit db706e08f5
3 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
export default (img: Image) => {
const canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
const cx = canvas.getContext("2d");
const imageData = new ImageData(
new Uint8ClampedArray(img.overlayData),
img.width,
img.height
);
cx.putImageData(imageData, 0, 0);
var link = document.createElement('a');
link.download = img.name + '_mask.png';
link.href = canvas.toDataURL()
link.click();
}

View File

@@ -1,4 +1,5 @@
export { default as bufToImageUrl } from "./BuffToImg";
export { default as fileToImage } from "./FileToImage";
export { default as countPixels } from "./CountPixels";
export { default as downloadImage } from "./DownloadImage";
export { default as AI } from "./AI";