1

I'm trying to draw some kind of watermark on the video with GLUtils.texImage2D function, but it does not appear on preview and recorded video. What I'm doing wrong?

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();
}
dr1v3
  • 151
  • 1
  • 1
  • 9
  • @Rabbid76, in original https://github.com/google/grafika/blob/master/src/com/android/grafika/ContinuousCaptureActivity.java 449 line `mDisplaySurface.swapBuffers();` is the last. Anyway, it doesn't help. – dr1v3 Oct 18 '17 at 08:40
  • did you find a solution? – user924 Jul 19 '18 at 06:26
  • @user924, yes, afair its about blending two textures in the shader code – dr1v3 Jul 19 '18 at 08:35
  • can you please show an example (what I have to edit in ContinuousCaptureActivity?) – user924 Jul 19 '18 at 09:32

0 Answers0