Presentation
@UnstableApi
class Presentation : MatrixTransformation
Controls how a frame is presented with options to set the output resolution and choose how to map the input pixels onto the output frame geometry (for example, by stretching the input frame to match the specified output frame, or fitting the input frame using letterboxing).
The background color of the output frame will be black, with alpha = 0 if applicable.
Summary
Nested types |
|---|
@DocumentedStrategies controlling the layout of input pixels in the output frame. |
Constants |
|
|---|---|
const Int |
Empty pixels added above and below the input frame (for letterboxing), or to the left and right of the input frame (for pillarboxing), until the desired aspect ratio is achieved. |
const Int |
Pixels cropped from the input frame, until the desired aspect ratio is achieved. |
const Int |
Frame stretched larger on the x or y axes to fit the desired aspect ratio. |
Public functions |
|
|---|---|
Size! |
Configures the input and output dimensions. |
Presentation! |
copyWithTextureMinFilter(@C.TextureMinFilter textureMinFilter: Int)Returns a copy with the specified texture minification filter. |
Presentation! |
copyWithUnsetSideRoundedTo(divisor: Int)Returns a copy that will round the unset side length to the given |
java-static Presentation! |
createForAspectRatio(Creates a new |
java-static Presentation! |
createForHeight(height: Int)Creates a new |
java-static Presentation! |
createForShortSide(shortSide: Int)Creates a new |
java-static Presentation! |
createForWidthAndHeight(Creates a new |
Int |
Returns the |
Matrix! |
Returns the 3x3 transformation |
Boolean |
Returns whether a |
Inherited functions |
||
|---|---|---|
|
||
|
||
|
||
|
Constants
LAYOUT_SCALE_TO_FIT
const val LAYOUT_SCALE_TO_FIT = 0: Int
Empty pixels added above and below the input frame (for letterboxing), or to the left and right of the input frame (for pillarboxing), until the desired aspect ratio is achieved. All input frame pixels will be within the output frame.
When applying:
- letterboxing, the output width will default to the input width, and the output height will be scaled appropriately.
- pillarboxing, the output height will default to the input height, and the output width will be scaled appropriately.
LAYOUT_SCALE_TO_FIT_WITH_CROP
const val LAYOUT_SCALE_TO_FIT_WITH_CROP = 1: Int
Pixels cropped from the input frame, until the desired aspect ratio is achieved. Pixels may be cropped either from the bottom and top, or from the left and right sides, of the input frame.
When cropping from the:
- bottom and top, the output width will default to the input width, and the output height will be scaled appropriately.
- left and right, the output height will default to the input height, and the output width will be scaled appropriately.
LAYOUT_STRETCH_TO_FIT
const val LAYOUT_STRETCH_TO_FIT = 2: Int
Frame stretched larger on the x or y axes to fit the desired aspect ratio.
When stretching to a:
- taller aspect ratio, the output width will default to the input width, and the output height will be scaled appropriately.
- narrower aspect ratio, the output height will default to the input height, and the output width will be scaled appropriately.
Public functions
configure
fun configure(inputWidth: Int, inputHeight: Int): Size!
Configures the input and output dimensions.
Must be called before getGlMatrixArray.
| Parameters | |
|---|---|
inputWidth: Int |
The input frame width, in pixels. |
inputHeight: Int |
The input frame height, in pixels. |
| Returns | |
|---|---|
Size! |
The output frame width and height, in pixels. |
copyWithTextureMinFilter
fun copyWithTextureMinFilter(@C.TextureMinFilter textureMinFilter: Int): Presentation!
Returns a copy with the specified texture minification filter.
| Parameters | |
|---|---|
@C.TextureMinFilter textureMinFilter: Int |
The |
copyWithUnsetSideRoundedTo
fun copyWithUnsetSideRoundedTo(divisor: Int): Presentation!
Returns a copy that will round the unset side length to the given divisor.
| Parameters | |
|---|---|
divisor: Int |
The value to round the unset side length to. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
When the copied |
java.lang.IllegalArgumentException |
When the divisor is less than 1. |
createForAspectRatio
java-static fun createForAspectRatio(
aspectRatio: @FloatRange(from = 0, fromInclusive = false) Float,
@Presentation.Layout layout: Int
): Presentation!
Creates a new Presentation instance.
The output frame will have the given aspect ratio (width/height ratio). Width or height will be resized to conform to this aspectRatio, given a Layout.
| Parameters | |
|---|---|
aspectRatio: @FloatRange(from = 0, fromInclusive = false) Float |
The aspect ratio (width/height ratio) of the output frame. Must be positive. |
@Presentation.Layout layout: Int |
The layout of the output frame. |
createForHeight
java-static fun createForHeight(height: Int): Presentation!
Creates a new Presentation instance.
The output frame will have the given height. Width will scale to preserve the input aspect ratio. For example, a 1920x1440 video can be scaled to 640x480 by passing a height of 480.
| Parameters | |
|---|---|
height: Int |
The height of the output frame, in pixels. |
createForShortSide
java-static fun createForShortSide(shortSide: Int): Presentation!
Creates a new Presentation instance.
The output frame will have a short side matching the given value. The longest side will scale to preserve the input aspect * ratio. For example, passing a shortSide of 480 will scale a 1440x1920 video to 480x640 or a 1920x1440 video to 640x480.
| Parameters | |
|---|---|
shortSide: Int |
The length of the short side of the output frame, in pixels. |
createForWidthAndHeight
java-static fun createForWidthAndHeight(
width: Int,
height: Int,
@Presentation.Layout layout: Int
): Presentation!
Creates a new Presentation instance.
The output frame will have the given width and height, given a Layout.
Width and height must be positive integers representing the output frame's width and height.
| Parameters | |
|---|---|
width: Int |
The width of the output frame, in pixels. |
height: Int |
The height of the output frame, in pixels. |
@Presentation.Layout layout: Int |
The layout of the output frame. |
getGlTextureMinFilter
@C.TextureMinFilter
fun getGlTextureMinFilter(): Int
Returns the texture minification filter to use for sampling the input texture when applying this matrix transformation.