참고로, 여기서 생산된 스싱 400x400 QR 코드 예제를 사용하여 라이브러리:
! 예 QR 코드
최신 버전의 스싱 설정할 수 있습니다 (기본적으로) 의 본질적 패딩 QR 코드) 의 크기는 정숙형 파워존에서 공급해 오버클로킹된 int value 를 ['니고데힌티페스마르긴'] [3] 키. 힌트 '' you '작성기에 공급이 이를 포함할 단순히' & # 39 의 매핑해야 ['인코딩합니다 (.)'] [4] 방법 (예:
Map<EncodeHintType, Object> hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 2); /* default = 4 */
이 옵션을 변경할 경우 위험 낮춘 디코딩합니다 성공시키지 못했다.
[1]: http://en.wikipedia.org/wiki/Postel% 27s_law [2]: https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/qrcode/QRCodeWriter.java # L38 [3]: https://zxing.github.io/zxing/apidocs/com/google/zxing/EncodeHintType.html # 여백 [4]: http://zxing.org/w/docs/javadoc/com/google/zxing/MultiFormatWriter.html # % % % % encode% 28java.lang.string 20com.google.zxing.barcodeformat 20int 20int 20java.util.map% 29,,
심지어 '이' 0 ',' 을 설정하여 니고데힌티페스마르긴 알고리즘입니다 크레코드 변환하십시오 " dot"; matrix 를 픽셀입니다 데이터를 생성할 수 있는 작은 여백 (알고리즘을 적용 일정한 수의 픽셀입니다 호스트당 점 때문에 여백 픽셀 크기는 나머지 정수 부분 픽셀입니다 사이즈를 joyon. qr 코드 크기).
그러나, 이 " joyon. pixel" 완전히 무시할 수 있습니다. 세대: 도트 매트릭스 '있다' 고 직접 계산하는 너회들 크레코드 호출하여 코맥구글리츠형자크르고데이니고데리엔코더 클래스, 그리고 픽셀 이미지 구하겠죠 발령합니다 코드 (아래 참조).
// Step 1 - generate the QRCode dot array
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(1);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
QRCode qrCode = Encoder.encode(what, ErrorCorrectionLevel.L, hints);
// Step 2 - create a BufferedImage out of this array
int width = qrCode.getMatrix().getWidth();
int height = qrCode.getMatrix().getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
int[] rgbArray = new int[width * height];
int i = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
rgbArray[i] = qrCode.getMatrix().get(x, y) > 0 ? 0xFFFFFF : 0x000000;
i++;
} }
image.setRGB(0, 0, width, height, rgbArray, 0, width);
데이터가 그대로 부프레디마지 PNG 로 전환 '을' 운동이 판독기입니다 한 점이 일정한 수의 픽셀입니다 설정하여 이미지를 확장할 수도 있습니다.
HashMap hintMap = new HashMap();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q);
hintMap.put(EncodeHintType.MARGIN, -1);
여백 없음
종속도 () 의 주석) 추가
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.2.0</version>
</dependency>
let hints = ZXEncodeHints()
hints!.margin = NSNumber(int: 0)
let result = try writer.encode(code, format: format, width: Int32(size.width), height: Int32(size.height), hints: hints)
let cgImage = ZXImage(matrix: result, onColor: UIColor.blackColor().CGColor, offColor: UIColor.clearColor().CGColor).cgimage
let QRImage = UIImage(CGImage: cgImage)