All I can say is, I think you have misunderstood what your printer specification says. Everything in a file is bytes. Whether those bytes represent a GIF image or a MS Word document or something else is a matter of interpretation. I don't understand what "raw" bytes meant to the people who wrote that document, or what "graphic file formatting" meant, so I can't help you with that.
As for your code, I can't tell whether it reads the file into an array of bytes correctly or not. There's certainly scope for off-by-one errors in it. If I had to read a file into an array of bytes, I would just open a DataInputStream onto the file and use its readFully() method to do that, so I don't feel like looking hard at your code. But it's more likely that you could just use a standard piece of file-copying code to send the image to the printer, instead of risking running out of memory if your file was exceptionally large.
Joined: Jan 07, 2004
Thanks for your reply.
I have also tried to read the image into a FileInputStream with the code below, but with no succes:
Regarding the specification this is a copy from the documentation:
DATA = Raw binary data without graphic file formatting. Data must be in bytes. Multiply the width in bytes (p3) by the number of print lines (p4) for the total amount of graphic data. The printer automatically calculates the exact size of the data block based upon this formula.
Great, ByteArrayOutputStream seems to work. Now a dark square is being printed to the label. So far so good
When sending data to the printer I have to send some parameters as well, i.e. the position (p1, p2) and the width (p3) and lenght (p4) of the image in bytes.
I am unsure about how to calculate p3 and p4? What is the width of graphic in bytes? And what is length of graphic in dots? I don´t get it.
I got the size of the image by using:
int imageSize = graphic.length;
EPL2 Documentation of GW:
p3 =Width of graphic in bytes. Eight (8) dots = One (1) byte of data
p4 =Length of graphic in dots (or print lines).
DATA = Data must be in bytes. Multiply
the width in bytes (p3) by the number
of print lines (p4) for the total
amount of graphic data. The printer automatically
calculates the exact size of
the data block based upon this formula.