Печать растрового изображения на Epson TM-T88V

Следуя приведенному здесь руководству: -c-and-escpos/" rel="nofollow noreferrer">http://nicholas.piasecki.name/blog/2009/12/sending-a-bit-image-to-an-epson-tm-t88iii-receipt -printer-using-c-and-escpos/

Я столкнулся с проблемой. Мое растровое изображение имеет небольшие линии, разделяющие каждый фрагмент данных, как можно увидеть в этом предыдущем вопросе здесь: Как распечатать битовое изображение TM-T88V.

После этого я столкнулся с другой проблемой, теперь все изображение сжато. Увеличение межстрочного интервала разбивает изображение на 12 групп по 3 (как и ожидалось), а увеличение и уменьшение смещения удлиняет и сжимает изображение.

Вот изображения:

  • 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

Я использую язык ESC/POS и C#. Хранение растрового изображения во флэш-памяти, а также использование кодов «GS» не вариант.

Любая помощь будет оценена по достоинству.

Я включил свой код ниже:

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();
    }
}

person Zephrys    schedule 02.10.2014    source источник