Show + capture camera. Attempts to record at 720p from the front-facing camera, displaying the preview and recording it simultaneously.
Use the record button to toggle recording on and off.
Recording continues until stopped. If you back out and return, recording will start again, with a real-time gap. If you try to play the movie while it’s recording, you will see an incomplete file (and probably cause the play movie activity to crash).
The recorded video is scaled to 640x480, so it will probably look squished. A real app would either set the recording size equal to the camera input size, or correct the aspect ratio by letter- or pillar-boxing the frames as they are rendered to the encoder.
You can select a filter to apply to the preview. It does not get applied to the recording. The shader used for the filters is not optimized, but seems to perform well on most devices (the original Nexus 7 (2012) being a notable exception). Demo here: http://www.youtube.com/watch?v=kH9kCP2T5Gg
The output is a video-only MP4 file (“camera-test.mp4”).
public class FullFrameRect {
private final Drawable2d mRectDrawable = new Drawable2d(Drawable2d.Prefab.FULL_RECTANGLE);
private Texture2dProgram mProgram;
public class Texture2dProgram {
public enum ProgramType { // 几种program的类型
TEXTURE_2D, TEXTURE_EXT, TEXTURE_EXT_BW, TEXTURE_EXT_FILT
}
private static final String VERTEX_SHADER = ""; // 定点和片段着色器的代码省略了
private static final String FRAGMENT_SHADER_2D = "" ;
// 以下几个成员变量才是关键
private int mProgramHandle; // openGL program 实际上就是这个mProgramHandle
private int muMVPMatrixLoc; // 投影矩阵
private int muTexMatrixLoc; // 纹理矩阵
private int muKernelLoc; // 内核 通过他配合片段着色器来实现滤镜功能
private int muTexOffsetLoc;
private int muColorAdjustLoc; // 颜色调整
private int maPositionLoc;
private int maTextureCoordLoc;
private int mTextureTarget;
private float[] mKernel = new float[KERNEL_SIZE];
private float[] mTexOffset;
private float mColorAdjust;
public Texture2dProgram(ProgramType programType) {}
public int createTextureObject(){}
public void setKernel(){}
public void draw(){}
}