zxing2는 다이렉트로 구현된 ZXing 바코드 처리 라이브러리로, 다양한 형식의 1차원 및 2차원 바코드 스캔과 생성을 지원합니다. 인기 있는 안드로이드 ZXing 라이브러리의 포트로, 플러터 앱에서 크로스플랫폼 바코드 기능을 가능하게 합니다. 이 패키지는 안드로이드, iOS, 웹, macOS, Windows, 리눅스에서 작동하여 다양한 장치에서 신뢰할 수 있는 바코드 읽기 및 쓰기 기능이 필요한 애플리케이션에 적합합니다.
사용 사례
모바일 앱에서 QR 코드 스캔하기
재고 추적을 위한 바코드 생성
소매 앱에서 제품 코드 읽기
웹 애플리케이션에서 바코드 입력 통합
바코드가 있는 문서 스캔 지원
주요 기능
크로스 플랫폼 바코드 지원
바코드 탐지의 높은 정확도
다양한 형식(QR, Data Matrix, PDF417 등)을 지원합니다
가볍고 빠른 처리
Flutter UI와의 간편한 통합
적합한 대상
바코드 스캔이 필요한 모바일 및 웹 앱
전자상거래 및 물류 애플리케이션
재고 및 자산 관리 도구
바코드를 통한 안전한 데이터 인코딩을 필요로 하는 앱
다중 플랫폼에서 네이티브에 가까운 성능을 원하는 개발자
고려 사항
모바일 플랫폼에서는 카메라 권한이 필요합니다
저사양 기기용 최적화가 필요할 수 있습니다
이미지 기반 바코드 처리에 제한됨
스캔용 내장 UI 컴포넌트 없음
성능은 이미지 품질과 조명 조건에 따라 달라집니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
zxing-dart
ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library.
This package is a pure Dart port of the original Java library.
For now, it only supports QR-Code (encoding and decoding). New format can easily be added if this port proves useful.
Getting started
QR Code
Decoding
The QRCodeReader class takes a list of bytes and returns the decoded barcode.
import'dart:io';
import'package:image/image.dart'as img;
import'package:zxing2/qrcode.dart';
voidmain() {
var image = img.decodePng(File('tool/example.png').readAsBytesSync())!;
LuminanceSource source = RGBLuminanceSource(
image.width,
image.height,
image
.convert(numChannels: 4)
.getBytes(order: img.ChannelOrder.abgr)
.buffer
.asInt32List());
var bitmap = BinaryBitmap(GlobalHistogramBinarizer(source));
var reader = QRCodeReader();
var result = reader.decode(bitmap);
print(result.text);
}
Encoding
The QRCodeReader class takes a list of bytes and returns the decoded barcode.
import'dart:io';
import'package:image/image.dart'as img;
import'package:zxing2/qrcode.dart';
voidmain() {
var qrcode = Encoder.encode('ABCDEF', ErrorCorrectionLevel.h);
var matrix = qrcode.matrix!;
var scale = 4;
var image = img.Image(
width: matrix.width * scale,
height: matrix.height * scale,
numChannels: 4);
for (var x = 0; x < matrix.width; x++) {
for (var y = 0; y < matrix.height; y++) {
if (matrix.get(x, y) == 1) {
img.fillRect(image,
x1: x * scale,
y1: y * scale,
x2: x * scale + scale,
y2: y * scale + scale,
color: img.ColorRgba8(0, 0, 0, 0xFF));
}
}
}
var pngBytes = img.encodePng(image);
File('tool/examples/encoded.png').writeAsBytes(pngBytes);
}
Flutter
The example folder contains a full example that uses the official camera plugin connected to this
package to decode barcode from the bytes stream.