fix: 二维码静默区2格+圆角8%,防止裁切定位角
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -73,7 +73,7 @@ class BindFragment : BaseFragment<FragmentBindBinding>() {
|
||||
// ZXing 生成二维码 Bitmap(缩小静默区,让二维码更大)
|
||||
val size = 500
|
||||
val hints = hashMapOf<com.google.zxing.EncodeHintType, Any>(
|
||||
com.google.zxing.EncodeHintType.MARGIN to 0 // 去掉静默区,圆角裁剪才对称
|
||||
com.google.zxing.EncodeHintType.MARGIN to 2 // 保留 2 格静默区,防止圆角裁掉定位角
|
||||
)
|
||||
val bitMatrix: BitMatrix = MultiFormatWriter().encode(
|
||||
qrData, BarcodeFormat.QR_CODE, size, size, hints
|
||||
@@ -108,7 +108,7 @@ class BindFragment : BaseFragment<FragmentBindBinding>() {
|
||||
val canvas = android.graphics.Canvas(output)
|
||||
val paint = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG)
|
||||
val rect = android.graphics.RectF(0f, 0f, width.toFloat(), height.toFloat())
|
||||
val radius = width * 0.12f
|
||||
val radius = width * 0.08f // 8% 圆角,避免裁到二维码定位角
|
||||
canvas.drawRoundRect(rect, radius, radius, paint)
|
||||
paint.xfermode = android.graphics.PorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_IN)
|
||||
canvas.drawBitmap(squareBitmap, 0f, 0f, paint)
|
||||
|
||||
Reference in New Issue
Block a user