Fun with QR library

My QR code generation library works well, but one of the features was generating a "colour" QR code. No, QR codes are not normally coloured, the idea is to just show the anatomy of a QR code, which parts are which. Wikipedia does a good job too.

As part of generating the code I have to create the data part, and padding, and then generate the error correction code (ECC) part, and apply various format control bits and fixed black/white units to make the image.

I have updated the library so it will make a QR code which shows what is what. It was a tad complicated by the fact that the error correction code is interleaved. This means that blocks of data and ECC are scrambled so that each block is actually spread out over the QR code. This means you can remove a chunk of the code - e.g. tear off a corner, and that is a small part of several separate blocks. You will notice the padding (green) below is spread out because of this interleaving.

Each block of data and ECC allows recreating of the data from a relatively small part of the overall block, so the distinction between data and ECC is not that relevant. But the colour coding shows how much is used for what quite nicely even so.

This has colour coding for :-

  • Blue: the actual data for the content
  • Green: padding bytes and bits
  • Red: the ECC code
  • Grey: formatting/control
  • Black/White: the fixed pixels in this size QR code

So that is it, just in case you wondered...

(That one above is an NHS COVID-19 QR code).

P.S. I have been having more fun with custom padding bytes. This is not just changing units within the tolerance of the ECC (which can be done, if careful), it is changing padding so that the ECC is still valid.

Of course, if you want to get a bit meta, you can put one type of barcode in the padding of another type. This is a Datamatrix barcode in a QR barcode. A real Frankenstein barcode!

Technically the padding is meant to be a repeating pattern EC/11, and surprisingly this is not just a recommendation in the spec. But obviously nothing checks the padding on read, so allowing pretty padding and hidden data in the padding to work.


  1. RevK will we be able to order our own Venue Check-in Cards with our home address in QR code for Track and Trace App from cards.aa?

    1. LOL, I have a template for that - but you'd need to get the QR from gov site and then put the code in the card template. I don't mind doing the odd one manually.

    2. I just wish there was a check-out card. It's ludicrous that I spend fifteen minutes at a venue and then am considered potentially infected if a covid case goes there three hours later, just because you can't check out, you can only check in somewhere else. A check-in card for your own home would actually be useful in this context :)

    3. Ok I have added to the card ordering. You can use the default if you like, e.g. click "set default" for the barcode and put "Check out" as the label or something. That default is, I think, for 10 Downing Street, so should be fine.

  2. Is it illegal to make a spoof QR? and is there a way of making one without going through the government?

    1. What law would make it illegal? And at present it would need to be signed, so using gov website, but they will sign and issue a code for anywhere you like.

    2. I see thanks for the insight, you seem to be the only person whose broken down the QR code system they've created. Very interesting

    3. Others have, not hard, I was just in there with a blog post nice and early so it is the main one people reference.


Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.

NOTSCO (Not TOTSCO) One Touch Switching test platform (now launched)

I posted about how inept TOTSCO seem to be, and the call today with them was no improvement. It seems they have test stages... A "simul...