Take a look at the "texture from camera" activity. Note it allows you to manipulate the image in various ways, notably "zoom". The "zoom" is done by modifying the texture coordinates.
The ScaledDrawable2D class does this; the setScale()
call changes the "zoom", rather than scaling the rect itself. Texture coordinates range from 0.0 to 1.0 inclusive, and the getTexCoordArray()
method modifies them to span a subset of the texture.
To clip the frames, you'd need to modify the texture coordinates proportionally. For example, if the input video is portrait 720x1280, and you want 720x720, you would change the coordinates from this:
[0.0, 0.0] [1.0, 0.0]
[0.0, 1.0] [1.0, 1.0]
to this:
[0.0, 280/1280.0] [1.0, 280/1280.0]
[0.0, 1000/1280.0] [1.0, 1000/1280.0]
and then render that on a square rather than a rectangle.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…