1 year ago

#166005

test-img

Mike Weiss

Display android.graphics.Bitmap constantly in TextureView

I have written a Fragment class, which is dedicated to display a constant stream of android.graphics.Bitmap. The stream of Bitmap objects is delivered by JavaCV.

Do I have to use the Canvas.drawBitmap method to display the Bitmaps in order to get a video?

The class looks like this

/**
 * A simple {@link Fragment} subclass for showing th Video stream.
 */
@EFragment(R.layout.fragment_video)
public class VideoFragment extends Fragment implements TextureView.SurfaceTextureListener, VideoListener {
    public static final String TAG = "de.mw.talk2drone.ui.video.VideoFragment";
    @ViewById
    TextureView textureView;

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onSurfaceTextureAvailable(@NonNull final SurfaceTexture surface, final int width, final int height) {

    }

    @Override
    public void onSurfaceTextureSizeChanged(@NonNull final SurfaceTexture surface, final int width, final int height) {

    }

    @Override
    public boolean onSurfaceTextureDestroyed(@NonNull final SurfaceTexture surface) {
        return false;
    }

    @Override
    public void onSurfaceTextureUpdated(@NonNull final SurfaceTexture surface) {

    }

    @Override
    public void onFrameReceived(TelloVideoFrame frame) {
        Log.d(TAG, "received a frame in Fragment: " +frame);
    }
}

Do you have some samples or links of how to smoothly display a Bitmap stream in a TextureView? I have seen multiple references to Grafika, which may give a clue of what has to been done.

android

video

bitmap

textureview

grafika

0 Answers

Your Answer

Accepted video resources