Repository: lb377463323/GraphicsTestBed
Branch: master
Commit: d938435125c0
Files: 129
Total size: 150.9 KB
Directory structure:
gitextract_k952_mcx/
├── Camera/
│ ├── CameraV1/
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── .gitignore
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── lb377463323/
│ │ │ │ └── camera1/
│ │ │ │ └── MainActivity.java
│ │ │ └── res/
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── ids.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── values-w820dp/
│ │ │ └── dimens.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ └── CameraV2/
│ ├── .gitignore
│ ├── app/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── lb377463323/
│ │ │ └── camera2/
│ │ │ └── MainActivity.java
│ │ └── res/
│ │ ├── layout/
│ │ │ ├── activity_main.xml
│ │ │ └── gallery_imageview.xml
│ │ ├── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── values-w820dp/
│ │ └── dimens.xml
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── Filter/
│ ├── .gitignore
│ ├── .idea/
│ │ ├── gradle.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ ├── app/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── liubing/
│ │ │ └── filtertestbed/
│ │ │ ├── CameraV1.java
│ │ │ ├── CameraV1GLSurfaceView/
│ │ │ │ ├── CameraV1GLSurfaceView.java
│ │ │ │ ├── CameraV1GLSurfaceViewActivity.java
│ │ │ │ └── CameraV1Renderer.java
│ │ │ ├── CameraV1TextureView/
│ │ │ │ ├── CameraV1GLRenderer.java
│ │ │ │ └── CameraV1TextureViewActivity.java
│ │ │ ├── CameraV2.java
│ │ │ ├── CameraV2GLSurfaceView/
│ │ │ │ ├── CameraV2GLSurfaceView.java
│ │ │ │ ├── CameraV2GLSurfaceViewActivity.java
│ │ │ │ └── CameraV2Renderer.java
│ │ │ ├── FilterEngine.java
│ │ │ └── Utils.java
│ │ └── res/
│ │ ├── raw/
│ │ │ ├── base_fragment_shader.glsl
│ │ │ └── base_vertex_shader.glsl
│ │ ├── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── values-w820dp/
│ │ └── dimens.xml
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── JNIDemo/
│ ├── .gitignore
│ ├── app/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── lb6905/
│ │ │ └── jnidemo/
│ │ │ ├── MainActivity.java
│ │ │ └── TestClass.java
│ │ ├── jni/
│ │ │ ├── Android.mk
│ │ │ └── hello-jni.c
│ │ ├── obj/
│ │ │ └── local/
│ │ │ ├── arm64-v8a/
│ │ │ │ └── objs/
│ │ │ │ └── hello-jni/
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── armeabi/
│ │ │ │ └── objs/
│ │ │ │ └── hello-jni/
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── armeabi-v7a/
│ │ │ │ └── objs/
│ │ │ │ └── hello-jni/
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── mips/
│ │ │ │ └── objs/
│ │ │ │ └── hello-jni/
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── mips64/
│ │ │ │ └── objs/
│ │ │ │ └── hello-jni/
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ ├── x86/
│ │ │ │ └── objs/
│ │ │ │ └── hello-jni/
│ │ │ │ ├── hello-jni.o
│ │ │ │ └── hello-jni.o.d
│ │ │ └── x86_64/
│ │ │ └── objs/
│ │ │ └── hello-jni/
│ │ │ ├── hello-jni.o
│ │ │ └── hello-jni.o.d
│ │ └── res/
│ │ ├── layout/
│ │ │ └── activity_main.xml
│ │ └── values/
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── OpenGLES/
│ ├── .gitignore
│ ├── app/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── lb377463323/
│ │ │ └── opengles/
│ │ │ ├── GLActivity.java
│ │ │ ├── GLRenderer.java
│ │ │ └── Triangle.java
│ │ └── res/
│ │ └── values/
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: Camera/CameraV1/.gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
================================================
FILE: Camera/CameraV1/README.md
================================================
This is a CameraV1 Demo,it has preview、switch camera、take picture function.
================================================
FILE: Camera/CameraV1/app/.gitignore
================================================
/build
================================================
FILE: Camera/CameraV1/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.lb377463323.camera1"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.1'
}
================================================
FILE: Camera/CameraV1/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/liubing/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: Camera/CameraV1/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lb377463323.camera1">
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity android:name="com.lb377463323.camera1.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: Camera/CameraV1/app/src/main/java/com/lb377463323/camera1/MainActivity.java
================================================
package com.lb377463323.camera1;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.os.Bundle;
import android.os.Environment;
import android.os.Process;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MainActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener, View.OnClickListener, AdapterView.OnItemClickListener{
private String TAG = "MainActivity";
public static final String STORAGE_PATH = Environment.getExternalStorageDirectory().toString();
private Camera mCamera;
private TextureView mTextureView;
private int mCameraId;
private int mCameraNum;
private Button mCaptureButton;
private Button mSwitchCamButton;
private Button mPictureSizeButton;
private PopupWindow mPreviewPopupWindow;
private PopupWindow mPicturePopupWindow;
private Camera.Parameters mParameters;
private List<Camera.Size> mSupportedPreSizeList;
private List<Camera.Size> mSupportedPicSizeList;
private List<String> mPreviewSizeList;
private List<String> mPictureSizeList;
private ListView mPictureListView;
private MyAdapter mPictureAdapter;
private int mCaptureWidth;
private int mCaptureHeight;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextureView = (TextureView) findViewById(R.id.camera_preview);
mCaptureButton = (Button) findViewById(R.id.btn_capture);
mSwitchCamButton = (Button) findViewById(R.id.btn_switchCam);
mPictureSizeButton = (Button) findViewById(R.id.btn_pictureSize);
mCaptureButton.setOnClickListener(this);
mSwitchCamButton.setOnClickListener(this);
mPictureSizeButton.setOnClickListener(this);
if(checkCameraHardware(this)){
mCameraNum = Camera.getNumberOfCameras();
Log.i(TAG, "Camera Number: " + mCameraNum);
mTextureView.setSurfaceTextureListener(this);
}else {
Log.i(TAG, "Has not Camera!");
}
}
@Override
protected void onResume() {
super.onResume();
requestCamera(mCameraId);
initSizeList();
initParameters();
initPopupWindow();
}
//Check whether the device has a camera
private boolean checkCameraHardware(Context context){
if(context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)){
return true;//has Camera
}else {
return false;// has not Camera
}
}
private void setPreviewTexture(SurfaceTexture surfaceTexture) {
if (mCamera != null) {
try {
mCamera.setPreviewTexture(surfaceTexture);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
setPreviewTexture(surface);
setDisplayOrientation(90);
startPreview();
Log.i(TAG, "onSurfaceTextureAvailable: size:" + width +"," + height);
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btn_capture:
takePicture();
break;
case R.id.btn_switchCam:
switchCamera();
break;
case R.id.btn_pictureSize:
showPopupWindow(mPicturePopupWindow, mPictureSizeButton);
break;
default:
break;
}
}
public void takePicture(){
if (mCamera != null){
mCamera.takePicture(null, null, mPictureCallback);
}
}
public void switchCamera(){
if (mCameraNum > 1){
mCameraId = mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK ?
Camera.CameraInfo.CAMERA_FACING_FRONT : Camera.CameraInfo.CAMERA_FACING_BACK;
stopPreview();
closeCamera();
requestCamera(mCameraId);
initSizeList();
for (int i = 0; i < mPreviewSizeList.size(); i++) {
Log.i(TAG, "preview size " + i + " :" + mPreviewSizeList.get(i));
}
for (int j = 0; j < mPictureSizeList.size(); j++) {
Log.i(TAG, "picture size " + j + " :" + mPictureSizeList.get(j));
}
initParameters();
mPictureAdapter.notifyDataSetChanged();
setDisplayOrientation(90);
setPreviewTexture(mTextureView.getSurfaceTexture());
startPreview();
Log.i(TAG, "Camera has switched!");
}else {
Log.i(TAG, "This device does not support switch camera");
}
}
private Camera.ErrorCallback mErrorCallback = new Camera.ErrorCallback() {
@Override
public void onError(int error, Camera camera) {
Log.e(TAG, "onError: got camera error callback: " + error);
if (error == Camera.CAMERA_ERROR_SERVER_DIED) {
android.os.Process.killProcess(Process.myPid());
}
}
};
private Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
@Override
public void onPictureTaken(final byte[] data, Camera camera) {
new Thread(new Runnable() {
@Override
public void run() {
String path = STORAGE_PATH + "/DCIM" + "/CameraV1";
writeFile(path, data);
}
}, "captureThread").start();
startPreview();
}
};
public void writeFile(String path, byte[] data) {
Bitmap bitmap = null;
if (data != null){
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
}
if (bitmap != null){
Matrix matrix = new Matrix();
if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
matrix.postRotate(90);
}else if (mCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT){
matrix.postRotate(90);
matrix.postScale(1, -1);
}
Bitmap rotateBmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix,false);
saveBmp2SD(path, rotateBmp);
rotateBmp.recycle();
}
}
private void saveBmp2SD(String path, Bitmap bitmap){
File file = new File(path);
if (!file.exists()){
file.mkdir();
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String fileName = path + "/" + "IMG_" + timeStamp + ".jpg";
try {
FileOutputStream fos = new FileOutputStream(fileName);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
Log.i(TAG, "Take picture success!");
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.e(TAG, "The save file for take picture is not exists!");
} catch (IOException e) {
e.printStackTrace();
Log.e(TAG, "Take picture fail!");
}
}
private void setDisplayOrientation(int degree){
if (mCamera != null) {
mCamera.setDisplayOrientation(degree);
}
Log.i(TAG, "Set display orientation is : " + degree);
}
private void requestCamera(int mCameraId) {
openCamera(mCameraId);
}
private void openCamera(int cameraId){
try{
if (mCamera == null) {
mCamera = Camera.open(cameraId);
Log.i(TAG, "Camera has opened, cameraId is " + cameraId);
}
}catch (Exception e){
Log.e(TAG, "Open Camera has exception!");
}
}
private void startPreview(){
if (mCamera != null) {
mCamera.setErrorCallback(mErrorCallback);
mCamera.startPreview();
Log.i(TAG, "Camera Preview has started!");
}
}
private void stopPreview() {
if (mCamera != null){
mCamera.stopPreview();
Log.i(TAG, "Camera Preview has stopped!");
}
}
private void closeCamera() {
if (mCamera != null){
mCamera.setErrorCallback(null);
mCamera.release();
mCamera = null;
Log.i(TAG, "Camera has closed!");
}
}
@Override
protected void onPause() {
super.onPause();
stopPreview();
closeCamera();
}
private void initSizeList() {
mParameters = getParameters();
mSupportedPreSizeList = getSupportedPreviewSizes(mParameters);
mSupportedPicSizeList = getSupportedPictureSizes(mParameters);
}
private void initParameters() {
if (mSupportedPreSizeList != null && mSupportedPicSizeList != null) {
mParameters.setPreviewSize(mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width,
mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
Log.i(TAG, "initParameters: previewSize: " + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width +
"," + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
mCaptureWidth = mSupportedPicSizeList.get(mSupportedPicSizeList.size() - 1).width;
mCaptureHeight = mSupportedPicSizeList.get(mSupportedPicSizeList.size() - 1).height;
mParameters.setPictureSize(mCaptureWidth, mCaptureHeight);
Log.i(TAG, "initParameters: pictureSize: " + mCaptureWidth + "," + mCaptureHeight);
setParameters();
}
}
private void initPopupWindow() {
initPicturePopupWindow();
}
private void initPicturePopupWindow() {
mPictureAdapter = new MyAdapter(mPictureSizeList);
mPictureListView = new ListView(this);
mPictureListView.setId(R.id.pictureId);
mPictureListView.setAdapter(mPictureAdapter);
if (mPicturePopupWindow == null) {
mPicturePopupWindow = new PopupWindow(mPictureListView, 320, 320,true);
}
mPictureListView.setOnItemClickListener(this);
}
private void showPopupWindow(PopupWindow popupWindow, View view) {
if (popupWindow != null && view != null && !popupWindow.isShowing()) {
int[] location = new int[2];
view.getLocationOnScreen(location);
popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0], location[1] - popupWindow.getHeight());
} else {
if (popupWindow != null) {
popupWindow.dismiss();
}
}
}
class MyAdapter extends BaseAdapter {
List<String> sizeList = new ArrayList<>();
public MyAdapter(List<String> list) {
this.sizeList = list;
}
@Override
public int getCount() {
return sizeList.size();
}
@Override
public Object getItem(int position) {
return sizeList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = new TextView(MainActivity.this);
textView.setTextSize(18);
textView.setTextColor(Color.rgb(255, 255, 0));
textView.setText(sizeList.get(position));
return textView;
}
}
private Camera.Parameters getParameters() {
if (mCamera != null) {
return mCamera.getParameters();
}
return null;
}
private void setParameters() {
if(mCamera != null && mParameters != null) {
mCamera.setParameters(mParameters);
}
}
private List<Camera.Size> getSupportedPreviewSizes(Camera.Parameters parameters) {
if (parameters == null) {
return null;
}
if (mPreviewSizeList == null) {
mPreviewSizeList = new ArrayList<>();
} else {
mPreviewSizeList.clear();
}
mSupportedPreSizeList = new ArrayList<>();
for (Camera.Size size : parameters.getSupportedPreviewSizes()) {
if (equalsRate(size, 1.777f)) {
mSupportedPreSizeList.add(size);
}
}
for (Camera.Size size : mSupportedPreSizeList) {
mPreviewSizeList.add(size.width + "×" + size.height);
}
return mSupportedPreSizeList;
}
private List<Camera.Size> getSupportedPictureSizes(Camera.Parameters parameters) {
if (parameters == null) {
return null;
}
if (mPictureSizeList == null) {
mPictureSizeList = new ArrayList<>();
} else {
mPictureSizeList.clear();
}
mSupportedPicSizeList = new ArrayList<>();
for (Camera.Size size : parameters.getSupportedPictureSizes()) {
if(equalsRate(size, 1.777f)) {
mSupportedPicSizeList.add(size);
}
}
for (Camera.Size size : mSupportedPicSizeList) {
mPictureSizeList.add(size.width + "×" + size.height);
}
return mSupportedPicSizeList;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (parent.getId()) {
case R.id.pictureId:
Log.i(TAG, "onItemClick: PictureSize: " + mPictureSizeList.get(position));
setCaptureSize(mSupportedPicSizeList.get(position).width,
mSupportedPicSizeList.get(position).height);
mPicturePopupWindow.dismiss();
break;
default:
break;
}
}
private void setPreviewSize(float rate) {
if (!equalsRate(mParameters.getPreviewSize(), rate)) {
mParameters.setPreviewSize(mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width,
mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
Log.i(TAG, "setPreviewSize: changed: " + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).width +
"×" + mSupportedPreSizeList.get(mSupportedPreSizeList.size() - 1).height);
setParameters();
stopPreview();
startPreview();
} else {
return;
}
}
private void setCaptureSize(int captureWidth, int captureHeight) {
this.mCaptureWidth = captureWidth;
this.mCaptureHeight = captureHeight;
mParameters.setPictureSize(mCaptureWidth, mCaptureHeight);
if (mCamera != null) {
setParameters();
}
setPreviewSize((float) captureWidth / (float) captureHeight);
}
private boolean equalsRate(Camera.Size size, float rate){
float f = (float)size.width / (float) size.height;
if (Math.abs(f - rate) <= 0.1f) {
return true;
} else {
return false;
}
}
}
================================================
FILE: Camera/CameraV1/app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.lb377463323.camera1.MainActivity">
<TextureView
android:id="@+id/camera_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/btn_switchCam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="切换"/>
<Button
android:id="@+id/btn_capture"
android:text="拍照"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="@+id/btn_pictureSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="拍照尺寸"/>
</LinearLayout>
</RelativeLayout>
================================================
FILE: Camera/CameraV1/app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: Camera/CameraV1/app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: Camera/CameraV1/app/src/main/res/values/ids.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="pictureId" type="id"></item>
</resources>
================================================
FILE: Camera/CameraV1/app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">CameraV1</string>
</resources>
================================================
FILE: Camera/CameraV1/app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: Camera/CameraV1/app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: Camera/CameraV1/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: Camera/CameraV1/gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
================================================
FILE: Camera/CameraV1/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: Camera/CameraV1/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: Camera/CameraV1/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: Camera/CameraV1/settings.gradle
================================================
include ':app'
================================================
FILE: Camera/CameraV2/.gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
================================================
FILE: Camera/CameraV2/app/.gitignore
================================================
/build
================================================
FILE: Camera/CameraV2/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.lb377463323.camera2"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
}
================================================
FILE: Camera/CameraV2/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\AndroidSdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: Camera/CameraV2/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.lb377463323.camera2"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera2.full" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.lb377463323.camera2.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: Camera/CameraV2/app/src/main/java/com/lb377463323/camera2/MainActivity.java
================================================
package com.lb377463323.camera2;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.ImageFormat;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.media.Image;
import android.media.ImageReader;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.v4.app.ActivityCompat;
import android.util.Size;
import android.util.SparseIntArray;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
public class MainActivity extends Activity {
private static final SparseIntArray ORIENTATION = new SparseIntArray();
static {
ORIENTATION.append(Surface.ROTATION_0, 90);
ORIENTATION.append(Surface.ROTATION_90, 0);
ORIENTATION.append(Surface.ROTATION_180, 270);
ORIENTATION.append(Surface.ROTATION_270, 180);
}
private String mCameraId;
private Size mPreviewSize;
private Size mCaptureSize;
private HandlerThread mCameraThread;
private Handler mCameraHandler;
private CameraDevice mCameraDevice;
private TextureView mTextureView;
private ImageReader mImageReader;
private CaptureRequest.Builder mCaptureRequestBuilder;
private CaptureRequest mCaptureRequest;
private CameraCaptureSession mCameraCaptureSession;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//全屏无状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
mTextureView = (TextureView) findViewById(R.id.textureView);
}
@Override
protected void onResume() {
super.onResume();
startCameraThread();
if (!mTextureView.isAvailable()) {
mTextureView.setSurfaceTextureListener(mTextureListener);
} else {
startPreview();
}
}
private void startCameraThread() {
mCameraThread = new HandlerThread("CameraThread");
mCameraThread.start();
mCameraHandler = new Handler(mCameraThread.getLooper());
}
private TextureView.SurfaceTextureListener mTextureListener = new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
//当SurefaceTexture可用的时候,设置相机参数并打开相机
setupCamera(width, height);
openCamera();
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
};
private void setupCamera(int width, int height) {
//获取摄像头的管理者CameraManager
CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
//遍历所有摄像头
for (String cameraId : manager.getCameraIdList()) {
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
//此处默认打开后置摄像头
if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT)
continue;
//获取StreamConfigurationMap,它是管理摄像头支持的所有输出格式和尺寸
StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
assert map != null;
//根据TextureView的尺寸设置预览尺寸
mPreviewSize = getOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height);
//获取相机支持的最大拍照尺寸
mCaptureSize = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new Comparator<Size>() {
@Override
public int compare(Size lhs, Size rhs) {
return Long.signum(lhs.getWidth() * lhs.getHeight() - rhs.getHeight() * rhs.getWidth());
}
});
//此ImageReader用于拍照所需
setupImageReader();
mCameraId = cameraId;
break;
}
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
//选择sizeMap中大于并且最接近width和height的size
private Size getOptimalSize(Size[] sizeMap, int width, int height) {
List<Size> sizeList = new ArrayList<>();
for (Size option : sizeMap) {
if (width > height) {
if (option.getWidth() > width && option.getHeight() > height) {
sizeList.add(option);
}
} else {
if (option.getWidth() > height && option.getHeight() > width) {
sizeList.add(option);
}
}
}
if (sizeList.size() > 0) {
return Collections.min(sizeList, new Comparator<Size>() {
@Override
public int compare(Size lhs, Size rhs) {
return Long.signum(lhs.getWidth() * lhs.getHeight() - rhs.getWidth() * rhs.getHeight());
}
});
}
return sizeMap[0];
}
private void openCamera() {
CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
return;
}
manager.openCamera(mCameraId, mStateCallback, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
private CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
@Override
public void onOpened(CameraDevice camera) {
mCameraDevice = camera;
startPreview();
}
@Override
public void onDisconnected(CameraDevice camera) {
camera.close();
mCameraDevice = null;
}
@Override
public void onError(CameraDevice camera, int error) {
camera.close();
mCameraDevice = null;
}
};
private void startPreview() {
SurfaceTexture mSurfaceTexture = mTextureView.getSurfaceTexture();
mSurfaceTexture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
Surface previewSurface = new Surface(mSurfaceTexture);
try {
mCaptureRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mCaptureRequestBuilder.addTarget(previewSurface);
mCameraDevice.createCaptureSession(Arrays.asList(previewSurface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(CameraCaptureSession session) {
try {
mCaptureRequest = mCaptureRequestBuilder.build();
mCameraCaptureSession = session;
mCameraCaptureSession.setRepeatingRequest(mCaptureRequest, null, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
@Override
public void onConfigureFailed(CameraCaptureSession session) {
}
}, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
public void takePicture(View view) {
lockFocus();
}
private void lockFocus() {
try {
mCaptureRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START);
mCameraCaptureSession.capture(mCaptureRequestBuilder.build(), mCaptureCallback, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request, CaptureResult partialResult) {
}
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
capture();
}
};
private void capture() {
try {
final CaptureRequest.Builder mCaptureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
int rotation = getWindowManager().getDefaultDisplay().getRotation();
mCaptureBuilder.addTarget(mImageReader.getSurface());
mCaptureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATION.get(rotation));
CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) {
Toast.makeText(getApplicationContext(), "Image Saved!", Toast.LENGTH_SHORT).show();
unLockFocus();
}
};
mCameraCaptureSession.stopRepeating();
mCameraCaptureSession.capture(mCaptureBuilder.build(), CaptureCallback, null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
private void unLockFocus() {
try {
mCaptureRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
//mCameraCaptureSession.capture(mCaptureRequestBuilder.build(), null, mCameraHandler);
mCameraCaptureSession.setRepeatingRequest(mCaptureRequest, null, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
@Override
protected void onPause() {
super.onPause();
if (mCameraCaptureSession != null) {
mCameraCaptureSession.close();
mCameraCaptureSession = null;
}
if (mCameraDevice != null) {
mCameraDevice.close();
mCameraDevice = null;
}
if (mImageReader != null) {
mImageReader.close();
mImageReader = null;
}
}
private void setupImageReader() {
//2代表ImageReader中最多可以获取两帧图像流
mImageReader = ImageReader.newInstance(mCaptureSize.getWidth(), mCaptureSize.getHeight(),
ImageFormat.JPEG, 2);
mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
mCameraHandler.post(new imageSaver(reader.acquireNextImage()));
}
}, mCameraHandler);
}
public static class imageSaver implements Runnable {
private Image mImage;
public imageSaver(Image image) {
mImage = image;
}
@Override
public void run() {
ByteBuffer buffer = mImage.getPlanes()[0].getBuffer();
byte[] data = new byte[buffer.remaining()];
buffer.get(data);
String path = Environment.getExternalStorageDirectory() + "/DCIM/CameraV2/";
File mImageFile = new File(path);
if (!mImageFile.exists()) {
mImageFile.mkdir();
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String fileName = path + "IMG_" + timeStamp + ".jpg";
FileOutputStream fos = null;
try {
fos = new FileOutputStream(fileName);
fos.write(data, 0, data.length);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}
================================================
FILE: Camera/CameraV2/app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.lb377463323.camera2.MainActivity">
<TextureView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/textureView"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拍照"
android:id="@+id/photoButton"
android:onClick="takePicture"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
================================================
FILE: Camera/CameraV2/app/src/main/res/layout/gallery_imageview.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/galleryImageView"
android:layout_margin="10dp"
android:layout_alignParentTop="true"/>
</RelativeLayout>
================================================
FILE: Camera/CameraV2/app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: Camera/CameraV2/app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: Camera/CameraV2/app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">CameraV2</string>
</resources>
================================================
FILE: Camera/CameraV2/app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: Camera/CameraV2/app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: Camera/CameraV2/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: Camera/CameraV2/gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
================================================
FILE: Camera/CameraV2/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: Camera/CameraV2/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: Camera/CameraV2/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: Camera/CameraV2/settings.gradle
================================================
include ':app'
================================================
FILE: Filter/.gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
================================================
FILE: Filter/.idea/gradle.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
================================================
FILE: Filter/.idea/misc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
================================================
FILE: Filter/.idea/modules.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Filter.iml" filepath="$PROJECT_DIR$/Filter.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
================================================
FILE: Filter/.idea/runConfigurations.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
================================================
FILE: Filter/app/.gitignore
================================================
/build
================================================
FILE: Filter/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.liubing.filtertestbed"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
}
================================================
FILE: Filter/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\AndroidSdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: Filter/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.liubing.filtertestbed"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-feature android:name="android.hardware.camera2.full" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--<activity android:name=".CameraV1GLSurfaceView.CameraV1GLSurfaceViewActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>-->
<!--<activity android:name=".CameraV1TextureView.CameraV1TextureViewActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>-->
<activity android:name=".CameraV2GLSurfaceView.CameraV2GLSurfaceViewActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1.java
================================================
package com.liubing.filtertestbed;
import android.app.Activity;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.util.Log;
import android.view.Surface;
import java.io.IOException;
/**
* Created by lb6905 on 2017/6/27.
*/
public class CameraV1 {
private Activity mActivity;
private int mCameraId;
private Camera mCamera;
public CameraV1(Activity activity) {
mActivity = activity;
}
public boolean openCamera(int screenWidth, int screenHeight, int cameraId) {
try {
mCameraId = cameraId;
mCamera = Camera.open(mCameraId);
Camera.Parameters parameters = mCamera.getParameters();
parameters.set("orientation", "portrait");
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
parameters.setPreviewSize(1280, 720);
setCameraDisplayOrientation(mActivity, mCameraId, mCamera);
mCamera.setParameters(parameters);
Log.i("lb6905", "open camera");
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
public static void setCameraDisplayOrientation(Activity activity,
int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay()
.getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0: degrees = 0; break;
case Surface.ROTATION_90: degrees = 90; break;
case Surface.ROTATION_180: degrees = 180; break;
case Surface.ROTATION_270: degrees = 270; break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation - degrees + 360) % 360;
}
camera.setDisplayOrientation(result);
}
public void startPreview() {
if (mCamera != null) {
mCamera.startPreview();
}
}
public void stopPreview() {
if (mCamera != null) {
mCamera.stopPreview();
}
}
public void setPreviewTexture(SurfaceTexture surfaceTexture) {
if (mCamera != null) {
try {
mCamera.setPreviewTexture(surfaceTexture);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void releaseCamera() {
if (mCamera != null) {
mCamera.release();
mCamera = null;
}
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceView.java
================================================
package com.liubing.filtertestbed.CameraV1GLSurfaceView;
import android.content.Context;
import android.opengl.GLSurfaceView;
import com.liubing.filtertestbed.CameraV1;
/**
* Created by lb6905 on 2017/6/12.
*/
public class CameraV1GLSurfaceView extends GLSurfaceView {
private CameraV1Renderer mRenderer;
private int textureId = -1;
public CameraV1GLSurfaceView(Context context) {
super(context);
}
public void init(CameraV1 camera, boolean isPreviewStarted, Context context) {
setEGLContextClientVersion(2);
mRenderer = new CameraV1Renderer();
mRenderer.init(this, camera, isPreviewStarted, context);
setRenderer(mRenderer);
}
public void deinit() {
if (mRenderer != null) {
mRenderer.deinit();
mRenderer = null;
textureId = -1;
}
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceViewActivity.java
================================================
package com.liubing.filtertestbed.CameraV1GLSurfaceView;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.hardware.Camera;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;
import com.liubing.filtertestbed.CameraV1;
public class CameraV1GLSurfaceViewActivity extends Activity {
private CameraV1GLSurfaceView mGLSurfaceView;
private int mCameraId;
private CameraV1 mCamera;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mGLSurfaceView = new CameraV1GLSurfaceView(this);
mCameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
DisplayMetrics dm = new DisplayMetrics();
mCamera = new CameraV1(this);
if (!mCamera.openCamera(dm.widthPixels, dm.heightPixels, mCameraId)) {
return;
}
mGLSurfaceView.init(mCamera, false, CameraV1GLSurfaceViewActivity.this);
setContentView(mGLSurfaceView);
}
@Override
protected void onPause() {
super.onPause();
if (mGLSurfaceView != null) {
mGLSurfaceView.onPause();
mGLSurfaceView.deinit();
mGLSurfaceView = null;
}
if (mCamera != null) {
mCamera.stopPreview();
mCamera.releaseCamera();
mCamera = null;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1Renderer.java
================================================
package com.liubing.filtertestbed.CameraV1GLSurfaceView;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLES11Ext;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.util.Log;
import com.liubing.filtertestbed.FilterEngine;
import com.liubing.filtertestbed.CameraV1;
import com.liubing.filtertestbed.Utils;
import java.nio.FloatBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import static android.opengl.GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
import static android.opengl.GLES20.GL_FLOAT;
import static android.opengl.GLES20.GL_FRAMEBUFFER;
import static android.opengl.GLES20.GL_TRIANGLES;
import static android.opengl.GLES20.glActiveTexture;
import static android.opengl.GLES20.glBindFramebuffer;
import static android.opengl.GLES20.glBindTexture;
import static android.opengl.GLES20.glClearColor;
import static android.opengl.GLES20.glDrawArrays;
import static android.opengl.GLES20.glEnableVertexAttribArray;
import static android.opengl.GLES20.glGenFramebuffers;
import static android.opengl.GLES20.glGetAttribLocation;
import static android.opengl.GLES20.glGetUniformLocation;
import static android.opengl.GLES20.glUniform1i;
import static android.opengl.GLES20.glUniformMatrix4fv;
import static android.opengl.GLES20.glVertexAttribPointer;
import static android.opengl.GLES20.glViewport;
/**
* Created by lb6905 on 2017/6/12.
*/
public class CameraV1Renderer implements GLSurfaceView.Renderer {
private static final String TAG = "Filter_MyRenderer";
private Context mContext;
private int mOESTextureId = -1;
private SurfaceTexture mSurfaceTexture;
private float[] transformMatrix = new float[16];
private CameraV1GLSurfaceView mGLSurfaceView;
private CameraV1 mCamera;
private boolean bIsPreviewStarted;
private FilterEngine mFilterEngine;
private FloatBuffer mDataBuffer;
private int mShaderProgram = -1;
private int aPositionLocation = -1;
private int aTextureCoordLocation = -1;
private int uTextureMatrixLocation = -1;
private int uTextureSamplerLocation = -1;
private int[] mFBOIds = new int[1];
public void init(CameraV1GLSurfaceView glSurfaceView, CameraV1 camera, boolean isPreviewStarted, Context context) {
mContext = context;
mGLSurfaceView = glSurfaceView;
mCamera = camera;
bIsPreviewStarted = isPreviewStarted;
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
mOESTextureId = Utils.createOESTextureObject();
mFilterEngine = new FilterEngine(mOESTextureId, mContext);
mDataBuffer = mFilterEngine.getBuffer();
mShaderProgram = mFilterEngine.getShaderProgram();
glGenFramebuffers(1, mFBOIds, 0);
glBindFramebuffer(GL_FRAMEBUFFER, mFBOIds[0]);
Log.i("lb6905", "onSurfaceCreated: mFBOId: " + mFBOIds[0]);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
glViewport(0, 0, width, height);
}
@Override
public void onDrawFrame(GL10 gl) {
Long t1 = System.currentTimeMillis();
if (mSurfaceTexture != null) {
mSurfaceTexture.updateTexImage();
mSurfaceTexture.getTransformMatrix(transformMatrix);
}
if (!bIsPreviewStarted) {
bIsPreviewStarted = initSurfaceTexture();
bIsPreviewStarted = true;
return;
}
//glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
aPositionLocation = glGetAttribLocation(mShaderProgram, FilterEngine.POSITION_ATTRIBUTE);
aTextureCoordLocation = glGetAttribLocation(mShaderProgram, FilterEngine.TEXTURE_COORD_ATTRIBUTE);
uTextureMatrixLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_MATRIX_UNIFORM);
uTextureSamplerLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_SAMPLER_UNIFORM);
glActiveTexture(GLES20.GL_TEXTURE0);
glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mOESTextureId);
glUniform1i(uTextureSamplerLocation, 0);
glUniformMatrix4fv(uTextureMatrixLocation, 1, false, transformMatrix, 0);
if (mDataBuffer != null) {
mDataBuffer.position(0);
glEnableVertexAttribArray(aPositionLocation);
glVertexAttribPointer(aPositionLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
mDataBuffer.position(2);
glEnableVertexAttribArray(aTextureCoordLocation);
glVertexAttribPointer(aTextureCoordLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
}
//glDrawElements(GL_TRIANGLE_FAN, 6,GL_UNSIGNED_INT, 0);
//glDrawArrays(GL_TRIANGLE_FAN, 0 , 6);
glDrawArrays(GL_TRIANGLES, 0, 6);
//glDrawArrays(GL_TRIANGLES, 3, 3);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
long t2 = System.currentTimeMillis();
long t = t2 - t1;
Log.i("lb6905", "onDrawFrame: time: " + t);
}
public boolean initSurfaceTexture() {
if (mCamera == null || mGLSurfaceView == null) {
Log.i(TAG, "mCamera or mGLSurfaceView is null!");
return false;
}
mSurfaceTexture = new SurfaceTexture(mOESTextureId);
mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
mGLSurfaceView.requestRender();
}
});
mCamera.setPreviewTexture(mSurfaceTexture);
mCamera.startPreview();
return true;
}
public void deinit() {
if (mFilterEngine != null) {
mFilterEngine = null;
}
mDataBuffer = null;
if (mSurfaceTexture != null) {
mSurfaceTexture.release();
mSurfaceTexture = null;
}
mCamera = null;
mOESTextureId = -1;
bIsPreviewStarted = false;
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1GLRenderer.java
================================================
package com.liubing.filtertestbed.CameraV1TextureView;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.util.Log;
import android.view.TextureView;
import com.liubing.filtertestbed.FilterEngine;
import java.nio.FloatBuffer;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
/**
* Created by lb6905 on 2017/6/28.
*/
public class CameraV1GLRenderer implements SurfaceTexture.OnFrameAvailableListener {
private static final String TAG = "Filter_GLRenderer";
private Context mContext;
private HandlerThread mHandlerThread;
private Handler mHandler;
private TextureView mTextureView;
private int mOESTextureId;
private FilterEngine mFilterEngine;
private FloatBuffer mDataBuffer;
private int mShaderProgram = -1;
private float[] transformMatrix = new float[16];
private EGL10 mEgl = null;
private EGLDisplay mEGLDisplay = EGL10.EGL_NO_DISPLAY;
private EGLContext mEGLContext = EGL10.EGL_NO_CONTEXT;
private EGLConfig[] mEGLConfig = new EGLConfig[1];
private EGLSurface mEglSurface;
private static final int MSG_INIT = 1;
private static final int MSG_RENDER = 2;
private static final int MSG_DEINIT = 3;
private SurfaceTexture mOESSurfaceTexture;
public void init(TextureView textureView, int oesTextureId, Context context) {
mContext = context;
mTextureView = textureView;
mOESTextureId = oesTextureId;
mHandlerThread = new HandlerThread("Renderer Thread");
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper()){
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_INIT:
initEGL();
return;
case MSG_RENDER:
drawFrame();
return;
case MSG_DEINIT:
return;
default:
return;
}
}
};
mHandler.sendEmptyMessage(MSG_INIT);
}
private void initEGL() {
mEgl = (EGL10) EGLContext.getEGL();
//获取显示设备
mEGLDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
throw new RuntimeException("eglGetDisplay failed! " + mEgl.eglGetError());
}
//version中存放EGL版本号
int[] version = new int[2];
//初始化EGL
if (!mEgl.eglInitialize(mEGLDisplay, version)) {
throw new RuntimeException("eglInitialize failed! " + mEgl.eglGetError());
}
//构造需要的配置列表
int[] attributes = {
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE,8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_BUFFER_SIZE, 32,
EGL10.EGL_RENDERABLE_TYPE, 4,
EGL10.EGL_SURFACE_TYPE, EGL10.EGL_WINDOW_BIT,
EGL10.EGL_NONE
};
int[] configsNum = new int[1];
//EGL选择配置
if (!mEgl.eglChooseConfig(mEGLDisplay, attributes, mEGLConfig, 1, configsNum)) {
throw new RuntimeException("eglChooseConfig failed! " + mEgl.eglGetError());
}
SurfaceTexture surfaceTexture = mTextureView.getSurfaceTexture();
if (surfaceTexture == null)
return;
//创建EGL显示窗口
mEglSurface = mEgl.eglCreateWindowSurface(mEGLDisplay, mEGLConfig[0], surfaceTexture, null);
//创建上下文
int[] contextAttribs = {
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE
};
mEGLContext = mEgl.eglCreateContext(mEGLDisplay, mEGLConfig[0], EGL10.EGL_NO_CONTEXT, contextAttribs);
if (mEGLDisplay == EGL10.EGL_NO_DISPLAY || mEGLContext == EGL10.EGL_NO_CONTEXT){
throw new RuntimeException("eglCreateContext fail failed! " + mEgl.eglGetError());
}
if (!mEgl.eglMakeCurrent(mEGLDisplay,mEglSurface, mEglSurface, mEGLContext)) {
throw new RuntimeException("eglMakeCurrent failed! " + mEgl.eglGetError());
}
mFilterEngine = new FilterEngine(mOESTextureId, mContext);
mDataBuffer = mFilterEngine.getBuffer();
mShaderProgram = mFilterEngine.getShaderProgram();
}
private void drawFrame() {
long t1, t2;
t1 = System.currentTimeMillis();
if (mOESSurfaceTexture != null) {
mOESSurfaceTexture.updateTexImage();
mOESSurfaceTexture.getTransformMatrix(transformMatrix);
}
mEgl.eglMakeCurrent(mEGLDisplay, mEglSurface, mEglSurface, mEGLContext);
GLES20.glViewport(0,0,mTextureView.getWidth(),mTextureView.getHeight());
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glClearColor(1f, 1f, 0f, 0f);
mFilterEngine.drawTexture(transformMatrix);
mEgl.eglSwapBuffers(mEGLDisplay, mEglSurface);
t2 = System.currentTimeMillis();
Log.i(TAG, "drawFrame: time = " + (t2 - t1));
}
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
if (mHandler != null) {
mHandler.sendEmptyMessage(MSG_RENDER);
}
}
public SurfaceTexture initOESTexture() {
mOESSurfaceTexture = new SurfaceTexture(mOESTextureId);
mOESSurfaceTexture.setOnFrameAvailableListener(this);
return mOESSurfaceTexture;
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1TextureViewActivity.java
================================================
package com.liubing.filtertestbed.CameraV1TextureView;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.view.TextureView;
import android.view.Window;
import android.view.WindowManager;
import com.liubing.filtertestbed.CameraV1;
import com.liubing.filtertestbed.Utils;
/**
* Created by lb6905 on 2017/6/28.
*/
public class CameraV1TextureViewActivity extends Activity {
private static final String TAG = "Filter_TVActivity";
private TextureView mTextureView;
private int mCameraId;
private CameraV1 mCamera;
private SurfaceTexture mOESSurfaceTexture;
private int mOESTextureId = -1;
private CameraV1GLRenderer mRenderer;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//设置全屏无状态栏,并竖屏显示
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(mTextureListener);
//设置隐藏虚拟按键
//mTextureView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
mRenderer = new CameraV1GLRenderer();
setContentView(mTextureView);
}
public TextureView.SurfaceTextureListener mTextureListener = new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
mOESTextureId = Utils.createOESTextureObject();
mRenderer.init(mTextureView, mOESTextureId, CameraV1TextureViewActivity.this);
mOESSurfaceTexture = mRenderer.initOESTexture();
mCameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
DisplayMetrics dm = new DisplayMetrics();
mCamera = new CameraV1(CameraV1TextureViewActivity.this);
if (!mCamera.openCamera(dm.widthPixels, dm.heightPixels, mCameraId)) {
return;
}
mCamera.setPreviewTexture(mOESSurfaceTexture);
mCamera.startPreview();
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
if (mCamera != null) {
mCamera.stopPreview();
mCamera.releaseCamera();
mCamera = null;
}
return true;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
};
@Override
protected void onPause() {
super.onPause();
if (mCamera != null) {
mCamera.stopPreview();
mCamera.releaseCamera();
mCamera = null;
}
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2.java
================================================
package com.liubing.filtertestbed;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.util.Size;
import android.view.Surface;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* Created by lb6905 on 2017/7/20.
*/
public class CameraV2 {
public static final String TAG = "Filter_CameraV2";
private Activity mActivity;
private CameraDevice mCameraDevice;
private String mCameraId;
private Size mPreviewSize;
private HandlerThread mCameraThread;
private Handler mCameraHandler;
private SurfaceTexture mSurfaceTexture;
private CaptureRequest.Builder mCaptureRequestBuilder;
private CaptureRequest mCaptureRequest;
private CameraCaptureSession mCameraCaptureSession;
public CameraV2(Activity activity) {
mActivity = activity;
startCameraThread();
}
public String setupCamera(int width, int height) {
CameraManager cameraManager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
try {
for (String id : cameraManager.getCameraIdList()) {
CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(id);
if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
continue;
}
StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
mPreviewSize = getOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height);
mCameraId = id;
Log.i(TAG, "preview width = " + mPreviewSize.getWidth() + ", height = " + mPreviewSize.getHeight() + ", cameraId = " + mCameraId);
}
} catch (CameraAccessException e) {
e.printStackTrace();
}
return mCameraId;
}
public void startCameraThread() {
mCameraThread = new HandlerThread("CameraThread");
mCameraThread.start();
mCameraHandler = new Handler(mCameraThread.getLooper());
}
public boolean openCamera() {
CameraManager cameraManager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
try {
if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
return false;
}
cameraManager.openCamera(mCameraId, mStateCallback, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
return false;
}
return true;
}
public CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
@Override
public void onOpened(@NonNull CameraDevice camera) {
mCameraDevice = camera;
}
@Override
public void onDisconnected(@NonNull CameraDevice camera) {
camera.close();
mCameraDevice = null;
}
@Override
public void onError(@NonNull CameraDevice camera, int error) {
camera.close();
mCameraDevice = null;
}
};
private Size getOptimalSize(Size[] sizeMap, int width, int height) {
List<Size> sizeList = new ArrayList<>();
for (Size option : sizeMap) {
if (width > height) {
if (option.getWidth() > width && option.getHeight() > height) {
sizeList.add(option);
}
} else {
if (option.getWidth() > height && option.getHeight() > width) {
sizeList.add(option);
}
}
}
if (sizeList.size() > 0) {
return Collections.min(sizeList, new Comparator<Size>() {
@Override
public int compare(Size lhs, Size rhs) {
return Long.signum(lhs.getWidth() * lhs.getHeight() - rhs.getWidth() * rhs.getHeight());
}
});
}
return sizeMap[0];
}
public void setPreviewTexture(SurfaceTexture surfaceTexture) {
mSurfaceTexture = surfaceTexture;
}
public void startPreview() {
mSurfaceTexture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
Surface surface = new Surface(mSurfaceTexture);
try {
mCaptureRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mCaptureRequestBuilder.addTarget(surface);
mCameraDevice.createCaptureSession(Arrays.asList(surface), new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(@NonNull CameraCaptureSession session) {
try {
mCaptureRequest = mCaptureRequestBuilder.build();
mCameraCaptureSession = session;
mCameraCaptureSession.setRepeatingRequest(mCaptureRequest, null, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
@Override
public void onConfigureFailed(@NonNull CameraCaptureSession session) {
}
}, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceView.java
================================================
package com.liubing.filtertestbed.CameraV2GLSurfaceView;
import android.content.Context;
import android.opengl.GLSurfaceView;
import com.liubing.filtertestbed.CameraV1;
import com.liubing.filtertestbed.CameraV2;
/**
* Created by lb6905 on 2017/7/19.
*/
public class CameraV2GLSurfaceView extends GLSurfaceView {
public static final String TAG = "Filter_CameraV2GLSurfaceView";
private CameraV2Renderer mCameraV2Renderer;
public void init(CameraV2 camera, boolean isPreviewStarted, Context context) {
setEGLContextClientVersion(2);
mCameraV2Renderer = new CameraV2Renderer();
mCameraV2Renderer.init(this, camera, isPreviewStarted, context);
setRenderer(mCameraV2Renderer);
}
public CameraV2GLSurfaceView(Context context) {
super(context);
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceViewActivity.java
================================================
package com.liubing.filtertestbed.CameraV2GLSurfaceView;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import com.liubing.filtertestbed.CameraV2;
/**
* Created by lb6905 on 2017/7/19.
*/
public class CameraV2GLSurfaceViewActivity extends Activity {
private CameraV2GLSurfaceView mCameraV2GLSurfaceView;
private CameraV2 mCamera;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCameraV2GLSurfaceView = new CameraV2GLSurfaceView(this);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
mCamera = new CameraV2(this);
mCamera.setupCamera(dm.widthPixels, dm.heightPixels);
if (!mCamera.openCamera()) {
return;
}
mCameraV2GLSurfaceView.init(mCamera, false, CameraV2GLSurfaceViewActivity.this);
setContentView(mCameraV2GLSurfaceView);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2Renderer.java
================================================
package com.liubing.filtertestbed.CameraV2GLSurfaceView;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLES11Ext;
import android.opengl.GLSurfaceView;
import android.util.Log;
import com.liubing.filtertestbed.CameraV2;
import com.liubing.filtertestbed.FilterEngine;
import com.liubing.filtertestbed.Utils;
import java.nio.FloatBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import static android.opengl.GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
import static android.opengl.GLES20.GL_FLOAT;
import static android.opengl.GLES20.GL_FRAMEBUFFER;
import static android.opengl.GLES20.GL_TRIANGLES;
import static android.opengl.GLES20.glActiveTexture;
import static android.opengl.GLES20.glBindFramebuffer;
import static android.opengl.GLES20.glBindTexture;
import static android.opengl.GLES20.glClearColor;
import static android.opengl.GLES20.glDrawArrays;
import static android.opengl.GLES20.glEnableVertexAttribArray;
import static android.opengl.GLES20.glGenFramebuffers;
import static android.opengl.GLES20.glGetAttribLocation;
import static android.opengl.GLES20.glGetUniformLocation;
import static android.opengl.GLES20.glUniform1i;
import static android.opengl.GLES20.glUniformMatrix4fv;
import static android.opengl.GLES20.glVertexAttribPointer;
import static android.opengl.GLES20.glViewport;
/**
* Created by lb6905 on 2017/7/19.
*/
public class CameraV2Renderer implements GLSurfaceView.Renderer {
public static final String TAG = "Filter_CameraV2Renderer";
private Context mContext;
CameraV2GLSurfaceView mCameraV2GLSurfaceView;
CameraV2 mCamera;
boolean bIsPreviewStarted;
private int mOESTextureId = -1;
private SurfaceTexture mSurfaceTexture;
private float[] transformMatrix = new float[16];
private FilterEngine mFilterEngine;
private FloatBuffer mDataBuffer;
private int mShaderProgram = -1;
private int aPositionLocation = -1;
private int aTextureCoordLocation = -1;
private int uTextureMatrixLocation = -1;
private int uTextureSamplerLocation = -1;
private int[] mFBOIds = new int[1];
public void init(CameraV2GLSurfaceView surfaceView, CameraV2 camera, boolean isPreviewStarted, Context context) {
mContext = context;
mCameraV2GLSurfaceView = surfaceView;
mCamera = camera;
bIsPreviewStarted = isPreviewStarted;
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
mOESTextureId = Utils.createOESTextureObject();
mFilterEngine = new FilterEngine(mOESTextureId, mContext);
mDataBuffer = mFilterEngine.getBuffer();
mShaderProgram = mFilterEngine.getShaderProgram();
glGenFramebuffers(1, mFBOIds, 0);
glBindFramebuffer(GL_FRAMEBUFFER, mFBOIds[0]);
Log.i(TAG, "onSurfaceCreated: mFBOId: " + mFBOIds[0]);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
glViewport(0, 0, width, height);
Log.i(TAG, "onSurfaceChanged: " + width + ", " + height);
}
@Override
public void onDrawFrame(GL10 gl) {
Long t1 = System.currentTimeMillis();
if (mSurfaceTexture != null) {
mSurfaceTexture.updateTexImage();
mSurfaceTexture.getTransformMatrix(transformMatrix);
}
if (!bIsPreviewStarted) {
bIsPreviewStarted = initSurfaceTexture();
bIsPreviewStarted = true;
return;
}
//glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
aPositionLocation = glGetAttribLocation(mShaderProgram, FilterEngine.POSITION_ATTRIBUTE);
aTextureCoordLocation = glGetAttribLocation(mShaderProgram, FilterEngine.TEXTURE_COORD_ATTRIBUTE);
uTextureMatrixLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_MATRIX_UNIFORM);
uTextureSamplerLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_SAMPLER_UNIFORM);
glActiveTexture(GL_TEXTURE_EXTERNAL_OES);
glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mOESTextureId);
glUniform1i(uTextureSamplerLocation, 0);
glUniformMatrix4fv(uTextureMatrixLocation, 1, false, transformMatrix, 0);
if (mDataBuffer != null) {
mDataBuffer.position(0);
glEnableVertexAttribArray(aPositionLocation);
glVertexAttribPointer(aPositionLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
mDataBuffer.position(2);
glEnableVertexAttribArray(aTextureCoordLocation);
glVertexAttribPointer(aTextureCoordLocation, 2, GL_FLOAT, false, 16, mDataBuffer);
}
//glDrawElements(GL_TRIANGLE_FAN, 6,GL_UNSIGNED_INT, 0);
//glDrawArrays(GL_TRIANGLE_FAN, 0 , 6);
glDrawArrays(GL_TRIANGLES, 0, 6);
//glDrawArrays(GL_TRIANGLES, 3, 3);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
long t2 = System.currentTimeMillis();
long t = t2 - t1;
Log.i(TAG, "onDrawFrame: time: " + t);
}
public boolean initSurfaceTexture() {
if (mCamera == null || mCameraV2GLSurfaceView == null) {
Log.i(TAG, "mCamera or mGLSurfaceView is null!");
return false;
}
mSurfaceTexture = new SurfaceTexture(mOESTextureId);
mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
mCameraV2GLSurfaceView.requestRender();
}
});
mCamera.setPreviewTexture(mSurfaceTexture);
mCamera.startPreview();
return true;
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/FilterEngine.java
================================================
package com.liubing.filtertestbed;
import android.content.Context;
import android.opengl.GLES11Ext;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import static android.opengl.GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
import static android.opengl.GLES20.GL_FLOAT;
import static android.opengl.GLES20.GL_FRAGMENT_SHADER;
import static android.opengl.GLES20.GL_TRIANGLES;
import static android.opengl.GLES20.GL_VERTEX_SHADER;
import static android.opengl.GLES20.glActiveTexture;
import static android.opengl.GLES20.glAttachShader;
import static android.opengl.GLES20.glBindTexture;
import static android.opengl.GLES20.glCompileShader;
import static android.opengl.GLES20.glCreateProgram;
import static android.opengl.GLES20.glCreateShader;
import static android.opengl.GLES20.glDrawArrays;
import static android.opengl.GLES20.glEnableVertexAttribArray;
import static android.opengl.GLES20.glGetAttribLocation;
import static android.opengl.GLES20.glGetError;
import static android.opengl.GLES20.glGetUniformLocation;
import static android.opengl.GLES20.glLinkProgram;
import static android.opengl.GLES20.glShaderSource;
import static android.opengl.GLES20.glUniform1i;
import static android.opengl.GLES20.glUniformMatrix4fv;
import static android.opengl.GLES20.glUseProgram;
import static android.opengl.GLES20.glVertexAttribPointer;
/**
* Created by lb6905 on 2017/6/12.
*/
public class FilterEngine {
private static FilterEngine filterEngine = null;
private Context mContext;
private FloatBuffer mBuffer;
private int mOESTextureId = -1;
private int vertexShader = -1;
private int fragmentShader = -1;
private int mShaderProgram = -1;
private int aPositionLocation = -1;
private int aTextureCoordLocation = -1;
private int uTextureMatrixLocation = -1;
private int uTextureSamplerLocation = -1;
public FilterEngine(int OESTextureId, Context context) {
mContext = context;
mOESTextureId = OESTextureId;
mBuffer = createBuffer(vertexData);
vertexShader = loadShader(GL_VERTEX_SHADER, Utils.readShaderFromResource(mContext, R.raw.base_vertex_shader));
fragmentShader = loadShader(GL_FRAGMENT_SHADER, Utils.readShaderFromResource(mContext, R.raw.base_fragment_shader));
mShaderProgram = linkProgram(vertexShader, fragmentShader);
}
/*public static FilterEngine getInstance() {
if (filterEngine == null) {
synchronized (FilterEngine.class) {
if (filterEngine == null)
filterEngine = new FilterEngine();
}
}
return filterEngine;
}*/
private static final float[] vertexData = {
1f, 1f, 1f, 1f,
-1f, 1f, 0f, 1f,
-1f, -1f, 0f, 0f,
1f, 1f, 1f, 1f,
-1f, -1f, 0f, 0f,
1f, -1f, 1f, 0f
};
public static final String POSITION_ATTRIBUTE = "aPosition";
public static final String TEXTURE_COORD_ATTRIBUTE = "aTextureCoordinate";
public static final String TEXTURE_MATRIX_UNIFORM = "uTextureMatrix";
public static final String TEXTURE_SAMPLER_UNIFORM = "uTextureSampler";
public FloatBuffer createBuffer(float[] vertexData) {
FloatBuffer buffer = ByteBuffer.allocateDirect(vertexData.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
buffer.put(vertexData, 0, vertexData.length).position(0);
return buffer;
}
public int loadShader(int type, String shaderSource) {
int shader = glCreateShader(type);
if (shader == 0) {
throw new RuntimeException("Create Shader Failed!" + glGetError());
}
glShaderSource(shader, shaderSource);
glCompileShader(shader);
return shader;
}
public int linkProgram(int verShader, int fragShader) {
int program = glCreateProgram();
if (program == 0) {
throw new RuntimeException("Create Program Failed!" + glGetError());
}
glAttachShader(program, verShader);
glAttachShader(program, fragShader);
glLinkProgram(program);
glUseProgram(program);
return program;
}
public void drawTexture(float[] transformMatrix) {
aPositionLocation = glGetAttribLocation(mShaderProgram, FilterEngine.POSITION_ATTRIBUTE);
aTextureCoordLocation = glGetAttribLocation(mShaderProgram, FilterEngine.TEXTURE_COORD_ATTRIBUTE);
uTextureMatrixLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_MATRIX_UNIFORM);
uTextureSamplerLocation = glGetUniformLocation(mShaderProgram, FilterEngine.TEXTURE_SAMPLER_UNIFORM);
glActiveTexture(GLES20.GL_TEXTURE0);
glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mOESTextureId);
glUniform1i(uTextureSamplerLocation, 0);
glUniformMatrix4fv(uTextureMatrixLocation, 1, false, transformMatrix, 0);
if (mBuffer != null) {
mBuffer.position(0);
glEnableVertexAttribArray(aPositionLocation);
glVertexAttribPointer(aPositionLocation, 2, GL_FLOAT, false, 16, mBuffer);
mBuffer.position(2);
glEnableVertexAttribArray(aTextureCoordLocation);
glVertexAttribPointer(aTextureCoordLocation, 2, GL_FLOAT, false, 16, mBuffer);
glDrawArrays(GL_TRIANGLES, 0, 6);
}
}
public int getShaderProgram() {
return mShaderProgram;
}
public FloatBuffer getBuffer() {
return mBuffer;
}
public int getOESTextureId() {
return mOESTextureId;
}
public void setOESTextureId(int OESTextureId) {
mOESTextureId = OESTextureId;
}
}
================================================
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/Utils.java
================================================
package com.liubing.filtertestbed;
import android.content.Context;
import android.opengl.GLES11Ext;
import android.opengl.GLES20;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.microedition.khronos.opengles.GL10;
/**
* Created by lb6905 on 2017/6/28.
*/
public class Utils {
public static int createOESTextureObject() {
int[] tex = new int[1];
GLES20.glGenTextures(1, tex, 0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex[0]);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
return tex[0];
}
public static String readShaderFromResource(Context context, int resourceId) {
StringBuilder builder = new StringBuilder();
InputStream is = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
is = context.getResources().openRawResource(resourceId);
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
builder.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
is = null;
}
if (isr != null) {
isr.close();
isr = null;
}
if (br != null) {
br.close();
br = null;
}
} catch (IOException e) {
e.printStackTrace();
}
}
return builder.toString();
}
}
================================================
FILE: Filter/app/src/main/res/raw/base_fragment_shader.glsl
================================================
#extension GL_OES_EGL_image_external : require
precision mediump float;
uniform samplerExternalOES uTextureSampler;
varying vec2 vTextureCoord;
void main()
{
vec4 vCameraColor = texture2D(uTextureSampler, vTextureCoord);
float fGrayColor = (0.3*vCameraColor.r + 0.59*vCameraColor.g + 0.11*vCameraColor.b);
gl_FragColor = vec4(fGrayColor, fGrayColor, fGrayColor, 1.0);
}
================================================
FILE: Filter/app/src/main/res/raw/base_vertex_shader.glsl
================================================
attribute vec4 aPosition;
uniform mat4 uTextureMatrix;
attribute vec4 aTextureCoordinate;
varying vec2 vTextureCoord;
void main()
{
vTextureCoord = (uTextureMatrix * aTextureCoordinate).xy;
gl_Position = aPosition;
}
================================================
FILE: Filter/app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: Filter/app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: Filter/app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">FilterTestBed</string>
</resources>
================================================
FILE: Filter/app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: Filter/app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: Filter/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: Filter/gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
================================================
FILE: Filter/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: Filter/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: Filter/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: Filter/settings.gradle
================================================
include ':app'
================================================
FILE: JNIDemo/.gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
================================================
FILE: JNIDemo/app/.gitignore
================================================
/build
================================================
FILE: JNIDemo/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.lb6905.jnidemo"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
================================================
FILE: JNIDemo/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\ProgramFiles\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: JNIDemo/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lb6905.jnidemo">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: JNIDemo/app/src/main/java/com/lb6905/jnidemo/MainActivity.java
================================================
package com.lb6905.jnidemo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView mTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView = (TextView) findViewById(R.id.tv_jni);
int[] arr = getArray();
mTextView.setText(stringFromJNI());
JNIReflect();
}
public native String stringFromJNI();
public native void setArray(int[] array);
public native int[] getArray();
public native void JNIReflect();
static {
System.loadLibrary("hello-jni");
}
}
================================================
FILE: JNIDemo/app/src/main/java/com/lb6905/jnidemo/TestClass.java
================================================
package com.lb6905.jnidemo;
import android.util.Log;
/**
* Created by lb6905 on 2017/7/18.
*/
public class TestClass {
private final static String TAG = "TestClass";
public TestClass(){
Log.i(TAG, "TestClass");
}
public void test(int index) {
Log.i(TAG, "test : " + index);
}
public static void testStatic(String str) {
Log.i(TAG, "testStatic : " + str);
}
public static class InnerClass {
private int num;
public InnerClass() {
Log.i(TAG, "InnerClass");
}
public void setInt(int n) {
num = n;
Log.i(TAG, "setInt: num = " + num);
}
}
}
================================================
FILE: JNIDemo/app/src/main/jni/Android.mk
================================================
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
include $(BUILD_SHARED_LIBRARY)
================================================
FILE: JNIDemo/app/src/main/jni/hello-jni.c
================================================
//
// Created by lb6905 on 2017/6/21.
//
#include <jni.h>
#include <string.h>
#ifndef _Included_com_lb6905_jnidemo_MainActivity
#define _Included_com_lb6905_jnidemo_MainActivity
int lutData[5] = {0,10,12,3,4};
jstring
Java_com_lb6905_jnidemo_MainActivity_stringFromJNI( JNIEnv* env,
jobject thiz )
{
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
/*
* Class: com_lb6905_jnidemo_MainActivity
* Method: setArray
* Signature: ([I)V
*/
JNIEXPORT void JNICALL Java_com_lb6905_jnidemo_MainActivity_setArray
(JNIEnv *env, jobject thiz, jintArray array)
{
}
/*
* Class: com_lb6905_jnidemo_MainActivity
* Method: getArray
* Signature: ()[I
*/
JNIEXPORT jintArray JNICALL Java_com_lb6905_jnidemo_MainActivity_getArray
(JNIEnv *env, jobject thiz)
{
jintArray array = (*env)->NewIntArray(env, 5);
(*env)->SetIntArrayRegion(env, array, 0, 5, lutData);
return array;
}
JNIEXPORT void JNICALL Java_com_lb6905_jnidemo_MainActivity_JNIReflect
(JNIEnv *env, jobject thiz)
{
//实例化Test类
jclass testclass = (*env)->FindClass(env, "com/lb6905/jnidemo/TestClass");
jmethodID testcontruct = (*env)->GetMethodID(env, testclass, "<init>", "()V");
jobject testobject = (*env)->NewObject(env, testclass, testcontruct);
//调用成员方法
jmethodID test = (*env)->GetMethodID(env, testclass, "test", "(I)V");
(*env)->CallVoidMethod(env, testobject, test, 1);
//调用静态方法
jmethodID testStatic = (*env)->GetStaticMethodID(env, testclass, "testStatic", "(Ljava/lang/String;)V");
jstring str = (*env)->NewStringUTF(env, "hello world!");
(*env)->CallStaticVoidMethod(env, testclass, testStatic, str);
//实例化InnerClass子类
jclass innerclass = (*env)->FindClass(env, "com/lb6905/jnidemo/TestClass$InnerClass");
jmethodID innercontruct = (*env)->GetMethodID(env, innerclass, "<init>", "()V");
jobject innerobject = (*env)->NewObject(env, innerclass, innercontruct);
jmethodID setInt = (*env)->GetMethodID(env, innerclass, "setInt", "(I)V");
(*env)->CallVoidMethod(env, innerobject, setInt, 2);
}
#endif
================================================
FILE: JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o.d
================================================
F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o: \
F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
================================================
FILE: JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o.d
================================================
F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o: \
F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
================================================
FILE: JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o.d
================================================
F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o: \
F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
================================================
FILE: JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o.d
================================================
F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o: \
F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
================================================
FILE: JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o.d
================================================
F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o: \
F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
================================================
FILE: JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o.d
================================================
F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o: \
F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
================================================
FILE: JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o.d
================================================
F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o: \
F:/Apps/jniDemo/JNIDemo/app/src/main/jni/hello-jni.c
================================================
FILE: JNIDemo/app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.lb6905.jnidemo.MainActivity">
<TextView
android:id="@+id/tv_jni"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
================================================
FILE: JNIDemo/app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: JNIDemo/app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">JNIDemo</string>
</resources>
================================================
FILE: JNIDemo/app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: JNIDemo/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: JNIDemo/gradle/wrapper/gradle-wrapper.properties
================================================
#Wed Jun 21 09:31:24 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
================================================
FILE: JNIDemo/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
android.useDeprecatedNDK=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: JNIDemo/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: JNIDemo/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: JNIDemo/settings.gradle
================================================
include ':app'
================================================
FILE: OpenGLES/.gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
================================================
FILE: OpenGLES/app/.gitignore
================================================
/build
================================================
FILE: OpenGLES/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.lb377463323.opengles"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
}
================================================
FILE: OpenGLES/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\ProgramFiles\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: OpenGLES/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lb377463323.opengles">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".GLActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: OpenGLES/app/src/main/java/com/lb377463323/opengles/GLActivity.java
================================================
package com.lb377463323.opengles;
import android.content.pm.ActivityInfo;
import android.opengl.GLSurfaceView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class GLActivity extends AppCompatActivity {
private GLSurfaceView mGLSurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mGLSurfaceView = new GLSurfaceView(this);
mGLSurfaceView.setEGLContextClientVersion(2);
mGLSurfaceView.setRenderer(new GLRenderer());
setContentView(mGLSurfaceView);
}
}
================================================
FILE: OpenGLES/app/src/main/java/com/lb377463323/opengles/GLRenderer.java
================================================
package com.lb377463323.opengles;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
/**
* Created by lb6905 on 2017/6/30.
*/
public class GLRenderer implements GLSurfaceView.Renderer {
private Triangle mTriangle;
private float[] mMVPMatrix = new float[16];
private float[] mProjectMatrix = new float[16];
private float[] mViewMatrix = new float[16];
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
GLES20.glClearColor(0, 0, 0, 1);
mTriangle = new Triangle();
//设置相机位置
Matrix.setLookAtM(mViewMatrix, 0, 0, 0, 3.0f, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
GLES20.glViewport(0, 0, width, height);
//计算宽高比
float ratio = (float) height / width;
//设置透视投影
Matrix.frustumM(mProjectMatrix, 0, -1, 1, -ratio, ratio, 3, 7);
//计算变换矩阵
Matrix.multiplyMM(mMVPMatrix, 0, mProjectMatrix, 0, mViewMatrix, 0);
}
@Override
public void onDrawFrame(GL10 gl) {
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
mTriangle.draw(mMVPMatrix);
}
}
================================================
FILE: OpenGLES/app/src/main/java/com/lb377463323/opengles/Triangle.java
================================================
package com.lb377463323.opengles;
import android.opengl.GLES20;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import static android.opengl.GLES20.GL_FLOAT;
/**
* Created by lb6905 on 2017/6/30.
*/
public class Triangle {
private FloatBuffer vertexBuffer;
static final int COORDS_PER_VERTEX = 3;
private final int mProgram;
private int mPositionHandle;
private int mColorHandle;
private int mMVPMatrixHandle;
private final int vertexCount = triangleCoords.length;
private final int vertexStride = COORDS_PER_VERTEX * 4;
/*private final String vertexShaderCode =
"attribute vec4 vPosition;" +
"void main() {" +
" gl_Position = vPosition;" +
"}";*/
private final String vertexShaderCode =
"uniform mat4 uMVPMatrix;" +
"attribute vec4 vPosition;" +
"void main() {" +
" gl_Position = uMVPMatrix * vPosition;" +
"}";
private final String fragmentShaderCode =
"precision mediump float;"
+ "uniform vec4 vColor;"
+ "void main() {"
+ " gl_FragColor = vColor;"
+ "}";
static float[] triangleCoords = {
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f
};
float[] color = {0.0f, 1f, 0f, 1.0f};
public Triangle() {
ByteBuffer bb = ByteBuffer.allocateDirect(triangleCoords.length * 4);
bb.order(ByteOrder.nativeOrder());
vertexBuffer = bb.asFloatBuffer();
vertexBuffer.put(triangleCoords);
vertexBuffer.position(0);
int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);
mProgram = GLES20.glCreateProgram();
GLES20.glAttachShader(mProgram, vertexShader);
GLES20.glAttachShader(mProgram, fragmentShader);
GLES20.glLinkProgram(mProgram);
}
public void draw(float[] mvpMatrix) {
GLES20.glUseProgram(mProgram);
mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
GLES20.glEnableVertexAttribArray(mPositionHandle);
GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX,
GL_FLOAT, false, vertexStride, vertexBuffer);
mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");//此方法名若写错,则绘制出来的图形颜色全是默认黑色
GLES20.glUniform4fv(mColorHandle, 1, color, 0);
mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
GLES20.glDisableVertexAttribArray(mPositionHandle);
}
public static int loadShader(int type, String shaderCode) {
int shader = GLES20.glCreateShader(type);
GLES20.glShaderSource(shader, shaderCode);
GLES20.glCompileShader(shader);
return shader;
}
}
================================================
FILE: OpenGLES/app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: OpenGLES/app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">OpenGLES</string>
</resources>
================================================
FILE: OpenGLES/app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: OpenGLES/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: OpenGLES/gradle/wrapper/gradle-wrapper.properties
================================================
#Mon Jul 17 15:58:28 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
================================================
FILE: OpenGLES/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: OpenGLES/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: OpenGLES/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: OpenGLES/settings.gradle
================================================
include ':app'
================================================
FILE: README.md
================================================
# GraphicsTestBed
此项目为学习Android Graphics时写的各种Demo,根据目录排放如下,后面整理好会添加一些滤镜处理和OpenGLES进阶Demo。也欢迎大家有合适的Graphic Demo提交进来,最好带有博客讲解。
- Camera
- CameraV1: 根据Camera第一版API写的
- CameraV2: 根据Camera第二版API写的([Android Camera2教程之打开相机、开启预览、实现PreviewCallback、拍照](http://blog.csdn.net/lb377463323/article/details/52740411))
- JNIDemo
- [Android JNI开发流程](http://blog.csdn.net/lb377463323/article/details/75112049)
- [Android JNI反射调用Java构造方法、成员方法和静态方法](http://blog.csdn.net/lb377463323/article/details/75303125)
- OpenGLES
- [OpenGL ES2.0入门之Android篇(一)——绘制三角形](http://blog.csdn.net/lb377463323/article/details/52136518)
- Filter(此代码包含三个包如下:有三个对应的Activity,在AndroidManifest中取消注释即可运行)
- CameraV1GLSurfaceView:对应博客为 - [Android Camera使用OpenGL ES 2.0和GLSurfaceView对预览进行实时处理(黑白滤镜)](http://blog.csdn.net/lb377463323/article/details/77071054)
- CameraV1TextureView:对应博客为 - [Android Camera使用OpenGL ES 2.0和TextureView对预览进行实时处理(黑白滤镜)](http://blog.csdn.net/lb377463323/article/details/77096652)
- CameraV2GLSurfaceView:对应博客为 - [Android Camera2使用OpenGL ES 2.0和GLSurfaceView对预览进行实时处理(黑白滤镜)](http://blog.csdn.net/lb377463323/article/details/78054892)
gitextract_k952_mcx/ ├── Camera/ │ ├── CameraV1/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── app/ │ │ │ ├── .gitignore │ │ │ ├── build.gradle │ │ │ ├── proguard-rules.pro │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── AndroidManifest.xml │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── lb377463323/ │ │ │ │ └── camera1/ │ │ │ │ └── MainActivity.java │ │ │ └── res/ │ │ │ ├── layout/ │ │ │ │ └── activity_main.xml │ │ │ ├── values/ │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── ids.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── values-w820dp/ │ │ │ └── dimens.xml │ │ ├── build.gradle │ │ ├── gradle/ │ │ │ └── wrapper/ │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ │ ├── gradle.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ └── CameraV2/ │ ├── .gitignore │ ├── app/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ └── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── lb377463323/ │ │ │ └── camera2/ │ │ │ └── MainActivity.java │ │ └── res/ │ │ ├── layout/ │ │ │ ├── activity_main.xml │ │ │ └── gallery_imageview.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── Filter/ │ ├── .gitignore │ ├── .idea/ │ │ ├── gradle.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── runConfigurations.xml │ ├── app/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ └── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── liubing/ │ │ │ └── filtertestbed/ │ │ │ ├── CameraV1.java │ │ │ ├── CameraV1GLSurfaceView/ │ │ │ │ ├── CameraV1GLSurfaceView.java │ │ │ │ ├── CameraV1GLSurfaceViewActivity.java │ │ │ │ └── CameraV1Renderer.java │ │ │ ├── CameraV1TextureView/ │ │ │ │ ├── CameraV1GLRenderer.java │ │ │ │ └── CameraV1TextureViewActivity.java │ │ │ ├── CameraV2.java │ │ │ ├── CameraV2GLSurfaceView/ │ │ │ │ ├── CameraV2GLSurfaceView.java │ │ │ │ ├── CameraV2GLSurfaceViewActivity.java │ │ │ │ └── CameraV2Renderer.java │ │ │ ├── FilterEngine.java │ │ │ └── Utils.java │ │ └── res/ │ │ ├── raw/ │ │ │ ├── base_fragment_shader.glsl │ │ │ └── base_vertex_shader.glsl │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── JNIDemo/ │ ├── .gitignore │ ├── app/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ └── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── lb6905/ │ │ │ └── jnidemo/ │ │ │ ├── MainActivity.java │ │ │ └── TestClass.java │ │ ├── jni/ │ │ │ ├── Android.mk │ │ │ └── hello-jni.c │ │ ├── obj/ │ │ │ └── local/ │ │ │ ├── arm64-v8a/ │ │ │ │ └── objs/ │ │ │ │ └── hello-jni/ │ │ │ │ ├── hello-jni.o │ │ │ │ └── hello-jni.o.d │ │ │ ├── armeabi/ │ │ │ │ └── objs/ │ │ │ │ └── hello-jni/ │ │ │ │ ├── hello-jni.o │ │ │ │ └── hello-jni.o.d │ │ │ ├── armeabi-v7a/ │ │ │ │ └── objs/ │ │ │ │ └── hello-jni/ │ │ │ │ ├── hello-jni.o │ │ │ │ └── hello-jni.o.d │ │ │ ├── mips/ │ │ │ │ └── objs/ │ │ │ │ └── hello-jni/ │ │ │ │ ├── hello-jni.o │ │ │ │ └── hello-jni.o.d │ │ │ ├── mips64/ │ │ │ │ └── objs/ │ │ │ │ └── hello-jni/ │ │ │ │ ├── hello-jni.o │ │ │ │ └── hello-jni.o.d │ │ │ ├── x86/ │ │ │ │ └── objs/ │ │ │ │ └── hello-jni/ │ │ │ │ ├── hello-jni.o │ │ │ │ └── hello-jni.o.d │ │ │ └── x86_64/ │ │ │ └── objs/ │ │ │ └── hello-jni/ │ │ │ ├── hello-jni.o │ │ │ └── hello-jni.o.d │ │ └── res/ │ │ ├── layout/ │ │ │ └── activity_main.xml │ │ └── values/ │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── OpenGLES/ │ ├── .gitignore │ ├── app/ │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src/ │ │ └── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── lb377463323/ │ │ │ └── opengles/ │ │ │ ├── GLActivity.java │ │ │ ├── GLRenderer.java │ │ │ └── Triangle.java │ │ └── res/ │ │ └── values/ │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle └── README.md
SYMBOL INDEX (168 symbols across 20 files)
FILE: Camera/CameraV1/app/src/main/java/com/lb377463323/camera1/MainActivity.java
class MainActivity (line 37) | public class MainActivity extends AppCompatActivity implements TextureVi...
method onCreate (line 60) | @Override
method onResume (line 81) | @Override
method checkCameraHardware (line 91) | private boolean checkCameraHardware(Context context){
method setPreviewTexture (line 99) | private void setPreviewTexture(SurfaceTexture surfaceTexture) {
method onSurfaceTextureAvailable (line 109) | @Override
method onSurfaceTextureSizeChanged (line 117) | @Override
method onSurfaceTextureDestroyed (line 122) | @Override
method onSurfaceTextureUpdated (line 127) | @Override
method onClick (line 132) | @Override
method takePicture (line 149) | public void takePicture(){
method switchCamera (line 155) | public void switchCamera(){
method onError (line 183) | @Override
method onPictureTaken (line 193) | @Override
method writeFile (line 206) | public void writeFile(String path, byte[] data) {
method saveBmp2SD (line 227) | private void saveBmp2SD(String path, Bitmap bitmap){
method setDisplayOrientation (line 250) | private void setDisplayOrientation(int degree){
method requestCamera (line 257) | private void requestCamera(int mCameraId) {
method openCamera (line 261) | private void openCamera(int cameraId){
method startPreview (line 272) | private void startPreview(){
method stopPreview (line 280) | private void stopPreview() {
method closeCamera (line 287) | private void closeCamera() {
method onPause (line 296) | @Override
method initSizeList (line 303) | private void initSizeList() {
method initParameters (line 309) | private void initParameters() {
method initPopupWindow (line 323) | private void initPopupWindow() {
method initPicturePopupWindow (line 327) | private void initPicturePopupWindow() {
method showPopupWindow (line 338) | private void showPopupWindow(PopupWindow popupWindow, View view) {
class MyAdapter (line 350) | class MyAdapter extends BaseAdapter {
method MyAdapter (line 353) | public MyAdapter(List<String> list) {
method getCount (line 357) | @Override
method getItem (line 362) | @Override
method getItemId (line 367) | @Override
method getView (line 372) | @Override
method getParameters (line 382) | private Camera.Parameters getParameters() {
method setParameters (line 389) | private void setParameters() {
method getSupportedPreviewSizes (line 395) | private List<Camera.Size> getSupportedPreviewSizes(Camera.Parameters p...
method getSupportedPictureSizes (line 417) | private List<Camera.Size> getSupportedPictureSizes(Camera.Parameters p...
method onItemClick (line 438) | @Override
method setPreviewSize (line 452) | private void setPreviewSize(float rate) {
method setCaptureSize (line 466) | private void setCaptureSize(int captureWidth, int captureHeight) {
method equalsRate (line 476) | private boolean equalsRate(Camera.Size size, float rate){
FILE: Camera/CameraV2/app/src/main/java/com/lb377463323/camera2/MainActivity.java
class MainActivity (line 47) | public class MainActivity extends Activity {
method onCreate (line 69) | @Override
method onResume (line 81) | @Override
method startCameraThread (line 92) | private void startCameraThread() {
method onSurfaceTextureAvailable (line 99) | @Override
method onSurfaceTextureSizeChanged (line 106) | @Override
method onSurfaceTextureDestroyed (line 111) | @Override
method onSurfaceTextureUpdated (line 116) | @Override
method setupCamera (line 122) | private void setupCamera(int width, int height) {
method getOptimalSize (line 156) | private Size getOptimalSize(Size[] sizeMap, int width, int height) {
method openCamera (line 181) | private void openCamera() {
method onOpened (line 194) | @Override
method onDisconnected (line 200) | @Override
method onError (line 206) | @Override
method startPreview (line 213) | private void startPreview() {
method takePicture (line 242) | public void takePicture(View view) {
method lockFocus (line 246) | private void lockFocus() {
method onCaptureProgressed (line 256) | @Override
method onCaptureCompleted (line 260) | @Override
method capture (line 266) | private void capture() {
method unLockFocus (line 286) | private void unLockFocus() {
method onPause (line 296) | @Override
method setupImageReader (line 315) | private void setupImageReader() {
class imageSaver (line 327) | public static class imageSaver implements Runnable {
method imageSaver (line 331) | public imageSaver(Image image) {
method run (line 335) | @Override
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1.java
class CameraV1 (line 15) | public class CameraV1 {
method CameraV1 (line 20) | public CameraV1(Activity activity) {
method openCamera (line 24) | public boolean openCamera(int screenWidth, int screenHeight, int camer...
method setCameraDisplayOrientation (line 42) | public static void setCameraDisplayOrientation(Activity activity,
method startPreview (line 67) | public void startPreview() {
method stopPreview (line 73) | public void stopPreview() {
method setPreviewTexture (line 79) | public void setPreviewTexture(SurfaceTexture surfaceTexture) {
method releaseCamera (line 89) | public void releaseCamera() {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceView.java
class CameraV1GLSurfaceView (line 12) | public class CameraV1GLSurfaceView extends GLSurfaceView {
method CameraV1GLSurfaceView (line 17) | public CameraV1GLSurfaceView(Context context) {
method init (line 21) | public void init(CameraV1 camera, boolean isPreviewStarted, Context co...
method deinit (line 28) | public void deinit() {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceViewActivity.java
class CameraV1GLSurfaceViewActivity (line 13) | public class CameraV1GLSurfaceViewActivity extends Activity {
method onCreate (line 18) | @Override
method onPause (line 37) | @Override
method onDestroy (line 53) | @Override
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1Renderer.java
class CameraV1Renderer (line 41) | public class CameraV1Renderer implements GLSurfaceView.Renderer {
method init (line 60) | public void init(CameraV1GLSurfaceView glSurfaceView, CameraV1 camera,...
method onSurfaceCreated (line 67) | @Override
method onSurfaceChanged (line 78) | @Override
method onDrawFrame (line 83) | @Override
method initSurfaceTexture (line 130) | public boolean initSurfaceTexture() {
method deinit (line 147) | public void deinit() {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1GLRenderer.java
class CameraV1GLRenderer (line 27) | public class CameraV1GLRenderer implements SurfaceTexture.OnFrameAvailab...
method init (line 50) | public void init(TextureView textureView, int oesTextureId, Context co...
method initEGL (line 76) | private void initEGL() {
method drawFrame (line 137) | private void drawFrame() {
method onFrameAvailable (line 154) | @Override
method initOESTexture (line 161) | public SurfaceTexture initOESTexture() {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1TextureViewActivity.java
class CameraV1TextureViewActivity (line 21) | public class CameraV1TextureViewActivity extends Activity {
method onCreate (line 30) | @Override
method onSurfaceTextureAvailable (line 48) | @Override
method onSurfaceTextureSizeChanged (line 65) | @Override
method onSurfaceTextureDestroyed (line 69) | @Override
method onSurfaceTextureUpdated (line 79) | @Override
method onPause (line 84) | @Override
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2.java
class CameraV2 (line 33) | public class CameraV2 {
method CameraV2 (line 48) | public CameraV2(Activity activity) {
method setupCamera (line 53) | public String setupCamera(int width, int height) {
method startCameraThread (line 72) | public void startCameraThread() {
method openCamera (line 78) | public boolean openCamera() {
method onOpened (line 93) | @Override
method onDisconnected (line 98) | @Override
method onError (line 104) | @Override
method getOptimalSize (line 111) | private Size getOptimalSize(Size[] sizeMap, int width, int height) {
method setPreviewTexture (line 135) | public void setPreviewTexture(SurfaceTexture surfaceTexture) {
method startPreview (line 139) | public void startPreview() {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceView.java
class CameraV2GLSurfaceView (line 13) | public class CameraV2GLSurfaceView extends GLSurfaceView {
method init (line 17) | public void init(CameraV2 camera, boolean isPreviewStarted, Context co...
method CameraV2GLSurfaceView (line 26) | public CameraV2GLSurfaceView(Context context) {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceViewActivity.java
class CameraV2GLSurfaceViewActivity (line 14) | public class CameraV2GLSurfaceViewActivity extends Activity {
method onCreate (line 18) | @Override
method onResume (line 34) | @Override
method onDestroy (line 39) | @Override
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2Renderer.java
class CameraV2Renderer (line 40) | public class CameraV2Renderer implements GLSurfaceView.Renderer {
method init (line 59) | public void init(CameraV2GLSurfaceView surfaceView, CameraV2 camera, b...
method onSurfaceCreated (line 66) | @Override
method onSurfaceChanged (line 77) | @Override
method onDrawFrame (line 83) | @Override
method initSurfaceTexture (line 130) | public boolean initSurfaceTexture() {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/FilterEngine.java
class FilterEngine (line 37) | public class FilterEngine {
method FilterEngine (line 54) | public FilterEngine(int OESTextureId, Context context) {
method createBuffer (line 87) | public FloatBuffer createBuffer(float[] vertexData) {
method loadShader (line 95) | public int loadShader(int type, String shaderSource) {
method linkProgram (line 105) | public int linkProgram(int verShader, int fragShader) {
method drawTexture (line 118) | public void drawTexture(float[] transformMatrix) {
method getShaderProgram (line 142) | public int getShaderProgram() {
method getBuffer (line 146) | public FloatBuffer getBuffer() {
method getOESTextureId (line 150) | public int getOESTextureId() {
method setOESTextureId (line 154) | public void setOESTextureId(int OESTextureId) {
FILE: Filter/app/src/main/java/com/liubing/filtertestbed/Utils.java
class Utils (line 18) | public class Utils {
method createOESTextureObject (line 20) | public static int createOESTextureObject() {
method readShaderFromResource (line 36) | public static String readShaderFromResource(Context context, int resou...
FILE: JNIDemo/app/src/main/java/com/lb6905/jnidemo/MainActivity.java
class MainActivity (line 7) | public class MainActivity extends AppCompatActivity {
method onCreate (line 10) | @Override
method stringFromJNI (line 20) | public native String stringFromJNI();
method setArray (line 21) | public native void setArray(int[] array);
method getArray (line 22) | public native int[] getArray();
method JNIReflect (line 23) | public native void JNIReflect();
FILE: JNIDemo/app/src/main/java/com/lb6905/jnidemo/TestClass.java
class TestClass (line 9) | public class TestClass {
method TestClass (line 12) | public TestClass(){
method test (line 16) | public void test(int index) {
method testStatic (line 20) | public static void testStatic(String str) {
class InnerClass (line 24) | public static class InnerClass {
method InnerClass (line 26) | public InnerClass() {
method setInt (line 30) | public void setInt(int n) {
FILE: JNIDemo/app/src/main/jni/hello-jni.c
function jstring (line 12) | jstring
function JNICALL (line 24) | JNICALL Java_com_lb6905_jnidemo_MainActivity_setArray
function JNICALL (line 35) | JNICALL Java_com_lb6905_jnidemo_MainActivity_getArray
function JNICALL (line 43) | JNICALL Java_com_lb6905_jnidemo_MainActivity_JNIReflect
FILE: OpenGLES/app/src/main/java/com/lb377463323/opengles/GLActivity.java
class GLActivity (line 10) | public class GLActivity extends AppCompatActivity {
method onCreate (line 13) | @Override
FILE: OpenGLES/app/src/main/java/com/lb377463323/opengles/GLRenderer.java
class GLRenderer (line 14) | public class GLRenderer implements GLSurfaceView.Renderer {
method onSurfaceCreated (line 20) | @Override
method onSurfaceChanged (line 29) | @Override
method onDrawFrame (line 41) | @Override
FILE: OpenGLES/app/src/main/java/com/lb377463323/opengles/Triangle.java
class Triangle (line 15) | public class Triangle {
method Triangle (line 57) | public Triangle() {
method draw (line 75) | public void draw(float[] mvpMatrix) {
method loadShader (line 96) | public static int loadShader(int type, String shaderCode) {
Condensed preview — 129 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (171K chars).
[
{
"path": "Camera/CameraV1/.gitignore",
"chars": 118,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n"
},
{
"path": "Camera/CameraV1/README.md",
"chars": 76,
"preview": "This is a CameraV1 Demo,it has preview、switch camera、take picture function.\n"
},
{
"path": "Camera/CameraV1/app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "Camera/CameraV1/app/build.gradle",
"chars": 671,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 25\n buildToolsVersion \"25.0.2\"\n defaultCo"
},
{
"path": "Camera/CameraV1/app/proguard-rules.pro",
"chars": 656,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /h"
},
{
"path": "Camera/CameraV1/app/src/main/AndroidManifest.xml",
"chars": 977,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n pa"
},
{
"path": "Camera/CameraV1/app/src/main/java/com/lb377463323/camera1/MainActivity.java",
"chars": 16507,
"preview": "package com.lb377463323.camera1;\n\nimport android.content.Context;\nimport android.content.pm.PackageManager;\nimport andro"
},
{
"path": "Camera/CameraV1/app/src/main/res/layout/activity_main.xml",
"chars": 1450,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "Camera/CameraV1/app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "Camera/CameraV1/app/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "Camera/CameraV1/app/src/main/res/values/ids.xml",
"chars": 108,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <item name=\"pictureId\" type=\"id\"></item>\n</resources>"
},
{
"path": "Camera/CameraV1/app/src/main/res/values/strings.xml",
"chars": 71,
"preview": "<resources>\n <string name=\"app_name\">CameraV1</string>\n</resources>\n"
},
{
"path": "Camera/CameraV1/app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "Camera/CameraV1/app/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "Camera/CameraV1/build.gradle",
"chars": 498,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "Camera/CameraV1/gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Wed Oct 21 11:34:03 PDT 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "Camera/CameraV1/gradle.properties",
"chars": 730,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "Camera/CameraV1/gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "Camera/CameraV1/gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "Camera/CameraV1/settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
},
{
"path": "Camera/CameraV2/.gitignore",
"chars": 97,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n"
},
{
"path": "Camera/CameraV2/app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "Camera/CameraV2/app/build.gradle",
"chars": 646,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 25\n buildToolsVersion \"25.0.2\"\n\n defaultC"
},
{
"path": "Camera/CameraV2/app/proguard-rules.pro",
"chars": 644,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "Camera/CameraV2/app/src/main/AndroidManifest.xml",
"chars": 981,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest package=\"com.lb377463323.camera2\"\n xmlns:android=\"http://schem"
},
{
"path": "Camera/CameraV2/app/src/main/java/com/lb377463323/camera2/MainActivity.java",
"chars": 13532,
"preview": "package com.lb377463323.camera2;\n\nimport android.Manifest;\nimport android.app.Activity;\nimport android.content.Context;\n"
},
{
"path": "Camera/CameraV2/app/src/main/res/layout/activity_main.xml",
"chars": 867,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "Camera/CameraV2/app/src/main/res/layout/gallery_imageview.xml",
"chars": 469,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "Camera/CameraV2/app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "Camera/CameraV2/app/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "Camera/CameraV2/app/src/main/res/values/strings.xml",
"chars": 71,
"preview": "<resources>\n <string name=\"app_name\">CameraV2</string>\n</resources>\n"
},
{
"path": "Camera/CameraV2/app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "Camera/CameraV2/app/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "Camera/CameraV2/build.gradle",
"chars": 498,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "Camera/CameraV2/gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Wed Oct 21 11:34:03 PDT 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "Camera/CameraV2/gradle.properties",
"chars": 855,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "Camera/CameraV2/gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "Camera/CameraV2/gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "Camera/CameraV2/settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
},
{
"path": "Filter/.gitignore",
"chars": 97,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n"
},
{
"path": "Filter/.idea/gradle.xml",
"chars": 626,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"GradleSettings\">\n <option name=\"linke"
},
{
"path": "Filter/.idea/misc.xml",
"chars": 1611,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"NullableNotNullManager\">\n <option nam"
},
{
"path": "Filter/.idea/modules.xml",
"chars": 349,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"ProjectModuleManager\">\n <modules>\n "
},
{
"path": "Filter/.idea/runConfigurations.xml",
"chars": 564,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"RunConfigurationProducerService\">\n <o"
},
{
"path": "Filter/app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "Filter/app/build.gradle",
"chars": 591,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 25\n buildToolsVersion \"25.0.2\"\n\n defaultC"
},
{
"path": "Filter/app/proguard-rules.pro",
"chars": 644,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "Filter/app/src/main/AndroidManifest.xml",
"chars": 2004,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest package=\"com.liubing.filtertestbed\"\n xmlns:android=\"http://sch"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1.java",
"chars": 2954,
"preview": "package com.liubing.filtertestbed;\n\nimport android.app.Activity;\nimport android.graphics.SurfaceTexture;\nimport android."
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceView.java",
"chars": 870,
"preview": "package com.liubing.filtertestbed.CameraV1GLSurfaceView;\n\nimport android.content.Context;\nimport android.opengl.GLSurfac"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1GLSurfaceViewActivity.java",
"chars": 1764,
"preview": "package com.liubing.filtertestbed.CameraV1GLSurfaceView;\n\nimport android.app.Activity;\nimport android.content.pm.Activit"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1GLSurfaceView/CameraV1Renderer.java",
"chars": 6066,
"preview": "package com.liubing.filtertestbed.CameraV1GLSurfaceView;\n\nimport android.content.Context;\nimport android.graphics.Surfac"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1GLRenderer.java",
"chars": 5878,
"preview": "package com.liubing.filtertestbed.CameraV1TextureView;\n\nimport android.content.Context;\nimport android.graphics.SurfaceT"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV1TextureView/CameraV1TextureViewActivity.java",
"chars": 3162,
"preview": "package com.liubing.filtertestbed.CameraV1TextureView;\n\nimport android.app.Activity;\nimport android.content.pm.ActivityI"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2.java",
"chars": 6179,
"preview": "package com.liubing.filtertestbed;\n\nimport android.Manifest;\nimport android.app.Activity;\nimport android.content.Context"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceView.java",
"chars": 816,
"preview": "package com.liubing.filtertestbed.CameraV2GLSurfaceView;\n\nimport android.content.Context;\nimport android.opengl.GLSurfac"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2GLSurfaceViewActivity.java",
"chars": 1210,
"preview": "package com.liubing.filtertestbed.CameraV2GLSurfaceView;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport "
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/CameraV2GLSurfaceView/CameraV2Renderer.java",
"chars": 5752,
"preview": "package com.liubing.filtertestbed.CameraV2GLSurfaceView;\n\nimport android.content.Context;\nimport android.graphics.Surfac"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/FilterEngine.java",
"chars": 5732,
"preview": "package com.liubing.filtertestbed;\n\nimport android.content.Context;\nimport android.opengl.GLES11Ext;\n\nimport java.nio.By"
},
{
"path": "Filter/app/src/main/java/com/liubing/filtertestbed/Utils.java",
"chars": 2319,
"preview": "package com.liubing.filtertestbed;\n\nimport android.content.Context;\nimport android.opengl.GLES11Ext;\nimport android.open"
},
{
"path": "Filter/app/src/main/res/raw/base_fragment_shader.glsl",
"chars": 376,
"preview": "#extension GL_OES_EGL_image_external : require\nprecision mediump float;\nuniform samplerExternalOES uTextureSampler;\nvary"
},
{
"path": "Filter/app/src/main/res/raw/base_vertex_shader.glsl",
"chars": 220,
"preview": "attribute vec4 aPosition;\nuniform mat4 uTextureMatrix;\nattribute vec4 aTextureCoordinate;\nvarying vec2 vTextureCoord;\nvo"
},
{
"path": "Filter/app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "Filter/app/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "Filter/app/src/main/res/values/strings.xml",
"chars": 76,
"preview": "<resources>\n <string name=\"app_name\">FilterTestBed</string>\n</resources>\n"
},
{
"path": "Filter/app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "Filter/app/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "Filter/build.gradle",
"chars": 498,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "Filter/gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Wed Oct 21 11:34:03 PDT 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "Filter/gradle.properties",
"chars": 855,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "Filter/gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "Filter/gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "Filter/settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
},
{
"path": "JNIDemo/.gitignore",
"chars": 118,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n"
},
{
"path": "JNIDemo/app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "JNIDemo/app/build.gradle",
"chars": 1044,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 25\n buildToolsVersion \"25.0.2\"\n defaultCo"
},
{
"path": "JNIDemo/app/proguard-rules.pro",
"chars": 929,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "JNIDemo/app/src/main/AndroidManifest.xml",
"chars": 716,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n pa"
},
{
"path": "JNIDemo/app/src/main/java/com/lb6905/jnidemo/MainActivity.java",
"chars": 774,
"preview": "package com.lb6905.jnidemo;\n\nimport android.support.v7.app.AppCompatActivity;\nimport android.os.Bundle;\nimport android.w"
},
{
"path": "JNIDemo/app/src/main/java/com/lb6905/jnidemo/TestClass.java",
"chars": 682,
"preview": "package com.lb6905.jnidemo;\n\nimport android.util.Log;\n\n/**\n * Created by lb6905 on 2017/7/18.\n */\n\npublic class TestClas"
},
{
"path": "JNIDemo/app/src/main/jni/Android.mk",
"chars": 748,
"preview": "# Copyright (C) 2009 The Android Open Source Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
},
{
"path": "JNIDemo/app/src/main/jni/hello-jni.c",
"chars": 2221,
"preview": "//\n// Created by lb6905 on 2017/6/21.\n//\n#include <jni.h>\n#include <string.h>\n\n#ifndef _Included_com_lb6905_jnidemo_Main"
},
{
"path": "JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o.d",
"chars": 142,
"preview": "F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/arm64-v8a/objs/hello-jni/hello-jni.o: \\\n F:/Apps/jniDemo/JNIDemo/app/src"
},
{
"path": "JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o.d",
"chars": 140,
"preview": "F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/armeabi/objs/hello-jni/hello-jni.o: \\\n F:/Apps/jniDemo/JNIDemo/app/src/m"
},
{
"path": "JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o.d",
"chars": 144,
"preview": "F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o: \\\n F:/Apps/jniDemo/JNIDemo/app/s"
},
{
"path": "JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o.d",
"chars": 137,
"preview": "F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/mips/objs/hello-jni/hello-jni.o: \\\n F:/Apps/jniDemo/JNIDemo/app/src/main"
},
{
"path": "JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o.d",
"chars": 139,
"preview": "F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/mips64/objs/hello-jni/hello-jni.o: \\\n F:/Apps/jniDemo/JNIDemo/app/src/ma"
},
{
"path": "JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o.d",
"chars": 136,
"preview": "F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/x86/objs/hello-jni/hello-jni.o: \\\n F:/Apps/jniDemo/JNIDemo/app/src/main/"
},
{
"path": "JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o.d",
"chars": 139,
"preview": "F:/Apps/jniDemo/JNIDemo/app/src/main/obj/local/x86_64/objs/hello-jni/hello-jni.o: \\\n F:/Apps/jniDemo/JNIDemo/app/src/ma"
},
{
"path": "JNIDemo/app/src/main/res/layout/activity_main.xml",
"chars": 823,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.constraint.ConstraintLayout\n xmlns:android=\"http://schemas.an"
},
{
"path": "JNIDemo/app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "JNIDemo/app/src/main/res/values/strings.xml",
"chars": 70,
"preview": "<resources>\n <string name=\"app_name\">JNIDemo</string>\n</resources>\n"
},
{
"path": "JNIDemo/app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "JNIDemo/build.gradle",
"chars": 498,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "JNIDemo/gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Wed Jun 21 09:31:24 CST 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "JNIDemo/gradle.properties",
"chars": 760,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "JNIDemo/gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "JNIDemo/gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "JNIDemo/settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
},
{
"path": "OpenGLES/.gitignore",
"chars": 118,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n"
},
{
"path": "OpenGLES/app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "OpenGLES/app/build.gradle",
"chars": 589,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 25\n buildToolsVersion \"25.0.2\"\n defaultCo"
},
{
"path": "OpenGLES/app/proguard-rules.pro",
"chars": 929,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "OpenGLES/app/src/main/AndroidManifest.xml",
"chars": 720,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n pa"
},
{
"path": "OpenGLES/app/src/main/java/com/lb377463323/opengles/GLActivity.java",
"chars": 917,
"preview": "package com.lb377463323.opengles;\n\nimport android.content.pm.ActivityInfo;\nimport android.opengl.GLSurfaceView;\nimport a"
},
{
"path": "OpenGLES/app/src/main/java/com/lb377463323/opengles/GLRenderer.java",
"chars": 1310,
"preview": "package com.lb377463323.opengles;\n\nimport android.opengl.GLES20;\nimport android.opengl.GLSurfaceView;\nimport android.ope"
},
{
"path": "OpenGLES/app/src/main/java/com/lb377463323/opengles/Triangle.java",
"chars": 3101,
"preview": "package com.lb377463323.opengles;\n\nimport android.opengl.GLES20;\n\nimport java.nio.ByteBuffer;\nimport java.nio.ByteOrder;"
},
{
"path": "OpenGLES/app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "OpenGLES/app/src/main/res/values/strings.xml",
"chars": 71,
"preview": "<resources>\n <string name=\"app_name\">OpenGLES</string>\n</resources>\n"
},
{
"path": "OpenGLES/app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "OpenGLES/build.gradle",
"chars": 498,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "OpenGLES/gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Mon Jul 17 15:58:28 CST 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "OpenGLES/gradle.properties",
"chars": 730,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "OpenGLES/gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "OpenGLES/gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "OpenGLES/settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
},
{
"path": "README.md",
"chars": 1124,
"preview": "# GraphicsTestBed\n\n此项目为学习Android Graphics时写的各种Demo,根据目录排放如下,后面整理好会添加一些滤镜处理和OpenGLES进阶Demo。也欢迎大家有合适的Graphic Demo提交进来,最好带有"
}
]
// ... and 12 more files (download for full content)
About this extraction
This page contains the full source code of the lb377463323/GraphicsTestBed GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 129 files (150.9 KB), approximately 43.2k tokens, and a symbol index with 168 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.