Printing bitmaps

Hi there,

I’m trying to print a bitmap on the receipt, using the iPoyntReceiptPrintingService. When I build the PrintedReceipt, I set the footer image as a QRCode. This QRCode comes as Base64 encoded PNG of 186x186px from our backend, then I build it as follows:

private static Bitmap decodeBase64(String input) {
    byte[] decodedBytes = Base64.decode(input, 0);
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inDither = false;
    options.inScaled = false;
    return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
}

Then I scale the bitmap up:

private static Bitmap generateQRCodeBitmap(SaleResponse sale) {
    Bitmap baseQrcode = decodeBase64(sale.getInvoice().getBase64Qrcode());

    float scale = 2;
    Matrix matrix = new Matrix();
    matrix.setScale(scale, scale);

    return Bitmap.createBitmap(baseQrcode, 0, 0, baseQrcode.getWidth(), baseQrcode.getHeight(), matrix, false);
}

When I try to print, I got this result:


I understand that this can be caused by thermal printing, it would be solved if I scale the bitmap up, probably (this was my initial intention on scaling it). But when I try to set scale variable to bigger values, it keeps the size in about 25x25mm.

Is there any limit to bitmaps?
Is there some “right” way to do this?

Thanks!

Figured that decreasing bitmap density makes it larger. Now having problems with the position on the paper:

Can someone help me with this, please?

Hi Gabriel,

I apologize for the delay responding to your question.
This may a bug in the code we use for re-scale images, but I would have to confirm that. Can you tell me what is the width and height of your QR code?

Also, if it’s easier you may try generating the bitmap of the whole receipt and using printBitmap method of IPoyntReceiptPrintingService.html: https://poynt.github.io/developer/javadoc/co/poynt/os/services/v1/IPoyntReceiptPrintingService.html#printBitmap-java.lang.String-android.graphics.Bitmap-co.poynt.os.services.v1.IPoyntReceiptPrintingServiceListener-

Hey @dennis,

The QRCode bitmap has 186x186px when we receive from the backend. Then we scale it 2x (see generateQRCodeBitmap) and set it’s density (not sure, but I think it’s 286) to half of the original.

I’ll try to use printBitmap method and then come with some feedback.

Thanks!