-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathu32.js
56 lines (54 loc) · 1.11 KB
/
u32.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module.exports = {
name: "u32",
ns: "jsfeat",
description: "To U32",
phrases: {
active: "Converting to U32"
},
ports: {
input: {
imageData: {
title: "Image Data",
type: "ImageData"
},
img_u8: {
title: "Img U8",
type: "function"
}
},
output: {
imageData: {
title: "Image Data",
type: "ImageData"
},
img_u8: {
title: "Img U8",
type: "function"
}
}
},
fn: function u32(input, $, output, state, done, cb, on) {
var r = function() {
// in-place
const data_u32 = new Uint32Array($.imageData.data.buffer)
const alpha = (0xff << 24)
let i = $.img_u8.cols * $.img_u8.rows
let pix = 0;
while (--i >= 0) {
pix = $.img_u8.data[i]
data_u32[i] = alpha | (pix << 16) | (pix << 8) | pix
}
output({
imageData: $.write('imageData', $.imageData),
img_u8: $.write('img_u8', $.img_u8)
});
done();
}.call(this);
return {
output: output,
state: state,
on: on,
return: r
};
}
}