Search code examples
blackberryqr-codezxing

How to set error correction level for QR code when using the new createbitmap method


This question is in reference to the API documentation link, http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/barcodelib/BarcodeBitmap.html

They specify that the old method

public static Bitmap createBitmap(ByteMatrix byteMatrix,
                                  int maxBitmapSizeInPixels) 

is deprecated.

But by using the new method,

public static Bitmap createBitmap(ByteMatrix byteMatrix)

they haven't specified a way to specify the error correction level for the QR code in Multiformatwriter. I haven't been able to find a way either, looking through various member functions. Has anyone tried this?

Thanks for your help.


Solution

  • Just looked to the documentation.

    It says to use createBitmap(ByteMatrix byteMatrix) in conjunction with MultiFormatWriter. That has method encode(String contents, BarcodeFormat format, int width, int height, Hashtable hints) where you could specify width, height and error level.

    To specify error level put to hints hashtable key EncodeHintType.ERROR_CORRECTION with value new Integer(level).

    Unfortunately I didn't find any constants for these values as described here. but probably you could find it in axing sources.