Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 1.84 KB

README.md

File metadata and controls

71 lines (50 loc) · 1.84 KB

StylizeQRCode

generate stylized QR code based on ZXing

Usage

Basic Dot Style QRCode

    val bitmap = StylizeQRGenerator.Builder()
      .dotStyle(true)
      .margin(2)
      .build()
      .generate(text)
   binding.qrNormal.setImageBitmap(bitmap)

image

Gradient Style

    val gradient = GradientDrawable(GradientDrawable.Orientation.BL_TR, arrayOf(Color.BLUE, Color.RED).toIntArray())
    val bitmapGradient = StylizeQRGenerator.Builder()
      .dotStyle(true)
      .margin(2)
      .gradient(gradient)
      .build()
      .generate(text)
    binding.qrGradient.setImageBitmap(bitmapGradient)

image

Background Style

    val bg = ContextCompat.getDrawable(this, R.drawable.bg)?.toBitmap(150, 150, Bitmap.Config.ARGB_8888)!!
    val bitmapBG = StylizeQRGenerator.Builder()
      .dotStyle(true)
      .background(bg)
      .margin(2)
      .build()
      .generate(longText)
    binding.qrBg.setImageBitmap(bitmapBG)

image

With Logo

    val logo = ContextCompat.getDrawable(this, R.drawable.logo)?.toBitmap(150, 150, Bitmap.Config.RGB_565)!!
    val bitmapLogo = StylizeQRGenerator.Builder()
      .dotStyle(true)
      .background(bg)
      .margin(2)
      .logo(logo)
      .build()
      .generate(text)
    binding.qrLogo.setImageBitmap(bitmapLogo)

image