├── .gitignore ├── README.MD ├── build.gradle ├── common ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── onzhou │ │ └── common │ │ ├── base │ │ ├── AbsBaseActivity.java │ │ ├── AbsGLSurfaceActivity.java │ │ └── BaseApplication.java │ │ ├── core │ │ └── AppCore.java │ │ ├── task │ │ └── AssertReleaseTask.java │ │ └── utils │ │ ├── ResReadUtils.java │ │ ├── ShaderUtils.java │ │ └── TextureUtils.java │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── config.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── 20181123103405458.png ├── 20181123111204640.png ├── 20181124224717420.png └── 20181125125310654.png ├── native-gauss ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ ├── gauss_bitmap.c │ │ └── gauss_bitmap.h │ ├── java │ │ └── com │ │ │ └── onzhou │ │ │ └── graphic │ │ │ ├── GaussBitmap.java │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-xxhdpi │ │ └── input.jpg │ │ ├── layout │ │ └── activity_main.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── onzhou │ └── graphic │ └── ExampleUnitTest.java ├── native-libjpeg-turbo ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── build_scripts │ ├── build_jpeg.sh │ ├── build_jpeg_all.sh │ └── config.sh ├── libs │ ├── arm64-v8a │ │ ├── include │ │ │ ├── jconfig.h │ │ │ ├── jerror.h │ │ │ ├── jmorecfg.h │ │ │ ├── jpeglib.h │ │ │ └── turbojpeg.h │ │ ├── libjpeg.a │ │ ├── libjpeg.so │ │ ├── libturbojpeg.a │ │ └── libturbojpeg.so │ ├── armeabi-v7a │ │ ├── include │ │ │ ├── jconfig.h │ │ │ ├── jerror.h │ │ │ ├── jmorecfg.h │ │ │ ├── jpeglib.h │ │ │ └── turbojpeg.h │ │ ├── libjpeg.a │ │ ├── libjpeg.so │ │ ├── libturbojpeg.a │ │ └── libturbojpeg.so │ ├── armeabi │ │ ├── include │ │ │ ├── jconfig.h │ │ │ ├── jerror.h │ │ │ ├── jmorecfg.h │ │ │ ├── jpeglib.h │ │ │ └── turbojpeg.h │ │ ├── libjpeg.a │ │ ├── libjpeg.so │ │ ├── libturbojpeg.a │ │ └── libturbojpeg.so │ ├── x86 │ │ ├── include │ │ │ ├── jconfig.h │ │ │ ├── jerror.h │ │ │ ├── jmorecfg.h │ │ │ ├── jpeglib.h │ │ │ └── turbojpeg.h │ │ ├── libjpeg.a │ │ ├── libjpeg.so │ │ ├── libturbojpeg.a │ │ └── libturbojpeg.so │ └── x86_64 │ │ ├── include │ │ ├── jconfig.h │ │ ├── jerror.h │ │ ├── jmorecfg.h │ │ ├── jpeglib.h │ │ └── turbojpeg.h │ │ ├── libjpeg.a │ │ ├── libjpeg.so │ │ ├── libturbojpeg.a │ │ └── libturbojpeg.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── onzhou │ │ └── libjpeg │ │ └── turbo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── input.jpeg │ ├── cpp │ │ ├── native_image.cpp │ │ └── native_image.h │ ├── java │ │ └── com │ │ │ └── onzhou │ │ │ └── libjpeg │ │ │ └── turbo │ │ │ ├── loader │ │ │ └── NativeImageLoader.java │ │ │ └── main │ │ │ └── NativeImageActivity.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── onzhou │ └── libjpeg │ └── turbo │ └── ExampleUnitTest.java ├── native-libpng ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── libs │ ├── arm64-v8a │ │ ├── libpng.so │ │ └── libz.so │ ├── armeabi-v7a │ │ ├── libpng.so │ │ └── libz.so │ ├── armeabi │ │ ├── libpng.so │ │ └── libz.so │ ├── mips │ │ ├── libpng.so │ │ └── libz.so │ ├── mips64 │ │ ├── libpng.so │ │ └── libz.so │ ├── x86 │ │ ├── libpng.so │ │ └── libz.so │ └── x86_64 │ │ ├── libpng.so │ │ └── libz.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── onzhou │ │ └── graphic │ │ └── png │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── input.png │ ├── cpp │ │ ├── include_png │ │ │ ├── PngFile.h │ │ │ ├── cexcept.h │ │ │ ├── png.h │ │ │ ├── pngconf.h │ │ │ ├── pngdebug.h │ │ │ ├── pnginfo.h │ │ │ ├── pnglibconf.h │ │ │ ├── pngpriv.h │ │ │ ├── pngstest-errors.h │ │ │ ├── pngstruct.h │ │ │ ├── pngusr.h │ │ │ ├── readpng.h │ │ │ ├── readpng2.h │ │ │ ├── resource.h │ │ │ ├── sRGB.h │ │ │ └── writepng.h │ │ ├── include_zlib │ │ │ ├── blast.h │ │ │ ├── crc32.h │ │ │ ├── crypt.h │ │ │ ├── deflate.h │ │ │ ├── gzguts.h │ │ │ ├── gzlog.h │ │ │ ├── infback9.h │ │ │ ├── inffast.h │ │ │ ├── inffix9.h │ │ │ ├── inffixed.h │ │ │ ├── inflate.h │ │ │ ├── inflate9.h │ │ │ ├── inftree9.h │ │ │ ├── inftrees.h │ │ │ ├── ioapi.h │ │ │ ├── iowin32.h │ │ │ ├── mztools.h │ │ │ ├── puff.h │ │ │ ├── trees.h │ │ │ ├── unzip.h │ │ │ ├── zconf.h │ │ │ ├── zfstream.h │ │ │ ├── zip.h │ │ │ ├── zlib.h │ │ │ ├── zstream.h │ │ │ └── zutil.h │ │ ├── native_png.cpp │ │ └── native_png.h │ ├── java │ │ └── com │ │ │ └── onzhou │ │ │ └── graphic │ │ │ ├── main │ │ │ └── NativePngActivity.java │ │ │ └── png │ │ │ └── NativePngLoader.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── onzhou │ └── graphic │ └── png │ └── ExampleUnitTest.java ├── native-libyuv ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── libs │ ├── arm64-v8a │ │ └── libyuv.so │ ├── armeabi-v7a │ │ └── libyuv.so │ ├── armeabi │ │ └── libyuv.so │ ├── x86 │ │ └── libyuv.so │ └── x86_64 │ │ └── libyuv.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── onzhou │ │ └── graphic │ │ └── libyuv │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── nv12.yuv │ │ ├── nv21.yuv │ │ └── yuv420p.yuv │ ├── cpp │ │ ├── include │ │ │ ├── libyuv.h │ │ │ └── libyuv │ │ │ │ ├── basic_types.h │ │ │ │ ├── compare.h │ │ │ │ ├── compare_row.h │ │ │ │ ├── convert.h │ │ │ │ ├── convert_argb.h │ │ │ │ ├── convert_from.h │ │ │ │ ├── convert_from_argb.h │ │ │ │ ├── cpu_id.h │ │ │ │ ├── macros_msa.h │ │ │ │ ├── mjpeg_decoder.h │ │ │ │ ├── planar_functions.h │ │ │ │ ├── rotate.h │ │ │ │ ├── rotate_argb.h │ │ │ │ ├── rotate_row.h │ │ │ │ ├── row.h │ │ │ │ ├── scale.h │ │ │ │ ├── scale_argb.h │ │ │ │ ├── scale_row.h │ │ │ │ ├── version.h │ │ │ │ └── video_common.h │ │ ├── native_yuv.cpp │ │ └── native_yuv.h │ ├── java │ │ └── com │ │ │ └── onzhou │ │ │ └── graphic │ │ │ ├── libyuv │ │ │ └── NativeYUV.java │ │ │ └── main │ │ │ └── NativeYUVActivity.java │ └── res │ │ ├── layout │ │ └── activity_native_yuv.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── onzhou │ └── graphic │ └── libyuv │ └── ExampleUnitTest.java ├── native-yuv2image ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── libs │ └── armeabi-v7a │ │ ├── include │ │ ├── jconfig.h │ │ ├── jerror.h │ │ ├── jmorecfg.h │ │ ├── jpeglib.h │ │ └── turbojpeg.h │ │ ├── libjpeg.so │ │ ├── libpng.so │ │ ├── libturbojpeg.so │ │ └── libz.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── onzhou │ │ └── graphic │ │ └── yuv2image │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── input.yuv │ ├── cpp │ │ ├── include_png │ │ │ ├── PngFile.h │ │ │ ├── cexcept.h │ │ │ ├── png.h │ │ │ ├── pngconf.h │ │ │ ├── pngdebug.h │ │ │ ├── pnginfo.h │ │ │ ├── pnglibconf.h │ │ │ ├── pngpriv.h │ │ │ ├── pngstest-errors.h │ │ │ ├── pngstruct.h │ │ │ ├── pngusr.h │ │ │ ├── readpng.h │ │ │ ├── readpng2.h │ │ │ ├── resource.h │ │ │ ├── sRGB.h │ │ │ └── writepng.h │ │ ├── include_zlib │ │ │ ├── blast.h │ │ │ ├── crc32.h │ │ │ ├── crypt.h │ │ │ ├── deflate.h │ │ │ ├── gzguts.h │ │ │ ├── gzlog.h │ │ │ ├── infback9.h │ │ │ ├── inffast.h │ │ │ ├── inffix9.h │ │ │ ├── inffixed.h │ │ │ ├── inflate.h │ │ │ ├── inflate9.h │ │ │ ├── inftree9.h │ │ │ ├── inftrees.h │ │ │ ├── ioapi.h │ │ │ ├── iowin32.h │ │ │ ├── mztools.h │ │ │ ├── puff.h │ │ │ ├── trees.h │ │ │ ├── unzip.h │ │ │ ├── zconf.h │ │ │ ├── zfstream.h │ │ │ ├── zip.h │ │ │ ├── zlib.h │ │ │ ├── zstream.h │ │ │ └── zutil.h │ │ ├── native_yuv2image.cpp │ │ ├── native_yuv2image.h │ │ ├── native_yuv2jpeg.cpp │ │ ├── native_yuv2jpeg.h │ │ ├── native_yuv2png.cpp │ │ ├── native_yuv2png.h │ │ ├── native_yuvutils.cpp │ │ └── native_yuvutils.h │ ├── java │ │ └── com │ │ │ └── onzhou │ │ │ └── graphic │ │ │ ├── main │ │ │ └── NativeGraphicActivity.java │ │ │ └── yuv2image │ │ │ └── NativeYUV2IMAGE.java │ └── res │ │ ├── layout │ │ └── activity_native_yuv2image.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── onzhou │ └── graphic │ └── yuv2image │ └── ExampleUnitTest.java ├── native-yuv2rgb ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── onzhou │ │ └── graphic │ │ └── yuv2rgb │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── nv12.yuv │ │ ├── nv21.yuv │ │ └── yuv420p.yuv │ ├── cpp │ │ ├── native_yuv2rgb.cpp │ │ └── native_yuv2rgb.h │ ├── java │ │ └── com │ │ │ └── onzhou │ │ │ └── graphic │ │ │ ├── main │ │ │ └── NativeYUV2RGBActivity.java │ │ │ └── yuv2rgb │ │ │ └── NativeYUV2RGB.java │ └── res │ │ ├── layout │ │ └── activity_native_yuv2rgb.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── onzhou │ └── graphic │ └── yuv2rgb │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | ### Android Studio Eclipse template 2 | .gradle 3 | .idea 4 | .settings 5 | bin 6 | build 7 | gen 8 | .classpath 9 | .project 10 | local.properties 11 | *.iml 12 | obj 13 | .externalNativeBuild -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | 2 | ## 图形图像操作实践 3 | 4 | 主要是在`native层`对各种图片格式进行转换,记录一下 5 | 6 | ## native-gauss 7 | 8 | 高斯模糊的开源算法很多,这个模块主要在`native`层对`bitmap`进行高斯模糊操作 9 | 10 | ## native-libjpeg-turbo 11 | 12 | 移植了`libjpeg-turbo`库到`android平台`,在`native`层加载`jpeg`图片,进行渲染 13 | 14 | ![](https://github.com/byhook/graphic4android/blob/master/images/20181123103405458.png) 15 | 16 | [原文地址](https://blog.csdn.net/byhook/article/details/84324847) 17 | 18 | ## native-libpng 19 | 20 | 移植了`libpng库`到`android平台`,在`native`层加载`png`图片,进行渲染 21 | 22 | ![](https://github.com/byhook/graphic4android/blob/master/images/20181123111204640.png) 23 | 24 | [原文地址](https://blog.csdn.net/byhook/article/details/84345512) 25 | 26 | ## native-yuv 27 | 28 | `libyuv`是`google`开源的一个处理`yuv格式数据的库`,移植到`android平台`也比较简单 29 | 30 | [原文地址](https://blog.csdn.net/byhook/article/details/84475525) 31 | 32 | ## native-yuv2image 33 | 34 | 主要用来实现`yuv格式转换为图片格式` 35 | 36 | ![](https://github.com/byhook/graphic4android/blob/master/images/20181124224717420.png) 37 | 38 | [原文地址](https://blog.csdn.net/byhook/article/details/84303640) 39 | 40 | ## native-yuv2rgb 41 | 42 | 主要用来实现`yuv` 43 | 44 | ![](https://github.com/byhook/graphic4android/blob/master/images/20181125125310654.png) 45 | 46 | [原文地址](https://blog.csdn.net/byhook/article/details/84303640) 47 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | apply from: "config.gradle" 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:2.3.3' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /common/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /common/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | //构建版本 5 | compileSdkVersion rootProject.ext.android.compileSdkVersion 6 | buildToolsVersion rootProject.ext.android.buildToolsVersion 7 | //默认的配置 8 | defaultConfig { 9 | minSdkVersion rootProject.ext.android.minSdkVersion 10 | targetSdkVersion rootProject.ext.android.targetSdkVersion 11 | 12 | versionCode rootProject.ext.android.versionCode 13 | versionName rootProject.ext.android.versionName 14 | 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | testCompile 'junit:junit:4.12' 28 | compile rootProject.ext.dependencies["appcompat-v7"] 29 | compile rootProject.ext.dependencies["design"] 30 | } 31 | -------------------------------------------------------------------------------- /common/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /common/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/base/AbsBaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.base; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | 5 | /** 6 | * @anchor: andy 7 | * @date: 2018-11-02 8 | * @description: 9 | */ 10 | public abstract class AbsBaseActivity extends AppCompatActivity { 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/base/AbsGLSurfaceActivity.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.base; 2 | 3 | import android.opengl.GLSurfaceView; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | 7 | import com.onzhou.common.base.AbsBaseActivity; 8 | 9 | /** 10 | * @anchor: andy 11 | * @date: 2018-11-02 12 | * @description: 13 | */ 14 | public abstract class AbsGLSurfaceActivity extends AbsBaseActivity { 15 | 16 | private GLSurfaceView mGLSurfaceView; 17 | 18 | protected abstract GLSurfaceView.Renderer bindRenderer(); 19 | 20 | @Override 21 | protected void onCreate(@Nullable Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setupViews(); 24 | } 25 | 26 | private void setupViews() { 27 | mGLSurfaceView = new GLSurfaceView(this); 28 | setContentView(mGLSurfaceView); 29 | //设置版本 30 | mGLSurfaceView.setEGLContextClientVersion(3); 31 | GLSurfaceView.Renderer renderer = bindRenderer(); 32 | mGLSurfaceView.setRenderer(renderer); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.base; 2 | 3 | import android.app.Application; 4 | 5 | import com.onzhou.common.core.AppCore; 6 | 7 | /** 8 | * @anchor: andy 9 | * @date: 2018-11-07 10 | * @description: 11 | */ 12 | public class BaseApplication extends Application { 13 | 14 | @Override 15 | public void onCreate() { 16 | super.onCreate(); 17 | AppCore.getInstance().init(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/core/AppCore.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.core; 2 | 3 | import android.app.Application; 4 | import android.content.res.Resources; 5 | 6 | /** 7 | * @anchor: andy 8 | * @date: 2018-11-07 9 | * @description: 10 | */ 11 | public class AppCore { 12 | 13 | private static AppCore sInstance; 14 | 15 | private Application application; 16 | 17 | public static AppCore getInstance() { 18 | if (sInstance == null) { 19 | sInstance = new AppCore(); 20 | } 21 | return sInstance; 22 | } 23 | 24 | public void init(Application application) { 25 | this.application = application; 26 | } 27 | 28 | public Application getContext() { 29 | return application; 30 | } 31 | 32 | public Resources getResources() { 33 | return application.getResources(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/task/AssertReleaseTask.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.task; 2 | 3 | import android.content.Context; 4 | import android.os.AsyncTask; 5 | 6 | import java.io.Closeable; 7 | import java.io.File; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.lang.ref.WeakReference; 12 | 13 | public class AssertReleaseTask extends AsyncTask { 14 | 15 | private WeakReference weakContext; 16 | 17 | private String[] fileNames; 18 | 19 | private ReleaseCallback releaseCallback; 20 | 21 | public AssertReleaseTask(Context context, String fileNames[], ReleaseCallback releaseCallback) { 22 | this.weakContext = new WeakReference<>(context); 23 | this.fileNames = fileNames; 24 | this.releaseCallback = releaseCallback; 25 | } 26 | 27 | public AssertReleaseTask(Context context, String fileName, ReleaseCallback releaseCallback) { 28 | this.weakContext = new WeakReference<>(context); 29 | this.fileNames = new String[1]; 30 | this.fileNames[0] = fileName; 31 | this.releaseCallback = releaseCallback; 32 | } 33 | 34 | @Override 35 | protected String doInBackground(Void... voids) { 36 | Context appContext = weakContext.get(); 37 | if (appContext != null && fileNames != null) { 38 | for (String fileName : fileNames) { 39 | releaseAsserts(fileName); 40 | } 41 | } 42 | return null; 43 | } 44 | 45 | /** 46 | * 释放Asserts目录下指定文件 47 | * @param fileName 48 | * @return 49 | */ 50 | private String releaseAsserts(String fileName) { 51 | InputStream inputStream = null; 52 | FileOutputStream fos = null; 53 | try { 54 | Context appContext = weakContext.get(); 55 | if (appContext != null) { 56 | inputStream = appContext.getAssets().open(fileName); 57 | File targetFile = new File(appContext.getExternalFilesDir(null), fileName); 58 | fos = new FileOutputStream(targetFile); 59 | int length; 60 | byte[] buffer = new byte[8 * 1024]; 61 | while ((length = inputStream.read(buffer)) != -1) { 62 | fos.write(buffer, 0, length); 63 | fos.flush(); 64 | } 65 | return targetFile.getAbsolutePath(); 66 | } 67 | } catch (IOException e) { 68 | e.printStackTrace(); 69 | } finally { 70 | ioClose(fos); 71 | ioClose(inputStream); 72 | } 73 | return null; 74 | } 75 | 76 | @Override 77 | protected void onPostExecute(String filePath) { 78 | super.onPostExecute(filePath); 79 | if (releaseCallback != null) { 80 | releaseCallback.onReleaseComplete(); 81 | } 82 | } 83 | 84 | private void ioClose(Closeable closeable) { 85 | if (closeable != null) { 86 | try { 87 | closeable.close(); 88 | } catch (IOException e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | } 93 | 94 | public interface ReleaseCallback { 95 | 96 | void onReleaseComplete(); 97 | 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/utils/ResReadUtils.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.utils; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | 6 | import com.onzhou.common.core.AppCore; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.InputStreamReader; 12 | 13 | /** 14 | * @anchor: andy 15 | * @date: 2018-09-13 16 | * @description: 17 | */ 18 | public class ResReadUtils { 19 | 20 | /** 21 | * 读取资源 22 | * 23 | * @param resourceId 24 | * @return 25 | */ 26 | public static String readResource(int resourceId) { 27 | StringBuilder builder = new StringBuilder(); 28 | try { 29 | InputStream inputStream = AppCore.getInstance().getResources().openRawResource(resourceId); 30 | InputStreamReader streamReader = new InputStreamReader(inputStream); 31 | 32 | BufferedReader bufferedReader = new BufferedReader(streamReader); 33 | String textLine; 34 | while ((textLine = bufferedReader.readLine()) != null) { 35 | builder.append(textLine); 36 | builder.append("\n"); 37 | } 38 | } catch (IOException e) { 39 | e.printStackTrace(); 40 | } catch (Resources.NotFoundException e) { 41 | e.printStackTrace(); 42 | } 43 | return builder.toString(); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/utils/ShaderUtils.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.utils; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.opengl.GLES30; 6 | 7 | import com.onzhou.common.core.AppCore; 8 | 9 | /** 10 | * @anchor: andy 11 | * @date: 2018-09-13 12 | * @description: 13 | */ 14 | public class ShaderUtils { 15 | 16 | private static final String TAG = "ShaderUtils"; 17 | 18 | /** 19 | * 编译顶点着色器 20 | * 21 | * @param shaderCode 22 | * @return 23 | */ 24 | public static int compileVertexShader(String shaderCode) { 25 | return compileShader(GLES30.GL_VERTEX_SHADER, shaderCode); 26 | } 27 | 28 | /** 29 | * 编译片段着色器 30 | * 31 | * @param shaderCode 32 | * @return 33 | */ 34 | public static int compileFragmentShader(String shaderCode) { 35 | return compileShader(GLES30.GL_FRAGMENT_SHADER, shaderCode); 36 | } 37 | 38 | /** 39 | * 编译 40 | * 41 | * @param type 顶点着色器:GLES30.GL_VERTEX_SHADER 42 | * 片段着色器:GLES30.GL_FRAGMENT_SHADER 43 | * @param shaderCode 44 | * @return 45 | */ 46 | private static int compileShader(int type, String shaderCode) { 47 | //创建一个着色器 48 | final int shaderId = GLES30.glCreateShader(type); 49 | if (shaderId != 0) { 50 | GLES30.glShaderSource(shaderId, shaderCode); 51 | GLES30.glCompileShader(shaderId); 52 | //检测状态 53 | final int[] compileStatus = new int[1]; 54 | GLES30.glGetShaderiv(shaderId, GLES30.GL_COMPILE_STATUS, compileStatus, 0); 55 | if (compileStatus[0] == 0) { 56 | String logInfo = GLES30.glGetShaderInfoLog(shaderId); 57 | System.err.println(logInfo); 58 | //创建失败 59 | GLES30.glDeleteShader(shaderId); 60 | return 0; 61 | } 62 | return shaderId; 63 | } else { 64 | //创建失败 65 | return 0; 66 | } 67 | } 68 | 69 | /** 70 | * 链接小程序 71 | * 72 | * @param vertexShaderId 顶点着色器 73 | * @param fragmentShaderId 片段着色器 74 | * @return 75 | */ 76 | public static int linkProgram(int vertexShaderId, int fragmentShaderId) { 77 | final int programId = GLES30.glCreateProgram(); 78 | if (programId != 0) { 79 | //将顶点着色器加入到程序 80 | GLES30.glAttachShader(programId, vertexShaderId); 81 | //将片元着色器加入到程序中 82 | GLES30.glAttachShader(programId, fragmentShaderId); 83 | //链接着色器程序 84 | GLES30.glLinkProgram(programId); 85 | final int[] linkStatus = new int[1]; 86 | 87 | GLES30.glGetProgramiv(programId, GLES30.GL_LINK_STATUS, linkStatus, 0); 88 | if (linkStatus[0] == 0) { 89 | String logInfo = GLES30.glGetProgramInfoLog(programId); 90 | System.err.println(logInfo); 91 | GLES30.glDeleteProgram(programId); 92 | return 0; 93 | } 94 | return programId; 95 | } else { 96 | //创建失败 97 | return 0; 98 | } 99 | } 100 | 101 | /** 102 | * 验证程序片段是否有效 103 | * 104 | * @param programObjectId 105 | * @return 106 | */ 107 | public static boolean validProgram(int programObjectId) { 108 | GLES30.glValidateProgram(programObjectId); 109 | final int[] programStatus = new int[1]; 110 | GLES30.glGetProgramiv(programObjectId, GLES30.GL_VALIDATE_STATUS, programStatus, 0); 111 | return programStatus[0] != 0; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /common/src/main/java/com/onzhou/common/utils/TextureUtils.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.common.utils; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.opengl.GLES11Ext; 7 | import android.opengl.GLES20; 8 | import android.opengl.GLES30; 9 | import android.opengl.GLUtils; 10 | import android.util.Log; 11 | 12 | import javax.microedition.khronos.opengles.GL10; 13 | 14 | /** 15 | * @anchor: andy 16 | * @date: 18-11-10 17 | */ 18 | 19 | public class TextureUtils { 20 | 21 | private static final String TAG = "TextureUtils"; 22 | 23 | public static int loadTexture(Context context, int resourceId) { 24 | final int[] textureIds = new int[1]; 25 | GLES30.glGenTextures(1, textureIds, 0); 26 | if (textureIds[0] == 0) { 27 | Log.e(TAG, "Could not generate a new OpenGL textureId object."); 28 | return 0; 29 | } 30 | final BitmapFactory.Options options = new BitmapFactory.Options(); 31 | options.inScaled = false; 32 | final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options); 33 | if (bitmap == null) { 34 | Log.e(TAG, "Resource ID " + resourceId + " could not be decoded."); 35 | GLES30.glDeleteTextures(1, textureIds, 0); 36 | return 0; 37 | } 38 | // 绑定纹理到OpenGL 39 | GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, textureIds[0]); 40 | 41 | GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR_MIPMAP_LINEAR); 42 | GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR); 43 | 44 | // 加载bitmap到纹理中 45 | GLUtils.texImage2D(GLES30.GL_TEXTURE_2D, 0, bitmap, 0); 46 | 47 | // 生成MIP贴图 48 | GLES30.glGenerateMipmap(GLES30.GL_TEXTURE_2D); 49 | 50 | // 数据如果已经被加载进OpenGL,则可以回收该bitmap 51 | bitmap.recycle(); 52 | 53 | // 取消绑定纹理 54 | GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0); 55 | 56 | return textureIds[0]; 57 | } 58 | 59 | /** 60 | * 加载OES Texture 61 | * 62 | * @return 63 | */ 64 | public static int loadOESTexture() { 65 | int[] textureIds = new int[1]; 66 | GLES20.glGenTextures(1, textureIds, 0); 67 | GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureIds[0]); 68 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 69 | GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); 70 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 71 | GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); 72 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 73 | GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); 74 | GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 75 | GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); 76 | GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0); 77 | return textureIds[0]; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /common/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /common/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /common/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /common/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /common/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/common/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /common/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /common/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | common 3 | 4 | -------------------------------------------------------------------------------- /common/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /config.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | android = [ 3 | compileSdkVersion: 25, 4 | buildToolsVersion: "25.0.3", 5 | applicationId : "com.onzhou.graphic", 6 | minSdkVersion : 16, 7 | targetSdkVersion : 25, 8 | versionCode : 1, 9 | versionName : "1.0.0" 10 | ] 11 | 12 | dependencies = [ 13 | "design" : 'com.android.support:design:25.3.1', 14 | "appcompat-v7": 'com.android.support:appcompat-v7:25.3.1', 15 | "junit" : 'junit:junit:4.12', 16 | "rxjava" : 'io.reactivex.rxjava2:rxjava:2.2.0', 17 | "rxandroid" : 'io.reactivex.rxjava2:rxandroid:2.1.0' 18 | ] 19 | 20 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Nov 01 23:52:08 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /images/20181123103405458.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/images/20181123103405458.png -------------------------------------------------------------------------------- /images/20181123111204640.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/images/20181123111204640.png -------------------------------------------------------------------------------- /images/20181124224717420.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/images/20181124224717420.png -------------------------------------------------------------------------------- /images/20181125125310654.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/images/20181125125310654.png -------------------------------------------------------------------------------- /native-gauss/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /native-gauss/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.4.1) 3 | 4 | 5 | add_library(gauss-bitmap 6 | SHARED 7 | src/main/cpp/gauss_bitmap.c) 8 | 9 | find_library(log-lib 10 | log) 11 | 12 | find_library(android-lib 13 | android) 14 | 15 | find_library(jnigraphics-lib 16 | jnigraphics) 17 | 18 | 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") 20 | set(CMAKE_VERBOSE_MAKEFILE on) 21 | 22 | target_link_libraries(gauss-bitmap ${log-lib} ${android-lib} ${jnigraphics-lib}) 23 | -------------------------------------------------------------------------------- /native-gauss/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | //构建版本 5 | compileSdkVersion rootProject.ext.android.compileSdkVersion 6 | buildToolsVersion rootProject.ext.android.buildToolsVersion 7 | //默认的配置 8 | defaultConfig { 9 | minSdkVersion rootProject.ext.android.minSdkVersion 10 | targetSdkVersion rootProject.ext.android.targetSdkVersion 11 | applicationId rootProject.ext.android.applicationId 12 | versionCode rootProject.ext.android.versionCode 13 | versionName rootProject.ext.android.versionName 14 | 15 | externalNativeBuild { 16 | cmake { 17 | cppFlags "" 18 | } 19 | ndk { 20 | abiFilters "armeabi-v7a" 21 | } 22 | } 23 | sourceSets { 24 | main { 25 | //库地址 26 | jniLibs.srcDirs = ['libs'] 27 | } 28 | } 29 | } 30 | buildTypes { 31 | release { 32 | minifyEnabled false 33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 34 | } 35 | } 36 | externalNativeBuild { 37 | cmake { 38 | path "CMakeLists.txt" 39 | } 40 | } 41 | } 42 | 43 | dependencies { 44 | compile fileTree(dir: 'libs', include: ['*.jar']) 45 | testCompile 'junit:junit:4.12' 46 | compile rootProject.ext.dependencies["appcompat-v7"] 47 | compile rootProject.ext.dependencies["design"] 48 | compile project(':common') 49 | } 50 | -------------------------------------------------------------------------------- /native-gauss/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /native-gauss/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /native-gauss/src/main/cpp/gauss_bitmap.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class cn_byhook_code_GaussBlurry */ 4 | 5 | #ifndef _Included_cn_byhook_code_GaussBlurry 6 | #define _Included_cn_byhook_code_GaussBlurry 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_onzhou_graphic_GaussBitmap 12 | * Method: gaussBitmap 13 | * Signature: (Ljava/lang/Object;)V 14 | */ 15 | JNIEXPORT jint JNICALL Java_com_onzhou_graphic_GaussBitmap_gaussBitmap 16 | (JNIEnv *, jobject, jobject,jint radius); 17 | 18 | /** 19 | * 高斯模糊算法 20 | **/ 21 | void GaussBitmap(int* pix, int w, int h, int radius); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | #endif -------------------------------------------------------------------------------- /native-gauss/src/main/java/com/onzhou/graphic/GaussBitmap.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.graphic; 2 | 3 | /** 4 | * @anchor: andy 5 | * @date: 18-11-2 6 | */ 7 | 8 | public class GaussBitmap { 9 | 10 | static { 11 | System.loadLibrary("gauss-bitmap"); 12 | } 13 | 14 | public static native int gaussBitmap(Object bitmap, int radius); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /native-gauss/src/main/java/com/onzhou/graphic/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.onzhou.graphic; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | private ImageView gaussImageView; 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | setupViews(); 19 | } 20 | 21 | private void setupViews() { 22 | gaussImageView = (ImageView) findViewById(R.id.iv_image); 23 | } 24 | 25 | public void onGaussClick(View view) { 26 | //获取Bitmap对象 27 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.input); 28 | gaussImageView.setImageBitmap(bitmap); 29 | //开始高斯模糊 30 | GaussBitmap.gaussBitmap(bitmap, 50); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /native-gauss/src/main/res/drawable-xxhdpi/input.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-gauss/src/main/res/drawable-xxhdpi/input.jpg -------------------------------------------------------------------------------- /native-gauss/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |