title: Zxing: generated barcode does not use full width available
body: <p>I am trying to generate a Code128 barcode using Zxing:</p>
  
  <pre><code>try {
      int width = (int) (barcode.getWidth() * 0.95f);
      int height = (int) (width * 0.2f);
      BitMatrix bitMatrix = writer.encode(code.number, BarcodeFormat.CODE_128, width, height);
      Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      for (int i = 0; i &lt; width; i++) {
          for (int j = 0; j &lt; height; j++) {
              bitmap.setPixel(i, j, bitMatrix.get(i, j) ? Color.BLACK : Color.WHITE);
          }
      }
      barcode.setImageBitmap(bitmap);
  } catch (WriterException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Where <code>barcode</code> is an <code>ImageView</code>, whose width is set to <code>match_parent</code> (with 5dp margin) and height is <code>wrap_content</code>. The image I am generating has an aspect ratio of 5:1, and I expected the black stripes to appear in the very beginning of the image, and finish at the very end.</p>
  
  <p>This is what happens, though:</p>
  
  <p><img src="https://i.stack.imgur.com/C1yMC.png" alt="barcode"></p>
  
  <p>The <code>ImageView</code> has the green background (note that the image width is 95% of the <code>ImageView</code> width), and the white part belongs to the image. As you can see, there's a huge white area, maybe 40% of the image.</p>
  
  <p>The question is why does the stripes not fill the full (or most of the) width I specified on the <code>writer.encode()</code> method? How can I force this to happen?</p>
  
  <p>Update:</p>
  
  <p>Using different values for the scale type, I noticed that the white margin is present only on the sides of the barcode, and never above or below it.</p>