alexzhirkevich / custom-qr-generator

Android library for creating QR codes with logo, custom shapes, colors, background image. Powered by ZXing
MIT License
173 stars 18 forks source link

Use custom logo from gallery #12

Closed neelniloy closed 1 year ago

neelniloy commented 1 year ago

is there any way to use URI or Bitmap for the logo image?

alexzhirkevich commented 1 year ago

If URI is from android file system, you can use DrawableSource.File. Otherwise you should pre-download it

You can use BitmapDrawable and create custom DrawableSource:

val bitmapDrawableSource = DrawableSource { 
    BitmapDrawable(resources, yourBitmap) 
    // or yourBitmap.toDrawable(resources)
}

But make sure that your bitmap is immutable. You can check it with Bitmap.isMutable and make bitmap immutable with


val immutableBitmap = yourBitmap.copy(Bitmap.Config.ARGB_8888, /* isMutable= */false)
neelniloy commented 1 year ago

Thanks. Issue Solved