code: public Bitmap getBitmap(int backgroundColor) {
          // create new bitmap
          Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
          Canvas bitmapCanvas = new Canvas(bitmap);
  
          // draw background if not transparent
          if (backgroundColor != 0) {
              bitmapCanvas.drawColor(backgroundColor);
          }
  
          // draw bitmap
          bitmapCanvas.drawBitmap(this.bitmap, 0, 0, null);
  
          return bitmap;
      }
docs: Returns the bitmap of the drawing with the specified background color
  
  @param backgroundColor The background color for the bitmap
  @return The bitmap