Code: Select all
def bitmap(self, data, length=0, density=0):
if length == 0:
length = len(data)
if 0 < length < 1023:
# length_lower = int(length & ord('\xff')).to_bytes()
# length_higher = int((length & ord('\x03')<<8)>>8).to_bytes()
# self.write(const.ESC_st + bytes(density) + length_lower + length_higher + bytes(data))
self.write(const.ESC_st + density.to_bytes(1, "little") + length.to_bytes(2, "little") + bytes(data))
else:
raise Exception
\x1B\x2A + (decimal value for density converted to bytes, assuming darkness or similar, but default is zero, little endian, length 1) + (length of the data converted to bytes, little endian, length 2) + (data, converted to bytes)
This should then print my logo on the Epson Printer (as thanks to vuott code it converts it to Hex data)