title: How to generate a custom QR code in Android programmatically using ZXing Library?
body: <p>I'm using <a href="https://github.com/journeyapps/zxing-android-embedded/tree/master/zxing-android-embedded/src/com/journeyapps/barcodescanner" rel="nofollow noreferrer">Journeyapp's ZXing Android Embedded library</a> for my android app and I can generate a simple QR code using the following piece of code </p>
  
  <pre><code> private void init() {
  
          ImageView qrImageView = (ImageView) findViewById(R.id.qr_image_view);
  
          qrImageView.setImageBitmap(generateQRBitMap("a"));
  
      }
  
      private Bitmap generateQRBitMap(final String content) {
  
          Map&lt;EncodeHintType, ErrorCorrectionLevel&gt; hints = new HashMap&lt;&gt;();
  
          hints.put(EncodeHintType.ERROR_CORRECTION,ErrorCorrectionLevel.H);
  
          QRCodeWriter qrCodeWriter = new QRCodeWriter();
  
          try {
              BitMatrix bitMatrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, 512, 512, hints);
  
              int width = bitMatrix.getWidth();
              int height = bitMatrix.getHeight();
  
              Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
  
              for (int x = 0; x &lt; width; x++) {
                  for (int y = 0; y &lt; height; y++) {
  
                      bmp.setPixel(x , y, bitMatrix.get(x,y) ? Color.BLACK : Color.WHITE);
                  }
              }
  
              return bmp;
          } catch (WriterException e) {
              e.printStackTrace();
          }
  
          return null;
      }
  </code></pre>
  
  <p>However, I want to be able to generate something as cool as the one given below<a href="https://i.stack.imgur.com/496ZW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/496ZW.jpg" alt="enter image description here"></a></p>
  
  <p>Now I know that I may have to write a custom encoder for that, but I really don't know where to begin. The <code>BitMatrix</code> class always creates a square QR code, but is there anything that I can use to create the odd shapes? </p>