- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
使用 Esc/Pos,我想将位图图像上传到打印机上的 NV 显存。
我正在使用 GS ( L / GS 8 L
<Function 67>
Esc/Pos 手册。
我可以使用 <Function 65>
和 <Function 66>
删除所有或一个图形。
我知道在将位图添加到函数时我遗漏了一些东西。
这是我的命令字符串,包括位图。 bitmapString
删除了位图的文件头和信息头(前 62 个字节)(DataOffset)。:
String bitmapString = new String(bitmapBytes, Charsets.US_ASCII);
bitmapString = bitmapString.substring(DataOffset, bitmapStringSize);
String commandString = "";
int commandLength = (bitmapStringSize.length) + 11;
pL = commandLength % 256;
if (commandLength < 256) {
pH = 0;
} else {
pH = (commandLength - pL) / 256;
}
xL = bitmapWidth % 256;
if (bitmapWidth < 256) {
xH = 0;
} else {
xH = (bitmapWidth - (bitmapWidth % 256)) / 256;
}
yL = bitmapHeight % 256;
if (bitmapHeight < 256) {
yH = 0;
} else {
yH = (bitmapHeight - (bitmapHeight % 256)) / 256;
}
commandString
+= Utils.H("1B")// 27
+ Utils.H("40") // 64
+ Utils.H("1B") // 27
+ Utils.H("3D") // 61
+ Utils.H("01") // 1
+ Utils.H("1D") // GS = 29
+ Utils.H("28") // ( = 40
+ Utils.H("4C") // L = 76
+ Utils.D(pL) // pL
+ Utils.D(pH) // pH
+ Utils.H("30") // m = 48
+ Utils.H("43") // fn = 67
+ Utils.H("30") // a = 48
+ Utils.H(KC1) // kc1
+ Utils.H(KC2) // kc2
+ Utils.H("01") // b = 1
+ Utils.D(xL) // xL
+ Utils.D(xH) // xH
+ Utils.D(yL) // yL
+ Utils.D(yH) // yH
+ Utils.H("31");// c = 49
commandString += bitmapString;
我正在使用 ePOS-Print.jar 打开并写入打印机:
EpsonIo epsonio = new EpsonIo();
byte[] commandBytes = commandString.getBytes(Charsets.US_ASCII);
epsonio.open(DevType.BLUETOOTH, MAC, null, ESCPosService.this);
while (n > 0) {
epsonio.write(commandBytes, i, n > bufferSize ? bufferSize : n, SEND_TIMEOUT);
Thread.sleep(450);
i += bufferSize;
n -= bufferSize;
}
但是当我打印图形时它变形了:
最佳答案
我已经解决了这个问题。
发送的位图字节必须使用下面的方法进行解码。该方法将位图像素转换为单色字节。 1 或 0。
希望这对 future 的人有所帮助!
public static byte[] decodeBitmap(byte[] bitmapBytes) {
Bitmap bmp = BitmapFactory.decodeByteArray(bitmapBytes, 0, bitmapBytes.length);
int zeroCount = bmp.getWidth() % 8;
String zeroStr = "";
if (zeroCount > 0) {
for (int i = 0; i < (8 - zeroCount); i++) {
zeroStr = zeroStr + "0";
}
}
List<String> list = new ArrayList<>();
for (int i = 0; i < bmp.getHeight(); i++) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < bmp.getWidth(); j++) {
int color = bmp.getPixel(j, i);
int r = (color >> 16) & 0xff;
int g = (color >> 8) & 0xff;
int b = color & 0xff;
// if color close to white,bit='0', else bit='1'
if (r > 160 && g > 160 && b > 160)
sb.append("0");
else
sb.append("1");
}
if (zeroCount > 0) {
sb.append(zeroStr);
}
list.add(sb.toString());
}
List<String> bmpHexList = binaryListToHexStringList(list);
List<String> commandList = new ArrayList<>();
commandList.addAll(bmpHexList);
return hexListToBytes(commandList);
}
关于JAVA ESC Pos上传NV图形到打印机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37262647/
我计划使用 pos for .net 创建我自己的 POS 系统。 到目前为止,我从未创建过任何 POS 系统或为 .net 使用过 pos。我试图找到一些教程但没有成功,有人知道一些好的网站或书籍吗
阅读 pygame 教程 here ,你会发现这个例子:(箭头是我的) for o in objects: screen.blit(background, o.pos, o.pos) # Re
所以我一直在为蓝牙打印机编写 Android 应用程序一段时间,我意识到这实际上是 ESC/POS 标准:http://nicholas.piasecki.name/blog/wp-content/u
我设法在 上更改了 POS 收据模板/addons/point_of_sale/static/src/xml/pos.xml 其中位于: 但是如何更改 PosTicket 上的详细信息?
我有一个长度为 32 的字符数组,想从中取出某些字符。例如 111111000000000000000000111111 #include #include /* Creates a sub-s
Parsey McParseface输出的POS标签和Depedency标签在 tag-set 中给出和 label-set文件 here分别。 Syntaxnet自述文件概述了该模型是在 Penn
我正在尝试使用 Stanford POS-tagger,我想问一下是否可以解析(实际上只有 pos 标签就足够了)英文文本并以 conll 格式输出结果。有这样的选择吗? 我正在使用 Stanford
我有使用 NLTK 的平均感知器标记器进行词性标记的代码: from nltk.corpus import wordnet from nltk.stem import WordNetLemmatize
我正在尝试为 58mm POS 热敏打印机编写正确的 ESC/POS 命令。我尝试将此命令作为 ASCII 文本输入,并将其转换为 HEX,但在这两种情况下,打印机都只打印此代码,而不是收据输出。代码
我正在使用 spaCy 库进行 POS 标记,但是当我运行这段代码时,它会返回数字来代替 pos 标签: import spacy from spacy.lang.fr.examples import
我博客的标题显示标题后面有一张图片。我希望这张图片有自己的高度直到它变得大于50vh(用户视口(viewport)的 50%)。 但正常行为是图像从底部裁剪,我希望图像从顶部和底部裁剪(换句话说:我希
我正在阅读句子列表并使用 NLTK 的 Stanford 词性标注器标记每个单词。我得到这样的输出: wordnet_sense = [] for o in output: a = st.ta
我们正在尝试实现一个支持 COM 接口(interface)的 .NET 服务对象来模拟 POSPrinter,但仍然与旧技术兼容。 我们在下面的类中有我们的接口(interface)和类对象。 us
我有一个列表 list = ['about','above','account','address','after'] 我将其传递给 nltk pos 标签 函数,输出看起来像这样以列表的形式: [(
有谁知道为什么“深度”(vertShader) 不同于“gl_FragCoord.z”(从 opengl 渲染)?特别是随着 z 的减小,差异变得更大。 “深度”是否有可能在更高的 z 值下更精确?
假设我有一个 block 元素,例如 h2: Title 然后我给它一个背景色。背景将跨越 wrapper 的整个宽度(应该如此)。 如果我 float 它,或者 position: absolute
我提供了一个 fiddle : http://jsfiddle.net/dCYdw/ 这个例子很惨,但是问题也能看出来。 .levelFive 是问题所在。这应该在所有其他元素之前,因为它的 z-in
C++(STL): Request for member ‘push_back’ in ‘pos.std::vector::operator[](((std::vector::size_type)i)
以下 JavaScript 中包含云图像的元素的动画的逻辑错误到底是什么?我认为“pos”变量似乎在每次迭代中都偏离了方向,而且我无法弄清楚每次迭代时云图像的运动如何变得越来越疯狂。 //CSS: #
我正在尝试在RMarkdown文档中插入图形,但无法将其显示在正确的位置。下图显示了该问题:使用图标题时,该图显示在页面顶部而不是文档中相关段落的下面。 这是此最小工作示例的代码: --- title
我是一名优秀的程序员,十分优秀!