How to extract bitmap image from ~DG command?

// Expert user has replied.
K Kiho Lee 2 years 7 months ago
54 1 0

Hi all.

I tried to make ZPL preview program.
Using free web service, like labelary, it is very easy to get a preview image.
However there is some limitation like usage under offline, commercial issue etc.

So, I trying to make ZPL preview program and there is something problems.
Our Database has image data using ZPL, especially ~DG command.
For example, here's sample of our image data.

~DGlsel.GRF,01792,028,,T07FIFC,U03FHF8,V03FC0,V01F80,03FF80J07FIFE1C,03FF80I03FJFE38, .....

In this case, how can I extract bitmap image from that commands?
I'm using C# for this program.

thanks in advance for your advice.

Please register or login to post a reply

1 Replies

S Steven Si

The image data in the ~DG command is an ASCII Hex representation of a graphic image. Based on the parameters in the ~DG command, we can derive the image height, the width and the image data. Let's take the following example, which can be found in the ~DG command section in the ZPL User Guide.

~DGR:SAMPLE.GRF,00080,010,
FFFFFFFFFFFFFFFFFFFF
8000FFFF0000FFFF0001
8000FFFF0000FFFF0001
8000FFFF0000FFFF0001
FFFF0000FFFF0000FFFF
FFFF0000FFFF0000FFFF
FFFF0000FFFF0000FFFF
FFFFFFFFFFFFFFFFFFFF

Based on the total number of bytes (0080, i.e. 80 bytes), the number of bytes per row (010, i.e. 10 bytes per row) and the print density (usually, it is 8 dots/mm), you should be able to determine the height and the width of the bitmap in mm. Then, you can use the image data in the ~DG command to populate each bit in the bitmap object based on the platform is used. The .NET has bitmap library API for this purpose.

CONTACT
Can’t find what you’re looking for?