encode in EAN 13 exemple

1,635 views
Skip to first unread message

Francois Wauquier

unread,
Nov 2, 2009, 10:16:30 AM11/2/09
to zxing
I have not found any exemple of a EAN 13 barCode generation.
Tried with this:

Hashtable hintsTable = new Hashtable();

ByteMatrix byteMatrix = new MultiFormatWriter().encode(text,
BarcodeFormat.EAN_13, 113, 98, hintsTable);

File file = new File(text + ".gif");

MatrixToImageWriter.writeToFile(byteMatrix, "image/gif", file);


but it only generate an empty file (lenght of 0 bytes).

Sean Owen

unread,
Nov 2, 2009, 10:55:47 AM11/2/09
to zxing
There is no support for generating EAN barcodes at the moment.

Francois Wauquier

unread,
Nov 3, 2009, 4:04:54 AM11/3/09
to zxing
com.google.zxing.oned.EAN13Writer
is like dead code ?

Sean Owen

unread,
Nov 3, 2009, 7:17:37 AM11/3/09
to zxing
Hmm, no I'm just completely wrong. I didn't even know this existed or
had forgotten all about... been so long since I looked at this. I will
look into why this doesn't work, since it seems like it should.

Sean Owen

unread,
Nov 3, 2009, 7:33:30 AM11/3/09
to zxing
Oh, the problem is that you need to pass "gif", not "image/gif", for
the format. Weird that javax.imageio doesn't throw an exception.

But it looks like there is a smaller problem with the code, it
generates barcodes that are inverted -- white on black. I can fix
that.

On Nov 2, 3:16 pm, Francois Wauquier <wok...@gmail.com> wrote:

Francois Wauquier

unread,
Nov 3, 2009, 7:55:17 AM11/3/09
to zxing
OK

It now generates an image that looks like a barCode, but that cannot
be red.
Surely because of the black/white inversion you talked about.

Sean Owen

unread,
Nov 3, 2009, 9:43:06 AM11/3/09
to zxing
Right. Try the latest code from SVN now.

Francois Wauquier

unread,
Nov 3, 2009, 10:22:26 AM11/3/09
to zxing
With your last modif in svn:
http://code.google.com/p/zxing/source/diff?spec=svn1095&r=1095&format=side&path=/trunk/javase/src/com/google/zxing/client/j2se/MatrixToImageWriter.java

It works with png format.

ByteMatrix byteMatrix = new MultiFormatWriter().encode
(text,BarcodeFormat.EAN_13, 113, 98);
File file = new File(text + ".png");
MatrixToImageWriter.writeToFile(byteMatrix, "png", file);
Reply all
Reply to author
Forward
0 new messages