From edbb11533c1fbd039c56dd625f3ea5eee05cc457 Mon Sep 17 00:00:00 2001 From: zhenxiong han Date: Fri, 9 Jul 2021 10:48:31 +0800 Subject: [PATCH] update --- .../zbar/camera/BitmapLuminanceSource.java | 53 ------------------- .../zbar/decoding/DecodeFormatManager.java | 42 +-------------- .../java/cn/bertsir/zbar/utils/QRUtils.java | 1 - 3 files changed, 2 insertions(+), 94 deletions(-) delete mode 100644 zbarlibary/src/main/java/cn/bertsir/zbar/camera/BitmapLuminanceSource.java diff --git a/zbarlibary/src/main/java/cn/bertsir/zbar/camera/BitmapLuminanceSource.java b/zbarlibary/src/main/java/cn/bertsir/zbar/camera/BitmapLuminanceSource.java deleted file mode 100644 index deb1d57..0000000 --- a/zbarlibary/src/main/java/cn/bertsir/zbar/camera/BitmapLuminanceSource.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package cn.bertsir.zbar.camera; - -import com.google.zxing.LuminanceSource; -import ohos.media.image.PixelMap; -import ohos.media.image.common.Rect; - -/** - * Created by aaron on 16/7/27. - * 自定义解析Bitmap LuminanceSource - */ -public class BitmapLuminanceSource extends LuminanceSource { - private byte[] bitmapPixels; - - public BitmapLuminanceSource(PixelMap pixelMap) { - super(pixelMap.getImageInfo().size.width, pixelMap.getImageInfo().size.height); - - // 首先,要取得该图片的像素数组内容 - int[] data = new int[getWidth() * getHeight()]; - this.bitmapPixels = new byte[getWidth() * getHeight()]; - pixelMap.readPixels(data, 0, getWidth(), new Rect(0, 0, getWidth(), getHeight())); - // 将int数组转换为byte数组,也就是取像素值中蓝色值部分作为辨析内容 - for (int i = 0; i < data.length; i++) { - this.bitmapPixels[i] = (byte) data[i]; - } - } - - @Override - public byte[] getMatrix() { - // 返回我们生成好的像素数据 - return bitmapPixels; - } - - @Override - public byte[] getRow(int y, byte[] row) { - // 这里要得到指定行的像素数据 - System.arraycopy(bitmapPixels, y * getWidth(), row, 0, getWidth()); - return row; - } -} diff --git a/zbarlibary/src/main/java/cn/bertsir/zbar/decoding/DecodeFormatManager.java b/zbarlibary/src/main/java/cn/bertsir/zbar/decoding/DecodeFormatManager.java index 8997941..20821e2 100644 --- a/zbarlibary/src/main/java/cn/bertsir/zbar/decoding/DecodeFormatManager.java +++ b/zbarlibary/src/main/java/cn/bertsir/zbar/decoding/DecodeFormatManager.java @@ -1,11 +1,10 @@ /* - * Copyright (C) 2010 ZXing authors - * + * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -28,44 +27,7 @@ import static java.util.Collections.singletonList; * 解码类型格式 */ public class DecodeFormatManager { - private static final Pattern COMMA_PATTERN = Pattern.compile(","); - -// private static final Vector PRODUCT_FORMATS; -// -// /** -// * one 格式 -// */ -// public static final Vector ONE_D_FORMATS; -// -// /** -// * qr 格式 -// */ -// public static final Vector QR_CODE_FORMATS; -// -// /** -// * data 格式 -// */ -// public static final Vector DATA_MATRIX_FORMATS; -// static { -// PRODUCT_FORMATS = new Vector(5); -// PRODUCT_FORMATS.add(BarcodeFormat.UPC_A); -// PRODUCT_FORMATS.add(BarcodeFormat.UPC_E); -// PRODUCT_FORMATS.add(BarcodeFormat.EAN_13); -// PRODUCT_FORMATS.add(BarcodeFormat.EAN_8); -// PRODUCT_FORMATS.add(BarcodeFormat.RSS_14); -// ONE_D_FORMATS = new Vector(PRODUCT_FORMATS.size() + 5); -// ONE_D_FORMATS.addAll(PRODUCT_FORMATS); -// ONE_D_FORMATS.add(BarcodeFormat.CODE_39); -// ONE_D_FORMATS.add(BarcodeFormat.CODE_93); -// ONE_D_FORMATS.add(BarcodeFormat.CODE_128); -// ONE_D_FORMATS.add(BarcodeFormat.ITF); -// ONE_D_FORMATS.add(BarcodeFormat.CODABAR); -// QR_CODE_FORMATS = new Vector(1); -// QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE); -// DATA_MATRIX_FORMATS = new Vector(1); -// DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX); -// } private DecodeFormatManager() {} diff --git a/zbarlibary/src/main/java/cn/bertsir/zbar/utils/QRUtils.java b/zbarlibary/src/main/java/cn/bertsir/zbar/utils/QRUtils.java index 39af93e..9ac94a7 100644 --- a/zbarlibary/src/main/java/cn/bertsir/zbar/utils/QRUtils.java +++ b/zbarlibary/src/main/java/cn/bertsir/zbar/utils/QRUtils.java @@ -2,7 +2,6 @@ package cn.bertsir.zbar.utils; import cn.bertsir.zbar.Qr.*; -import cn.bertsir.zbar.camera.BitmapLuminanceSource; import cn.bertsir.zbar.decoding.DecodeFormatManager; import com.google.zxing.*; import com.google.zxing.common.BitMatrix; -- Gitee