Search code examples
javaandroidbarcodezxingqr-code

How to convert bitmatrix into bitmap?


The ZXing library's Writer.encode() function returns a BitMatrix object. How does one convert that to a standard java Bitmap object so it can be used as the source of an ImageView in Android?


Solution

  • writeToFile(BitMatrix matrix, String format, File file)
    

    thsi method will write the BitMatrix into a file, now you can decode this file using

    BitmapFactory.decodeFile(newly created file name with path)
    

    This will return a Bitmap

    For more detail see this link