Image (PCX) for EPL2 Zebra printer

2019-02-20 09:13发布

I am having trouble producing and uploading graphics to an EPL2 printer.

Having tired quite literally any pieces of software available and trawled the internet, I am at a loss.

I have a 1 bit file which I try to upload with the following script..

setppi.txt

GK"NAMEPCX"
GK"NAMEPCX" 
GM"NAMEPCX"3042

and then upload with

copy setppi.txt+ppirmt.pcx lpt1/b

Has anyone with experience got any tips before I tear out what is remaining of my hair? I am almost certain that this issue is to do with the creation of the pcx but having tried all options, I am unsure as to my next step.

4条回答
戒情不戒烟
2楼-- · 2019-02-20 09:45

Here's the way I found to create the PCX properly:

In gimp, save the file as a 1-bit (black and white) BMP. Don't select PCX because the saved format is not 1-bit PCX as required by the printer!

Use imagemagick's convert program to convert your BMP to PCX.

The other issue I ran across after I got that down was that graphics were still corrupt, that was a codepage issue, so watch out for that.

查看更多
一夜七次
3楼-- · 2019-02-20 09:51

Disclaimer: I am currently writing a SVG-to-EPL-transpiler, which can be found here

I was facing the same issue lately, and solved it with sending a GW-command to the printer.

The main difference to GK-GK-GM-GG is that you don't send the PCX-header along, but rather the raw binary data (afaik without LRE compression).

I used following (non-optimized/naive) C# code, which heavily uses bit-shifting. The algorithm can be implemented in any language though and is straightforward:

[NotNull]
public IEnumerable<byte> GetRawBinaryData([NotNull] Bitmap bitmap,
                                          int octetts)
{
  var height = bitmap.Height;
  var width = bitmap.Width;

  for (var y = 0;
        y < height;
        y++)
  {
    for (var octett = 0;
          octett < octetts;
          octett++)
    {
      var value = (int) byte.MaxValue;

      for (var i = 0;
            i < 8;
            i++)
      {
        var x = octett * 8 + i;
        var bitIndex = 7 - i;
        if (x < width)
        {
          var color = bitmap.GetPixel(x,
                                      y);
          if (color.A > 0x32
              || color.R > 0x96 && color.G > 0x96 && color.B > 0x96)
          {
            value &= ~(1 << bitIndex);
          }
        }
      }

      yield return (byte) value;
    }
  }
}

The thing you have to keep in mind for conversions:

  • 1: white dot
  • 0: black dot
  • width has to be a multiple of 8 (as we are sending bytes) - the code above takes care of this by padding
  • rotation/orientation of the label!
  • some threshold is implemented here ...

I have also implemented GM-GG, but this would go beyond the scope of this answer. The relevant code can be found in EplCommands.StoreGraphics(bitmap:Bitmap,name:string).

查看更多
Rolldiameter
4楼-- · 2019-02-20 09:53

You don't mention which programming language you're using.

If it's C# (or .NET in general), then here's a blog post about printing images with EPL:
Using the EPL2 GW command to send an image to a Zebra thermal printer

And another blog post from the same guy, that got me started with printing EPL to Zebra printers with C#.

查看更多
时光不老,我们不散
5楼-- · 2019-02-20 10:03

There're two ways to output PCX graphics using EPL2 language. The first one is the one you suggested:

GK"namepcx"
GK"namepcx"
GM"namepcx",3042
..... and here follows monochrome PCX data ...
..... with 128-bit header and following pixel data 1 bit-per pixel..

later you should be able to write this stored "namepcx" to printer's image buffer via GM however I spent two days trying store PCX, but it would never be stored correctly. So I ended up simply using GW command to write pixel data directly to the printers image buffer. Avoiding "storing in flash memory". Also originally this "flash" storage via GM was meant to store some image (like logo) which would repeat on all labels. Thus you may store it once and then print 10 000 labels with the same logo. However if priting from java, usually you would be printing many different images on different labels. Thus if you store to flash new image for every label, then you will "wear off" flash memory really quickly. (Eg. manual for LP 2824 printer says that flash memory only has 100k write cycles).

So it may seem that using GW to write imag directly to image buffer instead of using 3-step GK GM GG may be a better solution.

查看更多
登录 后发表回答