-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for alpha channel and compressed 16-bit images
- Loading branch information
Showing
9 changed files
with
183 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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 characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
// Section 14: Differencing Predictor (p. 64) | ||
|
||
export function applyHorizontalDifferencing( | ||
export function applyHorizontalDifferencing8Bit( | ||
data: Uint8Array, | ||
width: number, | ||
components: number, | ||
): void { | ||
let i = 0; | ||
while (i < data.length) { | ||
for (let j = 1; j < width; j++) { | ||
data[i + j] = (data[i + j] + data[i + j - 1]) & 255; | ||
for (let j = components; j < width * components; j += components) { | ||
for (let k = 0; k < components; k++) { | ||
data[i + j + k] = | ||
(data[i + j + k] + data[i + j - (components - k)]) & 255; | ||
} | ||
} | ||
i += width; | ||
i += width * components; | ||
} | ||
} | ||
|
||
export function applyHorizontalDifferencingColor( | ||
data: Uint8Array, | ||
export function applyHorizontalDifferencing16Bit( | ||
data: Uint16Array, | ||
width: number, | ||
components: number, | ||
): void { | ||
let i = 0; | ||
while (i < data.length) { | ||
for (let j = 3; j < width * 3; j += 3) { | ||
data[i + j] = (data[i + j] + data[i + j - 3]) & 255; | ||
data[i + j + 1] = (data[i + j + 1] + data[i + j - 2]) & 255; | ||
data[i + j + 2] = (data[i + j + 2] + data[i + j - 1]) & 255; | ||
for (let j = components; j < width * components; j += components) { | ||
for (let k = 0; k < components; k++) { | ||
data[i + j + k] = | ||
(data[i + j + k] + data[i + j - (components - k)]) & 65535; | ||
} | ||
} | ||
i += width * 3; | ||
i += width * components; | ||
} | ||
} |
This file contains 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 characters
Oops, something went wrong.