TextureBitmapReader


@UnstableApi
public final class TextureBitmapReader implements VideoFrameProcessorTestRunner.BitmapReader


Reads from an OpenGL texture. Only for use on physical devices.

For images with alpha, this method incorrectly marks the output Bitmap as premultiplied, even though OpenGL typically outputs only non-premultiplied alpha.

Summary

Public constructors

Public methods

Bitmap

Returns the output Bitmap.

Bitmap
getBitmapAtPresentationTimeUs(long presentationTimeUs)
Set<Long>

Returns the timestamps in the order they were added.

@Nullable Surface
getSurface(
    int width,
    int height,
    boolean useHighPrecisionColorComponents
)

Returns the VideoFrameProcessor output Surface, if one is needed.

void
readBitmap(GlTextureInfo outputTexture, long presentationTimeUs)

Reads the given outputTexture.

void
readBitmapUnpremultipliedAlpha(
    GlTextureInfo outputTexture,
    long presentationTimeUs
)

Reads the given outputTexture as one with unpremultiplied alpha.

Public constructors

TextureBitmapReader

public TextureBitmapReader()

Public methods

getBitmap

public Bitmap getBitmap()

Returns the output Bitmap.

getBitmapAtPresentationTimeUs

public Bitmap getBitmapAtPresentationTimeUs(long presentationTimeUs)
Returns
Bitmap

The output Bitmap at a given presentationTimeUs.

Throws
java.lang.IllegalStateException

If no such bitmap is produced.

getOutputTimestamps

public Set<LonggetOutputTimestamps()

Returns the timestamps in the order they were added.

getSurface

public @Nullable Surface getSurface(
    int width,
    int height,
    boolean useHighPrecisionColorComponents
)

Returns the VideoFrameProcessor output Surface, if one is needed.

readBitmap

public void readBitmap(GlTextureInfo outputTexture, long presentationTimeUs)

Reads the given outputTexture.

The read result can be fetched by calling getBitmapAtPresentationTimeUs or getBitmap.

This implementation incorrectly marks the output Bitmap as premultiplied, even though OpenGL typically outputs only non-premultiplied alpha. Use readBitmapUnpremultipliedAlpha to properly handle alpha.

readBitmapUnpremultipliedAlpha

public void readBitmapUnpremultipliedAlpha(
    GlTextureInfo outputTexture,
    long presentationTimeUs
)

Reads the given outputTexture as one with unpremultiplied alpha.

The read result can be fetched by calling getBitmapAtPresentationTimeUs or getBitmap.