CodeUtils

object CodeUtils

二维码/条形码工具类:主要包括二维码/条形码的解析与生成

Author

Jenly

Follow me

Properties

Link copied to clipboard
const val DEFAULT_REQ_HEIGHT: Int = 640

默认解析图片目标高度。

Link copied to clipboard
const val DEFAULT_REQ_WIDTH: Int = 480

默认解析图片目标宽度。

Functions

Link copied to clipboard
fun createBarCode(content: String, desiredWidth: Int, desiredHeight: Int, hints: Map<EncodeHintType, *>? = null, isShowText: Boolean = false, textSize: Int = 40, @ColorInt codeColor: Int = Color.BLACK): Bitmap?

生成条形码(默认格式 BarcodeFormat.CODE_128)。

fun createBarCode(content: String, format: BarcodeFormat, desiredWidth: Int, desiredHeight: Int, hints: Map<EncodeHintType, *>? = null, isShowText: Boolean = false, textSize: Int = 40, @ColorInt codeColor: Int = Color.BLACK): Bitmap?

生成条形码。

Link copied to clipboard
fun createQRCode(content: String, size: Int, logo: Bitmap? = null, @FloatRange(from = 0.0, to = 1.0) ratio: Float = 0.2f, hints: Map<EncodeHintType, *>? = buildQRCodeHints(), @ColorInt codeColor: Int = Color.BLACK): Bitmap?

生成二维码。

Link copied to clipboard
fun parseCode(bitmap: Bitmap, hints: Map<DecodeHintType, Any>? = DecodeFormatManager.ALL_HINTS): String?

解析一维码/二维码位图,返回文本内容。

fun parseCode(bitmapPath: String, hints: Map<DecodeHintType, Any>? = DecodeFormatManager.ALL_HINTS): String?

解析一维码/二维码图片路径,返回文本内容。

Link copied to clipboard
fun parseCodeResult(bitmap: Bitmap, hints: Map<DecodeHintType, Any>? = DecodeFormatManager.ALL_HINTS): Result?

解析一维码/二维码位图,返回 Result

fun parseCodeResult(source: LuminanceSource?, hints: Map<DecodeHintType, Any>? = DecodeFormatManager.ALL_HINTS): Result?

解析一维码/二维码亮度源,返回 Result

fun parseCodeResult(bitmapPath: String, reqWidth: Int = DEFAULT_REQ_WIDTH, reqHeight: Int = DEFAULT_REQ_HEIGHT, hints: Map<DecodeHintType, Any>? = DecodeFormatManager.ALL_HINTS): Result?

解析一维码/二维码图片路径,返回 Result

Link copied to clipboard

解析二维码位图,返回文本内容。

fun parseQRCode(bitmapPath: String): String?

解析二维码图片路径,返回文本内容。

Link copied to clipboard
fun parseQRCodeResult(bitmapPath: String, reqWidth: Int = DEFAULT_REQ_WIDTH, reqHeight: Int = DEFAULT_REQ_HEIGHT): Result?

解析二维码图片路径,返回 Result