Here's my C++ module (It's a theme color extractor module, not finished yet)
https://github.com/XadillaX/thmclrx/tree/30665bd6b27c4e7fa9a6c03f038fa56d233420f9/src
And in my test file:
var thmclrx = require("../build/Release/thmclrx.node");
var getPixel = require("get-pixels");
var fs = require("fs");
getPixel("pic.jpg", function(err, pixels) {
var data = pixels.data;
var array = [];
for(var i = 0; i < data.length; i += 4) {
var r = data.readUInt8(i);
var g = data.readUInt8(i + 1);
var b = data.readUInt8(i + 2);
array.push({ r: r, g: g, b: b });
}
result = thmclrx.octreeGet(array);
console.log("done");
var string = "";
for(var i = 0; i < result.length; i++) {
string += "<div style=\"width: 50px; height: 21px; float: left; margin-right: 5px; margin-bottom: 5px; background: #" + result[i].color + "; color: #fff; font-size: 12px; text-align: center; padding-top: 9px;\">" + result[i].count + "</div>";
}
fs.writeFileSync("test.html", string, "utf8");
thmclrx.cleanPool();
process.exit(0);
});
Whether I wrote process.exit(0) or not, the process never exit until I press Ctrl + C.
Is there any problem in my C++ code?