我正在尝试使用Javascript中的ESC POS命令来打印图像日期,但直到现在,废纸is打印出来。
命令ESC *
我正在使用Javascript,尝试直接打印以将bit64字符串中的图像发送出去。
I tried this example with ESC @, ESC * command in Javscript
它只打印我的字符,而不打印图像
预先感谢
// let image = context.getImageData(0, 0, width, height)
getImageData(image, Width, Height){
var dimensions = Width * Height
var dots = new Uint8Array(dimensions)
var index = 0
var threshold = 127;
for (var y = 0; y < Height; y++)
{
for (var x = 0; x < Width; x++)
{
var color = this.getPixelI(image, x, y)
//let luminance
let luminance = (0.2126* color[0] + 0.7152 * color[1] + 0.0722 * color[2]);
dots[index] = luminance < threshold
index++;
}
}
return dots
}
getPixelI(imgData, x, y) {
var i = y * (imgData.width * 4) + x * 4;
var d = imgData.data;
return [d[i],d[i+1],d[i+2], d[i+3]] // returns array [R,G,B,A]
}