不需要的 textview 的位图轮廓

Unwanted textview's bitmap outline

我正在尝试从 TextView 中获取位图,如下所示:

private Bitmap getBitmapFromView(View view) {
        Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(returnedBitmap);
        view.draw(canvas);
        return returnedBitmap;
}

但是 returnedBitmap 包含带有不需要轮廓的 TextView 位图,请参阅 picture from Android Studio Debugger。我也尝试使用相同的功能,但在 ImageView 上应用了 returnedBitmap,但它没有这样的轮廓。我不明白如何解决这个问题。

UPD. 我的 TextView 布局:

<TextView
      android:id="@+id/bitmaptext"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="4dp"
      android:background="@android:color/transparent"
      android:textColor="@color/white"
      android:textSize="18sp"
      tools:text="test"
      tools:textColor="@color/white" />

UPD2. 这是示例项目:https://github.com/khoben/test-android,位图本身有轮廓,但在 ImageView 中没有。我需要一张没有这个轮廓的图片。

UPD3。我想在视频上从 texview 绘制位图,但是 outlining ruins all plans (pic).

UPD4。我应该说当来自 getBitmapFromView() 的图像通过 OpenGL 在视频上绘制时出现问题,原因是不正确的混合模式。 .

在“getBitmapFromView”中传递您的 TextView

  public static Bitmap getBitmapFromView(View view) {
        view.setDrawingCacheEnabled(true);
        Bitmap returnedBitmap = Bitmap.createBitmap(view.getDrawingCache());
        view.setDrawingCacheEnabled(false);
        return returnedBitmap;
    }

实际上,Android 调试器中图像的黑色边框是由于字母周围的半透明像素和默认混合选项给出的结果为黑色(glClearColor 设置为黑色)。 OpenGL 也做同样的事情。

以下是 OpenGL 的一些技巧:

  1. 调整混合参数(在我的例子中有效):

    GLES20.glEnable(GL_BLEND);
    GLES20.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    
  2. 确保叠加层绘制在您的背景上,例如没有清除 FBO 的背景。