
专注于为中小企业提供成都做网站、网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业永仁免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
码生成能够根据给定的字符串信息,生成相应的二维码图片。常见应用场景举例:
码生成提供了的 IBarcodeDetector()接口,常用方法的功能描述如下:
| 接口名 | 方法 | 功能描述 |
|---|---|---|
| IBarcodeDetector | int detect(String barcodeInput, byte[] bitmapOutput, int width, int height); | 根据给定的信息和二维码图片尺寸,生成二维码图片字节流。 |
| IBarcodeDetector | int release(); | 停止QR码生成服务,释放资源。 |
import ohos.cvinterface.common.ConnectionCallback;import ohos.cvinterface.common.VisionManager;import ohos.cvinterface.qrcode.IBarcodeDetector; ConnectionCallback connectionCallback = new ConnectionCallback() {
@Override
public void onServiceConnect() {
// Do something when service connects successfully
}
@Override
public void onServiceDisconnect() {
// Do something when service connects unsuccessfully
}
}; int result = VisionManager.init(context, connectionCallback); IBarcodeDetector barcodeDetector = VisionManager.getBarcodeDetector(context); final int SAMPLE_LENGTH = 152;
byte[] byteArray = new byte[SAMPLE_LENGTH * SAMPLE_LENGTH * 4]; int result = barcodeDetector.detect("This is a TestCase of IBarcodeDetector", byteArray, SAMPLE_LENGTH, SAMPLE_LENGTH);如果返回值为 0,表明调用成功。
result = barcodeDetector.release(); VisionManager.destroy();