Skip to content

Commit

Permalink
加入arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
devilsen committed Jul 23, 2019
1 parent 36ab665 commit d2bd792
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 21 deletions.
2 changes: 1 addition & 1 deletion czxing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {

externalNativeBuild {
cmake {
abiFilters "armeabi-v7a"
abiFilters "armeabi-v7a","arm64-v8a"
}
}
}
Expand Down
Binary file added czxing/libs/arm64-v8a/libopencv_java4.so
Binary file not shown.
Binary file added czxing/libs/x86/libopencv_java4.so
Binary file not shown.
8 changes: 4 additions & 4 deletions czxing/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ Java_me_devilsen_czxing_BarcodeReader_analysisBrightnessNative(JNIEnv *env, jcla

extern "C"
JNIEXPORT jint JNICALL
Java_me_devilsen_czxing_BarcodeReader_writeBarcode(JNIEnv *env, jclass type, jstring content_,
jint width, jint height, jobjectArray result) {
Java_me_devilsen_czxing_BarcodeWriter_writeBarcode(JNIEnv *env, jclass type, jstring content_,
jint width, jint height, jint color,
jobjectArray result) {
const char *content = env->GetStringUTFChars(content_, 0);

try {
std::wstring wContent;
wContent = StringToWString(content);
Expand All @@ -171,7 +171,7 @@ Java_me_devilsen_czxing_BarcodeReader_writeBarcode(JNIEnv *env, jclass type, jst

int size = width * height;
jintArray pixels = env->NewIntArray(size);
int black = 0xff000000;
int black = color;
int white = 0xffffffff;
int index = 0;
for (int i = 0; i < height; ++i) {
Expand Down
11 changes: 0 additions & 11 deletions czxing/src/main/java/me/devilsen/czxing/BarcodeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ public Result read(byte[] data, int cropLeft, int cropTop, int cropWidth, int cr
return null;
}

public Bitmap write(String text, int width, int height) {
Object[] result = new Object[1];
int resultCode = writeBarcode(text, width, height, result);
if (resultCode > -1) {
int[] pixels = (int[]) result[0];
return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
}
return null;
}

public boolean analysisBrightness(byte[] data, int imageWidth, int imageHeight) {
return analysisBrightnessNative(data, imageWidth, imageHeight);
Expand Down Expand Up @@ -140,8 +131,6 @@ protected void finalize() throws Throwable {

public static native boolean analysisBrightnessNative(byte[] bytes, int width, int height);

public static native int writeBarcode(String content, int width, int height, Object[] result);

static {
System.loadLibrary("zxing-lib");
}
Expand Down
38 changes: 38 additions & 0 deletions czxing/src/main/java/me/devilsen/czxing/BarcodeWriter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package me.devilsen.czxing;

import android.graphics.Bitmap;
import android.graphics.Color;

/**
* desc : 生成二维码处理
* date : 2019-07-22 15:35
Expand All @@ -8,6 +11,41 @@
*/
public class BarcodeWriter {

/**
* 生成二维码
*
* @param text 要生成的文本
* @param width bitmap 宽
* @param height bitmap 高
* @return bitmap二维码
*/
public Bitmap write(String text, int width, int height) {
return write(text, width, height, Color.BLACK);
}

/**
* 生成二维码
*
* @param text 要生成的文本
* @param width bitmap 宽
* @param height bitmap 高
* @param color 要生成的二维码颜色
* @return bitmap二维码
*/
public Bitmap write(String text, int width, int height, int color) {
Object[] result = new Object[1];
int resultCode = writeBarcode(text, width, height, color, result);
if (resultCode > -1) {
int[] pixels = (int[]) result[0];
return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
}
return null;
}

public static native int writeBarcode(String content, int width, int height, int color, Object[] result);

static {
System.loadLibrary("zxing-lib");
}

}
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ android {

externalNativeBuild {
cmake {
abiFilters "armeabi-v7a"
abiFilters "armeabi-v7a","arm64-v8a"
}
}

ndk {
// 设置支持的SO库架构
abiFilters "armeabi-v7a"
abiFilters "armeabi-v7a","arm64-v8a"
}
}

Expand All @@ -41,8 +41,8 @@ android {

dependencies {

implementation project(':czxing')
// implementation 'me.devilsen:CZXing:0.1'
// implementation project(':czxing')
implementation 'me.devilsen:CZXing:0.3'

implementation rootProject.ext.appcompat
testImplementation rootProject.ext.junit
Expand Down
3 changes: 2 additions & 1 deletion sample/src/main/java/me/sam/czxing/WriteCodeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import me.devilsen.czxing.BarcodeFormat;
import me.devilsen.czxing.BarcodeReader;
import me.devilsen.czxing.BarcodeWriter;
import me.devilsen.czxing.util.BarCodeUtil;

/**
Expand All @@ -26,7 +27,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

ImageView imageView = findViewById(R.id.image_view_qr_code);

BarcodeReader reader = new BarcodeReader(BarcodeFormat.QR_CODE);
BarcodeWriter reader = new BarcodeWriter();
Bitmap bitmap = reader.write("Hello World", BarCodeUtil.dp2px(this, 200), BarCodeUtil.dp2px(this, 200));

if (bitmap != null) {
Expand Down

0 comments on commit d2bd792

Please sign in to comment.