Created
November 5, 2023 06:56
-
-
Save ledunguit/25941684bf4ed949d2d760f439af6eb8 to your computer and use it in GitHub Desktop.
Revisions
-
ledunguit created this gist
Nov 5, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ function addAlphaChannelToUnit8ClampedArray(unit8Array: Uint8ClampedArray, imageWidth: number, imageHeight: number) { const newImageData = new Uint8ClampedArray(imageWidth * imageHeight * 4); for (let j = 0, k = 0, jj = imageWidth * imageHeight * 4; j < jj; ) { newImageData[j++] = unit8Array[k++]; newImageData[j++] = unit8Array[k++]; newImageData[j++] = unit8Array[k++]; newImageData[j++] = 255; } return newImageData; }