QRCode 이미지 제작(zxing 이용)
C#2011. 8. 18. 14:53
오픈 소스인 zxing(Zebra Crossing) 1.7을 이용한다.
(http://code.google.com/p/zxing/)
(http://code.google.com/p/zxing/)
//인코딩 설정 //zxing의 인코딩 기본값이 ISO-8859-1이므로 //한글처리를 위해 인코딩 힌트를 UTF-8로 설정한다. Hashtable htHint = new Hashtable(); if (cbUTF8.Checked) { htHint.Add(EncodeHintType.CHARACTER_SET, "UTF-8"); //zxing 기본값:ISO-8859-1 } //오류복원레벨 설정 //따로 지정하지 않으면 기본값으로 L이 설정된다. ErrorCorrectionLevel ecLevel = ErrorCorrectionLevel.L; switch (cboEcLevel.SelectedIndex) { case 1: ecLevel = ErrorCorrectionLevel.M; break; case 2: ecLevel = ErrorCorrectionLevel.Q; break; case 3: ecLevel = ErrorCorrectionLevel.H; break; } htHint.Add(EncodeHintType.ERROR_CORRECTION, ecLevel); //기본값:L try { //QRCode 이미지를 만든다. QRCodeWriter writer = new QRCodeWriter(); ByteMatrix bm = writer.encode(txtData.Text, BarcodeFormat.QR_CODE , tbSize.Value, tbSize.Value, htHint); pbQRCode.Image = bm.ToBitmap(); //pictureBox 컨트롤에 표시 } catch (Exception ex) { MessageBox.Show(ex.ToString()); }
'C#' 카테고리의 다른 글
오라클 BLOB 등록 및 조회 (0) | 2016.04.14 |
---|---|
다른 프로젝트의 Resources.resx 파일의 리소스에 접근하기 (0) | 2012.05.07 |
윈도우에 등록된 확장자를 가진 파일 열기 (0) | 2011.11.16 |
날짜 문자열을 DateTime형으로 변환 (0) | 2011.10.27 |
ComboBox SelectedItem (0) | 2011.10.27 |