I will draw GS1-DataMatrix in zxing. How do I?

1,502 views
Skip to first unread message

EunMi Lee

unread,
Nov 2, 2015, 1:42:41 AM11/2/15
to zxing
Hello

I coding java.

I will draw GS1-DataMatrix in zxing.

I do not know what API should be used when creating a barcode that GS1-DataMatrix type.

I will appreciate tell us the answer.

gs1_barcode.gif

Lachezar Dobrev

unread,
Nov 2, 2015, 4:56:34 AM11/2/15
to EunMi Lee, zxing
  // ZXing Core Project [1]
  new MultiFormatWriter()//
  .encode("Data Matrix Contents", BarcodeFormat.DATA_MATRIX, 300, 300);

  The 300 and 300 are the desired width and height to fit the matrix in.

  This generates a bit-matrix which you should render in a way appropriate for your platform.
  Typically for a Java SE/EE the
c.g.z.client.j2se.MatrixToImageWriter is the way to go. This is found in the javase sub-project [2].

  [1] https://github.com/zxing/zxing/tree/master/core
  [2] https://github.com/zxing/zxing/tree/master/javase



--
You received this message because you are subscribed to the Google Groups "zxing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

EunMi Lee

unread,
Nov 2, 2015, 8:02:31 PM11/2/15
to zxing, 16the...@gmail.com
Thank you For your answer.
I used this way, But,I made DataMatrix barcodes with different the picture.

I used code

DataMatrixWriter dataMatrixWriter = new DataMatrixWriter();

//char FNC1 = 0xe8; // ASCII 232
char FNC1 = 0x1d; // ASCII 29

//String contents = FNC1 + "01088012345600161719123110A123";
String contents = FNC1 + "01" + "0" + "8801234560016" + "17" + "191231" + "10A123";


BarcodeFormat format = BarcodeFormat.DATA_MATRIX;
int width = 20;
int height = 20;
Map<EncodeHintType, Object> hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "ASCII");

BitMatrix bitMatrix = dataMatrixWriter.encode(contents, format, width, height, hints);

MatrixToImageWriter.writeToStream(bitMatrix, "png", new FileOutputStream(new File("img/img.png")));


How do I GS1-type of encoding is?
How do I use FNC?

2015년 11월 2일 월요일 오후 6시 56분 34초 UTC+9, Lachezar Dobrev 님의 말:

Lachezar Dobrev

unread,
Nov 3, 2015, 5:25:56 AM11/3/15
to EunMi Lee, zxing
  I took another look at this.
  It seems that FNC1 is not supported by ZXing for encoding Data Matrix.
  When decoding Data Matrix with a FNC1 codeword it gets reported as 0x1D character.

Sean Owen

unread,
Nov 3, 2015, 7:42:04 AM11/3/15
to zxing, 16the...@gmail.com
Hm, what does support mean besides that? it's generally translated as ASCII 29.

Lachezar Dobrev

unread,
Nov 4, 2015, 7:16:55 AM11/4/15
to Sean Owen, zxing, EunMi Lee
  The GS1 rules for bar-codes are not easy to read and understand.
  The rules I was able to dig out seem (to me) to point that the GS1 variant of Data Matrix must start with a FNC1 code word, not a <GS> (group separator, 0x001D) symbol. The current Data Matrix encoder does not allow for FNC1 to be encoded. One can encode a <GS>, but that is not the same, and the encoded matrix is different. Which is what I believe the original poster meant.
  It seems FNC1 is also used as a terminator/separator for variable-length elements.
  The GS1 imposes significant requirements on readers, for instance the first FNC1 has to be returned as ']d2' (no quotes), while subsequent FNC1 symbols are to be replaced with a <GS> symbol.
  This all seems a lot of specific content that may be outside the project's scope.

2015-11-03 14:42 GMT+02:00 Sean Owen <sro...@gmail.com>:
Hm, what does support mean besides that? it's generally translated as ASCII 29.

--
Reply all
Reply to author
Forward
0 new messages