mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
added image-byte-array
util
This commit is contained in:
parent
889f069012
commit
ed2515a26c
14
packages/server/src/utils/image-byte-array/index.js
Normal file
14
packages/server/src/utils/image-byte-array/index.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export default (image, numChannels) => {
|
||||||
|
const pixels = image.data
|
||||||
|
const numPixels = image.width * image.height
|
||||||
|
|
||||||
|
const values = new Int32Array(numPixels * numChannels)
|
||||||
|
|
||||||
|
for (let i = 0; i < numPixels; i++) {
|
||||||
|
for (let channel = 0; channel < numChannels; ++channel) {
|
||||||
|
values[i * numChannels + channel] = pixels[i * 4 + channel]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return values
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user