Bitmap printing on Epson TM-T88V
After reading the manual: http://nicholas.piasecki.name/blog/2009/12/sending-a-bit-image-to-an-epson-tm-t88iii-receipt-printer-using-c-and-escpos /
I have a problem. My bitmap has small lines separating each piece of data, as can be seen in this previous question: How to print the TM-T88V Image bit .
After that I ran into another problem, now the whole image is compressed. Increasing the line spacing divides the image into 12 groups of 3 (as expected), while increasing and decreasing the offset lengthens and bleeds through the image.
Here are the images:
- imagizer.imageshack.us/v2/150x100q90/673/d6dYRS.png
- imagizer.imageshack.us/v2/150x100q90/538/oEpbVd.jpg
- imagizer.imageshack.us/v2/150x100q90/537/NUAHrZ.jpg
- imagizer.imageshack.us/v2/150x100q90/909/uPqWFI.jpg
I am using ESC / POS and C # language. Storing the bitmap in flash memory as well as using "GS" codes is not an option.
Any help would be appreciated.
I have included my code below:
private static byte[] ConvertMethodByteArray(tBitmapData bmpdata)
{
using (var ms = new MemoryStream())
using (var bw = new BinaryWriter(ms))
{
int offset = 0;
var iWidth = BitConverter.GetBytes(bmpdata.Width);
var iWidthPage = (bmpdata.Width * 2) + 30;
bw.Write((char)0x1B); //ASCII Escape
bw.Write((char)'L'); // PageMode
bw.Write((char)0x1B); //ASCII Escape
bw.Write((char)'W'); //Print region in pagemode
bw.Write((byte)0); //xl
bw.Write((byte)0); //xh
bw.Write((byte)0); //yl
bw.Write((byte)0); //yh
bw.Write((byte)0); //dxl
bw.Write((byte)0); //dxh
bw.Write((iWidthPage % 256)); //dyl
bw.Write((iWidthPage / 256)); //dyh
bw.Write((char)(0x1B)); // ASCII Escape
bw.Write((char)('T')); // Print Direction
bw.Write((byte)(0)); // Right to left
bw.Write((char)0x1B); // ASCII Escape character
bw.Write('3'); // Change line height
bw.Write((byte)24); // line height 24
while (offset < bmpdata.Height)
{
//bw.Write((char)0x1B); // ESC FF here prints each line then moves on
//bw.Write((char)0x0c); // FF prints and leaves printmode
//..(but leaves image in tact with lines)
bw.Write((char)0x1B); // ASCII Escape character
bw.Write('*'); // bit-image mode
bw.Write((byte)33); // 24 - dot double density
bw.Write(iWidth[0]); // Width low byte
bw.Write(iWidth[1]); // width hight byte
for (int x = 0; x < bmpdata.Width; x++)
{
// 24 dots = 24 bits = 3 bytes
for (int k = 0; k < 3; k++)
{
byte slice = 0;
// 8 bits in a byte
for (int b = 0; b < 8; b++)
{
// For calculating the y position we are currently trying to draw
int y = (((offset / 8) + k) * 8) + b;
// Calculate the position of y in the bit array
int i = (y * bmpdata.Width) + x;
// If the image (or stripe) is shorter than 24 pad with 0
bool v = false;
if (i < bmpdata.data.Length)
{
v = bmpdata.data[i];
}
// store the bit in the current byte, bitshift and
// ..or to get b in the correct location
slice |= (byte)((v ? 1 : 0) << (7 - b));
}
bw.Write(slice);
}
}
//Done with 1 24 dot pass, go to new line and increase offset
offset += 24;
bw.Write((char)0x0A);
}
bw.Write((char)0x0c); // FF exit pagemode and print data
bw.Write((char)0x1B); // ESC
bw.Write('3'); // Line spacing
bw.Write((byte)30); // 30
return ms.ToArray();
}
}
source to share
No one has answered this question yet
See similar questions:
or similar: