Skip to content

Commit 83baf31

Browse files
committed
优化闪关灯的显示,删除一些无用的方法和文件
1 parent 16f8a15 commit 83baf31

7 files changed

Lines changed: 12 additions & 195 deletions

File tree

czxing/src/main/cpp/ImageUtil.cpp

Lines changed: 0 additions & 91 deletions
This file was deleted.

czxing/src/main/cpp/ImageUtil.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

czxing/src/main/cpp/JNIUtils.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <stdexcept>
2222
#include <vector>
2323
#include <opencv2/core/types.hpp>
24-
#include <locale.h>
2524

2625
namespace {
2726

@@ -110,23 +109,9 @@ BinaryBitmapFromBytesC1(void *pixels, int left, int top, int width, int height)
110109
return std::make_shared<HybridBinarizer>(luminance);
111110
}
112111

113-
bool AnalysisBrightness(JNIEnv *env, const jbyte *bytes, int width, int height) {
114-
115-
}
116-
117112
/**
118113
* string转wstring
119114
*/
120-
std::wstring StringToWString(const std::string &src) {
121-
unsigned long len = src.size() * 2; // 预留字节数
122-
setlocale(LC_CTYPE, ""); // 必须调用此函数,但是会造成污染
123-
auto *p = new wchar_t[len]; // 申请一段内存存放转换后的字符串
124-
mbstowcs(p, src.c_str(), len); // 转换
125-
std::wstring desc(p);
126-
delete[] p; // 释放申请的内存
127-
return desc;
128-
}
129-
130115
std::string UnicodeToANSI(const std::wstring &wstr) {
131116
std::string ret;
132117
std::mbstate_t state = {};
@@ -214,22 +199,4 @@ ToJavaArray(JNIEnv *env, const std::vector<ZXing::ResultPoint> &input) {
214199
}
215200

216201
return array;
217-
}
218-
219-
jintArray
220-
reactToJavaArray(JNIEnv *env, const cv::Rect &rect) {
221-
jintArray array = env->NewIntArray(6);
222-
223-
cv::Point pointLeftTop = rect.tl();
224-
cv::Point pointRightBottom = rect.br();
225-
env->SetIntArrayRegion(array, 0, 1, &pointLeftTop.x);
226-
env->SetIntArrayRegion(array, 1, 1, &pointLeftTop.y);
227-
228-
env->SetIntArrayRegion(array, 2, 1, &pointRightBottom.x);
229-
env->SetIntArrayRegion(array, 3, 1, &pointLeftTop.y);
230-
231-
env->SetIntArrayRegion(array, 4, 1, &pointLeftTop.x);
232-
env->SetIntArrayRegion(array, 5, 1, &pointRightBottom.y);
233-
234-
return array;
235-
}
202+
}

czxing/src/main/cpp/JNIUtils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@ class BinaryBitmap;
3939
std::shared_ptr<ZXing::BinaryBitmap> BinaryBitmapFromJavaBitmap(JNIEnv* env, jobject bitmap, int cropLeft, int cropTop, int cropWidth, int cropHeight);
4040
std::shared_ptr<ZXing::BinaryBitmap> BinaryBitmapFromBytesC4(JNIEnv* env, void *rgbScale, int cropLeft, int cropTop, int cropWidth, int cropHeight);
4141
std::shared_ptr<ZXing::BinaryBitmap> BinaryBitmapFromBytesC1(void *grayScale, int cropLeft, int cropTop, int cropWidth, int cropHeight);
42-
bool AnalysisBrightness(JNIEnv* env,const jbyte *bytes, int width, int height);
43-
std::wstring StringToWString(const std::string &src);
4442
std::string UnicodeToANSI(const std::wstring & wstr);
4543
std::wstring ANSIToUnicode(const std::string &src);
4644
void ThrowJavaException(JNIEnv* env, const char* message);
4745
jstring ToJavaString(JNIEnv* env, const std::wstring& str);
4846
jfloatArray ToJavaArray(JNIEnv* env, const std::vector<ZXing::ResultPoint>& vector);
49-
jintArray reactToJavaArray(JNIEnv *env, const cv::Rect &rect);

czxing/src/main/cpp/QRCodeRecognizer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <opencv2/imgproc/types_c.h>
66
#include "QRCodeRecognizer.h"
77
#include "opencv2/opencv.hpp"
8-
#include "JNIUtils.h"
98

109
using namespace cv;
1110
using namespace std;

czxing/src/main/cpp/native-lib.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "Result.h"
77
#include "QRCodeRecognizer.h"
88
#include "opencv2/opencv.hpp"
9-
#include "ImageUtil.h"
109
#include <vector>
1110
#include <opencv2/imgproc/types_c.h>
1211
#include "MultiFormatWriter.h"

czxing/src/main/java/me/devilsen/czxing/view/ScanView.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,17 @@ public void onAnalysisBrightness(boolean isDark) {
120120
}
121121
}
122122

123-
this.isDark = show >= DARK_LIST_SIZE;
124-
mScanBoxView.setDark(isDark);
123+
if (this.isDark) {
124+
if (show <= 2) {
125+
this.isDark = false;
126+
mScanBoxView.setDark(false);
127+
}
128+
} else {
129+
if (show >= DARK_LIST_SIZE) {
130+
this.isDark = true;
131+
mScanBoxView.setDark(true);
132+
}
133+
}
125134
}
126135

127136
public void resetZoom() {

0 commit comments

Comments
 (0)