private CloseableReference<Bitmap> createBitmap(
      @Nullable DisplayMetrics display,
      int width,
      int height,
      Bitmap.Config config,
      boolean hasAlpha,
      @Nullable Object callerContext) {
    checkWidthHeight(width, height);
    CloseableReference<Bitmap> bitmapRef = createBitmapInternal(width, height, config);

    Bitmap bitmap = bitmapRef.get();
    if (display != null) {
      bitmap.setDensity(display.densityDpi);
    }

    if (Build.VERSION.SDK_INT >= 12) {
      bitmap.setHasAlpha(hasAlpha);
    }

    if (config == Bitmap.Config.ARGB_8888 && !hasAlpha) {
      bitmap.eraseColor(0xff000000);
    }

    return bitmapRef;
  }
Creates a bitmap with the specified width and height. Its initial density is determined from
the given DisplayMetrics.

@param display Display metrics for the display this bitmap will be drawn on
@param width The width of the bitmap
@param height The height of the bitmap
@param config The bitmap config to create
@param hasAlpha If the bitmap is ARGB_8888 this flag can be used to mark the bitmap as opaque
    Doing so will clear the bitmap in black instead of transparent
@param callerContext the Tag to track who create the Bitmap
@return a reference to the bitmap
@throws IllegalArgumentException if the width or height are <= 0
@throws TooManyBitmapsException if the pool is full
@throws java.lang.OutOfMemoryError if the Bitmap cannot be allocated
imagepipeline-base/src/main/java/com/facebook/imagepipeline/bitmaps/PlatformBitmapFactory.java