Created
June 1, 2013 12:12
-
-
Save trajano/5690175 to your computer and use it in GitHub Desktop.
Creating a QR Code using ZXING
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import org.junit.Test; | |
import com.google.zxing.BarcodeFormat; | |
import com.google.zxing.Writer; | |
import com.google.zxing.WriterException; | |
import com.google.zxing.client.j2se.MatrixToImageWriter; | |
import com.google.zxing.common.BitMatrix; | |
import com.google.zxing.qrcode.QRCodeWriter; | |
public class ZXingTest { | |
@Test | |
public void createQRCodeToStream() throws WriterException, IOException { | |
final Writer w = new QRCodeWriter(); | |
final BitMatrix bitMatrix = w.encode("http://www.trajano.net", | |
BarcodeFormat.QR_CODE, 200, 200); | |
final FileOutputStream stream = new FileOutputStream("foo.png"); | |
MatrixToImageWriter.writeToStream(bitMatrix, "png", stream); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment