1.拍照
2.录视频
3.美颜,滤镜
1.加入CameraX Api
2.将glsurfaceview变成自定义的textureview渲染
3.离线渲染
4.将opengl java部分的代码变成可移植的c库,便于ios上的移植。
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}
dependencies
{
implementation 'com.github.moo611:OpenCamera:latestversion'
}
//注意在android代码块里添加java8支持!!
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<com.atech.glcamera.views.GLCameraView
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/glcamera"
android:layout_width="match_parent"
android:layout_height="match_parent" />
mCameraView.enableBeauty(true);
mCameraView.setBeautyLevel(0.5f);
private List<FilterFactory.FilterType>filters = new ArrayList<>();
...
filters.add(FilterFactory.FilterType.Original);
filters.add(FilterFactory.FilterType.Sunrise);
filters.add(FilterFactory.FilterType.Sunset);
filters.add(FilterFactory.FilterType.BlackWhite);
filters.add(FilterFactory.FilterType.WhiteCat);
filters.add(FilterFactory.FilterType.BlackCat);
filters.add(FilterFactory.FilterType.SkinWhiten);
mCameraView.updateFilter(filters.get(pos));
mCameraView.switchCamera();
mCameraView.takePicture(new FilteredBitmapCallback() {
@Override
public void onData(Bitmap bitmap) {
...
}
});
private boolean isRecording = false; // 录制状态
...
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isRecording = !isRecording;
mCameraView.changeRecordingState(isRecording);
}
});
mCameraView.setOuputMP4File(mFile);
mCameraView.setrecordFinishedListnener(new FileCallback() {
@Override
public void onData(File file) {
//update the gallery
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.fromFile(file)));
}
});
https://github.com/google/grafika