Consider reading up on https://www.nayuki.io/page/creating-a-qr-code-step-by-step
And I highly recommend QRazyBox for manual painting with automatic decoding: https://merri.cx/qrazybox/ , https://github.com/Merricx/qrazybox
> that begins with collecting a bunch of broken and corrupted QR codes
Some ideas to consider: http://datagenetics.com/blog/november12013/index.html