Skip to content

Commit

Permalink
release 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hupei committed Jan 22, 2021
1 parent ffe026d commit e5dd957
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- 依赖使用 Gradle 构建时添加一下即可

```javascript
compile 'com.mylhyl:zxingscanner:2.1.9'
compile 'com.mylhyl:zxingscanner:2.2.0'
```

## 2、离线jar,需要手动添加 Zxing 核心库
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ protected void onCreate(Bundle savedInstanceState) {
Drawable tintDrawable = DrawableCompat.wrap(originalDrawable).mutate();
DrawableCompat.setTint(tintDrawable, Color.RED);

Bitmap bitmap = Scanner.drawableToBitmap(tintDrawable);

ImageView imageView = findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);

ScannerOptions.Builder builder = new ScannerOptions.Builder();
builder
// .setFrameStrokeColor(Color.RED)
Expand All @@ -74,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) {
// .setLaserLine(ScannerOptions.LaserStyle.RES_GRID, R.mipmap.zfb_grid_scan_line)//网格图
// .setFrameCornerColor(0xFF26CEFF)//支付宝颜色

// .setScanFullScreen(true)
.setScanFullScreen(true)

// .setFrameHide(false)
// .setFrameCornerHide(true)
Expand Down
4 changes: 0 additions & 4 deletions sample/src/main/res/layout/activity_scanner_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />

<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp" />
</RelativeLayout>
2 changes: 1 addition & 1 deletion zxingscanner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 15
targetSdkVersion 28
versionCode 20210122
versionName '2.1.9'
versionName '2.2.0'
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,34 +316,41 @@ private void drawLaserLine(Canvas canvas, Rect frame) {
* @param point
*/
private void drawLaserLineFullScreen(Canvas canvas, Point point) {
if (scannerOptions.getLaserStyle() == ScannerOptions.LaserStyle.COLOR_LINE) {
ScannerOptions.LaserStyle laserLineStyle = scannerOptions.getLaserStyle();
if (laserLineStyle == ScannerOptions.LaserStyle.COLOR_LINE) {
paint.setStyle(Paint.Style.FILL);
paint.setColor(scannerOptions.getLaserLineColor());// 设置扫描线颜色
canvas.drawRect(0, laserLineTop, point.x, laserLineTop + laserLineHeight, paint);
} else {
if (laserLineBitmap == null)//图片资源文件转为 Bitmap
return;
}
// 图片资源文件转为 Bitmap
if (laserLineBitmap == null) {
if (laserLineStyle == ScannerOptions.LaserStyle.DRAWABLE_LINE ||
laserLineStyle == ScannerOptions.LaserStyle.DRAWABLE_GRID) {
laserLineBitmap = Scanner.drawableToBitmap(scannerOptions.getLaserLineDrawable());
} else {
laserLineBitmap = BitmapFactory.decodeResource(getResources(), scannerOptions.getLaserLineResId());
int height = laserLineBitmap.getHeight();//取原图高
//网格图片
if (scannerOptions.getLaserStyle() == ScannerOptions.LaserStyle.RES_GRID) {
int dstRectFTop = 0;
if (laserLineTop >= height) {
dstRectFTop = laserLineTop - height;
}
RectF dstRectF = new RectF(0, dstRectFTop, point.x, laserLineTop);
Rect srcRect = new Rect(0, (int) (height - dstRectF.height()), laserLineBitmap.getWidth(), height);
canvas.drawBitmap(laserLineBitmap, srcRect, dstRectF, paint);
}
//线条图片
else {
//如果没有设置线条高度,则用图片原始高度
if (laserLineHeight == dp2px(ScannerOptions.DEFAULT_LASER_LINE_HEIGHT)) {
laserLineHeight = laserLineBitmap.getHeight() / 2;
}
Rect laserRect = new Rect(0, laserLineTop, point.x, laserLineTop + laserLineHeight);
canvas.drawBitmap(laserLineBitmap, null, laserRect, paint);
}
int height = laserLineBitmap.getHeight();//取原图高
// 网格图片
if (laserLineStyle == ScannerOptions.LaserStyle.RES_GRID ||
laserLineStyle == ScannerOptions.LaserStyle.DRAWABLE_GRID) {
int dstRectFTop = 0;
if (laserLineTop >= height) {
dstRectFTop = laserLineTop - height;
}
RectF dstRectF = new RectF(0, dstRectFTop, point.x, laserLineTop);
Rect srcRect = new Rect(0, (int) (height - dstRectF.height()), laserLineBitmap.getWidth(), height);
canvas.drawBitmap(laserLineBitmap, srcRect, dstRectF, paint);
return;
}
// 线条图片, 如果没有设置线条高度,则用图片原始高度
if (laserLineHeight == dp2px(ScannerOptions.DEFAULT_LASER_LINE_HEIGHT)) {
laserLineHeight = laserLineBitmap.getHeight() / 2;
}
Rect laserRect = new Rect(0, laserLineTop, point.x, laserLineTop + laserLineHeight);
canvas.drawBitmap(laserLineBitmap, null, laserRect, paint);
}

void drawViewfinder() {
Expand Down

0 comments on commit e5dd957

Please sign in to comment.