title: Android creating bitmap from two bitmaps bottom bitmap not visible
body: <p>I have a list of items where I am displaying a bitmap next to the item's name. This bitmap is to be created from 2 images, I have a background image with a smaller foreground image to add on top of the background.</p>
  
  <p>I am seeing that the background image appears to not be present on some of my rows in my list. It is not consistent when and which row has the combined bitmap without the background. It is not always the same row where the combined bitmap does not have the background and it is not always the first or not always the last row where the bitmap does not have the background. And sometimes the whole list has every row with the correct image.</p>
  
  <p>The image below is a mockup showing my issue.</p>
  
  <p><img src="https://i.stack.imgur.com/sXbnU.png" alt="Issue mockup image"></p>
  
  <p>My code for creating the combined bitmap is as follows.</p>
  
  <pre><code>Bitmap combinedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  Canvas combinedCanvas = new Canvas(combinedBitmap);
  
  // Add the first bitmap to the canvas (this is my background and this is what appears to be 
  // missing on some rows in my list on some occasions)
  combinedCanvas.drawBitmap(backgroundBitmap, 0, 0, null); 
  
  // my second smaller image, on top of the first image but 1 pixel in 
  // from the left and 20 pixels down from the top
  combinedCanvas.drawBitmap(foregroundBitmap, 1, 20, null);
  
  return combinedBitmap;
  </code></pre>
  
  <p>Note: My backgroundBitmap is generated from a Drawable using the following code</p>
  
  <pre><code>Bitmap backgroundBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), 
                                                drawable.getMinimumHeight(),
                                                Bitmap.Config.ARGB_8888);
  backgroundBitmap.setDensity(resources.getDisplayMetrics().densityDpi);
  Canvas canvas = new Canvas(backgroundBitmap);
  drawable.draw(canvas);
  </code></pre>
  
  <p>Any suggestions of what I have wrong or even where to look to try and resolve this would be greatly appreciated.</p>
  
  <p>EDIT: I have tested adding a colour to the background of my combinedCanvas to try and see where the image generation is going wrong by adding the following code</p>
  
  <pre><code>// TEMP: fill the canvas in red for now so I can see which combinedBitmaps are missing
  // the background image
  combinedCanvas.drawColor(Color.RED); 
  </code></pre>
  
  <p>Now the rows which do not have the background are coloured in red. This indicates that the code above to create the combined canvas is somehow not adding the backgroundBitmap.  I have checked and my background image is not null for every row in my list.</p>