ASCII十六进制编码? [英] ASCII Hexadecimal Encoding?

查看:79
本文介绍了ASCII十六进制编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了Zebra ZPL2命令(条形码打印机)的编程手册.我正在尝试将PNG图形下载到打印机.手册指出图像数据必须采用"ASCII十六进制编码".我尝试了下面的代码,但没有成功.

I've reading the programming manual for Zebra ZPL2 commands (barcode printer). I'm trying to download a PNG graphic to the printer. The manual states that the image data must be in "ASCII hexadecimal encoding".  I've tried the code below without success.

 

byte [] byteArray = File.ReadAllBytes(filePath);

byte[] byteArray = File.ReadAllBytes(filePath);

string imageHex = BitConverter.ToString(byteArray).Replace(-",");

string imageHex = BitConverter.ToString(byteArray).Replace("-","");

byte [] byteArray = File.ReadAllBytes(filePath);

byte[] byteArray = File.ReadAllBytes(filePath);

string asciiString = Encoding.ASCII.GetString(byteArray);

string asciiString = Encoding.ASCII.GetString(byteArray);

byte [] byteArrayASCII =  Encoding.ASCII.GetBytes(asciiString);

byte[] byteArrayASCII =  Encoding.ASCII.GetBytes(asciiString);

string imageHex = BitConverter.ToString(byteArrayASCII).Replace(-",");

string imageHex = BitConverter.ToString(byteArrayASCII).Replace("-","");

 

谢谢

罗恩

 

推荐答案

您可能需要的格式是:

The format you probably need is:

for(int i = 0; i< byteArray.Length; i ++)

for (int i = 0; i < byteArray.Length; i++)

{
   imageHex + = byteArray [i] .ToString("X2");
}

{
   imageHex +=byteArray[i].ToString("X2");
}

过去,Zebras不会接受PNG,但只接受GRF(基本上是没有标题的PCX格式)...

In the old days, Zebras would not accept PNG, only GRF (basically a PCX format without headers) though ...

克里斯蒂安.


这篇关于ASCII十六进制编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆