我正在尝试使用GLUtils.texImage2D功能在视频上绘制某种水印,但它不会出现在预览和录制的视频中。我做错了什么?
private void drawFrame() {
mDisplaySurface.makeCurrent();
mCameraTexture.updateTexImage();
mCameraTexture.getTransformMatrix(mTmpMatrix);
AutoFitTextureView sv = (AutoFitTextureView) findViewById(R.id.texture);
int viewWidth = sv.getWidth();
int viewHeight = sv.getHeight();
GLES20.glViewport(0, 0, viewWidth, viewHeight);
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
drawExtra(mFrameNum, viewWidth, viewHeight);
loadWatermark(BitmapFactory.decodeResource(getResources(), R.drawable.ic_settings_white_24dp));
mDisplaySurface.swapBuffers();
if (!mFileSaveInProgress) {
mEncoderSurface.makeCurrent();
GLES20.glViewport(0, 0, videoHeightSetting,
videoWidthSetting);
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
drawExtra(mFrameNum,
videoWidthSetting,
videoHeightSetting);
loadWatermark(BitmapFactory.decodeResource(getResources(), R.drawable.ic_settings_white_24dp));
mCircEncoder.frameAvailableSoon();
mEncoderSurface.setPresentationTime(mCameraTexture.getTimestamp());
mEncoderSurface.swapBuffers();
}
mFrameNum++;
}
private void loadWatermark(Bitmap bitmap) {
final int[] textureHandle = new int[1];
GLES20.glGenTextures(1, textureHandle, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();
}