├── .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 | 
15 |
16 | [原文地址](https://blog.csdn.net/byhook/article/details/84324847)
17 |
18 | ## native-libpng
19 |
20 | 移植了`libpng库`到`android平台`,在`native`层加载`png`图片,进行渲染
21 |
22 | 
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 | 
37 |
38 | [原文地址](https://blog.csdn.net/byhook/article/details/84303640)
39 |
40 | ## native-yuv2rgb
41 |
42 | 主要用来实现`yuv`
43 |
44 | 
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 |
15 |
16 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/native-gauss/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/native-gauss/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | graphic4android
3 |
4 |
--------------------------------------------------------------------------------
/native-gauss/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/native-gauss/src/test/java/com/onzhou/graphic/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/native-libjpeg-turbo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | cmake_minimum_required(VERSION 3.4.1)
3 |
4 | ##官方标准配置
5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")
7 |
8 | add_library(native-image
9 | SHARED
10 | src/main/cpp/native_image.cpp)
11 |
12 | add_library(jpeg
13 | SHARED
14 | IMPORTED)
15 |
16 | set_target_properties(jpeg
17 | PROPERTIES IMPORTED_LOCATION
18 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libjpeg.so
19 | )
20 |
21 | add_library(jpeg-turbo
22 | SHARED
23 | IMPORTED)
24 |
25 | set_target_properties(jpeg-turbo
26 | PROPERTIES IMPORTED_LOCATION
27 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libturbojpeg.so
28 | )
29 |
30 | #头文件
31 | include_directories(${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/include)
32 |
33 | target_link_libraries(native-image
34 | jpeg
35 | jpeg-turbo
36 | android
37 | jnigraphics
38 | log)
39 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/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 |
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", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
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 |
49 | compile project(':common')
50 | }
--------------------------------------------------------------------------------
/native-libjpeg-turbo/build_scripts/build_jpeg.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #初始化环境变量
4 | source config.sh
5 |
6 | # 获取当前路径
7 | NOW_DIR=$(cd `dirname $0`; pwd)
8 |
9 | # 待编译的库目录名称
10 | MY_LIBS_NAME=libjpeg-turbo
11 | # 源代码路径
12 | MY_SOURCE_DIR=$NOW_DIR/libjpeg-turbo
13 |
14 | #编译的过程中产生的中间件的存放目录
15 | BINARY_DIR=binary
16 |
17 | #NDK路径
18 | ANDROID_NDK_ROOT=/media/byhook/backup/android/android-ndk-r16b
19 | BUILD_PLATFORM=linux-x86_64
20 | AOSP_TOOLCHAIN_SUFFIX=4.9
21 | AOSP_API=21
22 |
23 | LIBS_DIR=$NOW_DIR/libs
24 | echo "LIBS_DIR="$LIBS_DIR
25 |
26 |
27 | # 构建中间文件
28 | BUILD_DIR=./${BINARY_DIR}/${AOSP_ABI}
29 |
30 | # 最终编译的安装目录
31 | PREFIX=${LIBS_DIR}/${AOSP_ABI}/
32 | SYSROOT=${ANDROID_NDK_ROOT}/platforms/android-${AOSP_API}/${AOSP_ARCH}
33 |
34 | export CFLAGS="$AOSP_FLAGS -D__ANDROID_API__=${AOSP_API} --sysroot=${SYSROOT} \
35 | -isystem ${ANDROID_NDK_ROOT}/sysroot/usr/include \
36 | -isystem ${ANDROID_NDK_ROOT}/sysroot/usr/include/${HOST} "
37 | export LDFLAGS=-pie
38 |
39 | TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/$TOOLCHAIN_BASE-$AOSP_TOOLCHAIN_SUFFIX/prebuilt/${BUILD_PLATFORM}
40 |
41 | #创建当前编译目录
42 | mkdir -p ${BUILD_DIR}
43 | mkdir -p ${PREFIX}
44 | cd ${BUILD_DIR}
45 |
46 | cat <toolchain.cmake
47 | set(CMAKE_SYSTEM_NAME Linux)
48 | set(CMAKE_SYSTEM_PROCESSOR ${PROCESSOR})
49 | set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
50 | set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
51 | EOF
52 |
53 | cmake -G"Unix Makefiles" \
54 | -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
55 | -DCMAKE_POSITION_INDEPENDENT_CODE=1 \
56 | -DCMAKE_INSTALL_PREFIX=${PREFIX} \
57 | -DWITH_JPEG8=1 \
58 | ${MY_SOURCE_DIR}
59 |
60 | make clean
61 | make
62 | make install
63 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/build_scripts/build_jpeg_all.sh:
--------------------------------------------------------------------------------
1 |
2 |
3 | for arch in armeabi armeabi-v7a arm64-v8a x86 x86_64
4 | do
5 | bash build_jpeg.sh $arch
6 | done
7 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/build_scripts/config.sh:
--------------------------------------------------------------------------------
1 |
2 |
3 | #架构
4 | if [ "$#" -lt 1 ]; then
5 | THE_ARCH=armv7
6 | else
7 | THE_ARCH=$(tr [A-Z] [a-z] <<< "$1")
8 | fi
9 |
10 | #根据不同架构配置环境变量
11 | case "$THE_ARCH" in
12 | arm|armv5|armv6|armv7|armeabi)
13 | TOOLCHAIN_BASE="arm-linux-androideabi"
14 | HOST="arm-linux-androideabi"
15 | AOSP_ABI="armeabi"
16 | AOSP_ARCH="arch-arm"
17 | AOSP_FLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays"
18 | PROCESSOR="arm"
19 | ;;
20 | armv7a|armeabi-v7a)
21 | TOOLCHAIN_BASE="arm-linux-androideabi"
22 | HOST="arm-linux-androideabi"
23 | AOSP_ABI="armeabi-v7a"
24 | AOSP_ARCH="arch-arm"
25 | AOSP_FLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays"
26 | PROCESSOR="arm"
27 | ;;
28 | armv8|armv8a|aarch64|arm64|arm64-v8a)
29 | TOOLCHAIN_BASE="aarch64-linux-android"
30 | HOST="aarch64-linux-android"
31 | AOSP_ABI="arm64-v8a"
32 | AOSP_ARCH="arch-arm64"
33 | AOSP_FLAGS=""
34 | PROCESSOR="aarch64"
35 | ;;
36 | x86)
37 | TOOLCHAIN_BASE="x86"
38 | HOST="i686-linux-android"
39 | AOSP_ABI="x86"
40 | AOSP_ARCH="arch-x86"
41 | AOSP_FLAGS=""
42 | PROCESSOR="i386"
43 | ;;
44 | x86_64|x64)
45 | TOOLCHAIN_BASE="x86_64"
46 | HOST="x86_64-linux-android"
47 | AOSP_ABI="x86_64"
48 | AOSP_ARCH="arch-x86_64"
49 | AOSP_FLAGS=""
50 | PROCESSOR="x86_64"
51 | ;;
52 | *)
53 | echo "ERROR: Unknown architecture $1"
54 | [ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
55 | ;;
56 | esac
57 |
58 | echo "TOOLCHAIN_BASE="$TOOLCHAIN_BASE
59 | echo "TOOLNAME_BASE="$TOOLNAME_BASE
60 | echo "AOSP_ABI="$AOSP_ABI
61 | echo "AOSP_ARCH="$AOSP_ARCH
62 | echo "AOSP_FLAGS="$AOSP_FLAGS
63 | echo "HOST="$HOST
64 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/arm64-v8a/include/jconfig.h:
--------------------------------------------------------------------------------
1 | /* Version ID for the JPEG library.
2 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
3 | */
4 | #define JPEG_LIB_VERSION 80
5 |
6 | /* libjpeg-turbo version */
7 | #define LIBJPEG_TURBO_VERSION 2.0.1
8 |
9 | /* libjpeg-turbo version in integer form */
10 | #define LIBJPEG_TURBO_VERSION_NUMBER 2000001
11 |
12 | /* Support arithmetic encoding */
13 | #define C_ARITH_CODING_SUPPORTED 1
14 |
15 | /* Support arithmetic decoding */
16 | #define D_ARITH_CODING_SUPPORTED 1
17 |
18 | /* Support in-memory source/destination managers */
19 | /* #undef MEM_SRCDST_SUPPORTED */
20 |
21 | /* Use accelerated SIMD routines. */
22 | #define WITH_SIMD 1
23 |
24 | /*
25 | * Define BITS_IN_JSAMPLE as either
26 | * 8 for 8-bit sample values (the usual setting)
27 | * 12 for 12-bit sample values
28 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the
29 | * JPEG standard, and the IJG code does not support anything else!
30 | * We do not support run-time selection of data precision, sorry.
31 | */
32 |
33 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
34 |
35 | /* Define to 1 if you have the header file. */
36 | #define HAVE_LOCALE_H 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDDEF_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define if you need to include to get size_t. */
45 | #define NEED_SYS_TYPES_H 1
46 |
47 | /* Define if you have BSD-like bzero and bcopy in rather than
48 | memset/memcpy in . */
49 | /* #undef NEED_BSD_STRINGS */
50 |
51 | /* Define to 1 if the system has the type `unsigned char'. */
52 | #define HAVE_UNSIGNED_CHAR 1
53 |
54 | /* Define to 1 if the system has the type `unsigned short'. */
55 | #define HAVE_UNSIGNED_SHORT 1
56 |
57 | /* Compiler does not support pointers to undefined structures. */
58 | /* #undef INCOMPLETE_TYPES_BROKEN */
59 |
60 | /* Define if your (broken) compiler shifts signed values as if they were
61 | unsigned. */
62 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */
63 |
64 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */
65 | #ifndef __CHAR_UNSIGNED__
66 | /* #undef __CHAR_UNSIGNED__ */
67 | #endif
68 |
69 | /* Define to empty if `const' does not conform to ANSI C. */
70 | /* #undef const */
71 |
72 | /* Define to `unsigned int' if does not define. */
73 | /* #undef size_t */
74 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/arm64-v8a/libjpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/arm64-v8a/libjpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/arm64-v8a/libjpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/arm64-v8a/libjpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/arm64-v8a/libturbojpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/arm64-v8a/libturbojpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/arm64-v8a/libturbojpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/arm64-v8a/libturbojpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi-v7a/include/jconfig.h:
--------------------------------------------------------------------------------
1 | /* Version ID for the JPEG library.
2 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
3 | */
4 | #define JPEG_LIB_VERSION 80
5 |
6 | /* libjpeg-turbo version */
7 | #define LIBJPEG_TURBO_VERSION 2.0.1
8 |
9 | /* libjpeg-turbo version in integer form */
10 | #define LIBJPEG_TURBO_VERSION_NUMBER 2000001
11 |
12 | /* Support arithmetic encoding */
13 | #define C_ARITH_CODING_SUPPORTED 1
14 |
15 | /* Support arithmetic decoding */
16 | #define D_ARITH_CODING_SUPPORTED 1
17 |
18 | /* Support in-memory source/destination managers */
19 | /* #undef MEM_SRCDST_SUPPORTED */
20 |
21 | /* Use accelerated SIMD routines. */
22 | #define WITH_SIMD 1
23 |
24 | /*
25 | * Define BITS_IN_JSAMPLE as either
26 | * 8 for 8-bit sample values (the usual setting)
27 | * 12 for 12-bit sample values
28 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the
29 | * JPEG standard, and the IJG code does not support anything else!
30 | * We do not support run-time selection of data precision, sorry.
31 | */
32 |
33 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
34 |
35 | /* Define to 1 if you have the header file. */
36 | #define HAVE_LOCALE_H 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDDEF_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define if you need to include to get size_t. */
45 | #define NEED_SYS_TYPES_H 1
46 |
47 | /* Define if you have BSD-like bzero and bcopy in rather than
48 | memset/memcpy in . */
49 | /* #undef NEED_BSD_STRINGS */
50 |
51 | /* Define to 1 if the system has the type `unsigned char'. */
52 | #define HAVE_UNSIGNED_CHAR 1
53 |
54 | /* Define to 1 if the system has the type `unsigned short'. */
55 | #define HAVE_UNSIGNED_SHORT 1
56 |
57 | /* Compiler does not support pointers to undefined structures. */
58 | /* #undef INCOMPLETE_TYPES_BROKEN */
59 |
60 | /* Define if your (broken) compiler shifts signed values as if they were
61 | unsigned. */
62 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */
63 |
64 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */
65 | #ifndef __CHAR_UNSIGNED__
66 | /* #undef __CHAR_UNSIGNED__ */
67 | #endif
68 |
69 | /* Define to empty if `const' does not conform to ANSI C. */
70 | /* #undef const */
71 |
72 | /* Define to `unsigned int' if does not define. */
73 | /* #undef size_t */
74 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi-v7a/libjpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi-v7a/libjpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi-v7a/libjpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi-v7a/libjpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi-v7a/libturbojpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi-v7a/libturbojpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi-v7a/libturbojpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi-v7a/libturbojpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi/include/jconfig.h:
--------------------------------------------------------------------------------
1 | /* Version ID for the JPEG library.
2 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
3 | */
4 | #define JPEG_LIB_VERSION 80
5 |
6 | /* libjpeg-turbo version */
7 | #define LIBJPEG_TURBO_VERSION 2.0.1
8 |
9 | /* libjpeg-turbo version in integer form */
10 | #define LIBJPEG_TURBO_VERSION_NUMBER 2000001
11 |
12 | /* Support arithmetic encoding */
13 | #define C_ARITH_CODING_SUPPORTED 1
14 |
15 | /* Support arithmetic decoding */
16 | #define D_ARITH_CODING_SUPPORTED 1
17 |
18 | /* Support in-memory source/destination managers */
19 | /* #undef MEM_SRCDST_SUPPORTED */
20 |
21 | /* Use accelerated SIMD routines. */
22 | #define WITH_SIMD 1
23 |
24 | /*
25 | * Define BITS_IN_JSAMPLE as either
26 | * 8 for 8-bit sample values (the usual setting)
27 | * 12 for 12-bit sample values
28 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the
29 | * JPEG standard, and the IJG code does not support anything else!
30 | * We do not support run-time selection of data precision, sorry.
31 | */
32 |
33 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
34 |
35 | /* Define to 1 if you have the header file. */
36 | #define HAVE_LOCALE_H 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDDEF_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define if you need to include to get size_t. */
45 | #define NEED_SYS_TYPES_H 1
46 |
47 | /* Define if you have BSD-like bzero and bcopy in rather than
48 | memset/memcpy in . */
49 | /* #undef NEED_BSD_STRINGS */
50 |
51 | /* Define to 1 if the system has the type `unsigned char'. */
52 | #define HAVE_UNSIGNED_CHAR 1
53 |
54 | /* Define to 1 if the system has the type `unsigned short'. */
55 | #define HAVE_UNSIGNED_SHORT 1
56 |
57 | /* Compiler does not support pointers to undefined structures. */
58 | /* #undef INCOMPLETE_TYPES_BROKEN */
59 |
60 | /* Define if your (broken) compiler shifts signed values as if they were
61 | unsigned. */
62 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */
63 |
64 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */
65 | #ifndef __CHAR_UNSIGNED__
66 | /* #undef __CHAR_UNSIGNED__ */
67 | #endif
68 |
69 | /* Define to empty if `const' does not conform to ANSI C. */
70 | /* #undef const */
71 |
72 | /* Define to `unsigned int' if does not define. */
73 | /* #undef size_t */
74 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi/libjpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi/libjpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi/libjpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi/libjpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi/libturbojpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi/libturbojpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/armeabi/libturbojpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/armeabi/libturbojpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86/include/jconfig.h:
--------------------------------------------------------------------------------
1 | /* Version ID for the JPEG library.
2 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
3 | */
4 | #define JPEG_LIB_VERSION 80
5 |
6 | /* libjpeg-turbo version */
7 | #define LIBJPEG_TURBO_VERSION 2.0.1
8 |
9 | /* libjpeg-turbo version in integer form */
10 | #define LIBJPEG_TURBO_VERSION_NUMBER 2000001
11 |
12 | /* Support arithmetic encoding */
13 | #define C_ARITH_CODING_SUPPORTED 1
14 |
15 | /* Support arithmetic decoding */
16 | #define D_ARITH_CODING_SUPPORTED 1
17 |
18 | /* Support in-memory source/destination managers */
19 | /* #undef MEM_SRCDST_SUPPORTED */
20 |
21 | /* Use accelerated SIMD routines. */
22 | #define WITH_SIMD 1
23 |
24 | /*
25 | * Define BITS_IN_JSAMPLE as either
26 | * 8 for 8-bit sample values (the usual setting)
27 | * 12 for 12-bit sample values
28 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the
29 | * JPEG standard, and the IJG code does not support anything else!
30 | * We do not support run-time selection of data precision, sorry.
31 | */
32 |
33 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
34 |
35 | /* Define to 1 if you have the header file. */
36 | #define HAVE_LOCALE_H 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDDEF_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define if you need to include to get size_t. */
45 | #define NEED_SYS_TYPES_H 1
46 |
47 | /* Define if you have BSD-like bzero and bcopy in rather than
48 | memset/memcpy in . */
49 | /* #undef NEED_BSD_STRINGS */
50 |
51 | /* Define to 1 if the system has the type `unsigned char'. */
52 | #define HAVE_UNSIGNED_CHAR 1
53 |
54 | /* Define to 1 if the system has the type `unsigned short'. */
55 | #define HAVE_UNSIGNED_SHORT 1
56 |
57 | /* Compiler does not support pointers to undefined structures. */
58 | /* #undef INCOMPLETE_TYPES_BROKEN */
59 |
60 | /* Define if your (broken) compiler shifts signed values as if they were
61 | unsigned. */
62 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */
63 |
64 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */
65 | #ifndef __CHAR_UNSIGNED__
66 | /* #undef __CHAR_UNSIGNED__ */
67 | #endif
68 |
69 | /* Define to empty if `const' does not conform to ANSI C. */
70 | /* #undef const */
71 |
72 | /* Define to `unsigned int' if does not define. */
73 | /* #undef size_t */
74 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86/libjpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86/libjpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86/libjpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86/libjpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86/libturbojpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86/libturbojpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86/libturbojpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86/libturbojpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86_64/include/jconfig.h:
--------------------------------------------------------------------------------
1 | /* Version ID for the JPEG library.
2 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
3 | */
4 | #define JPEG_LIB_VERSION 80
5 |
6 | /* libjpeg-turbo version */
7 | #define LIBJPEG_TURBO_VERSION 2.0.1
8 |
9 | /* libjpeg-turbo version in integer form */
10 | #define LIBJPEG_TURBO_VERSION_NUMBER 2000001
11 |
12 | /* Support arithmetic encoding */
13 | #define C_ARITH_CODING_SUPPORTED 1
14 |
15 | /* Support arithmetic decoding */
16 | #define D_ARITH_CODING_SUPPORTED 1
17 |
18 | /* Support in-memory source/destination managers */
19 | /* #undef MEM_SRCDST_SUPPORTED */
20 |
21 | /* Use accelerated SIMD routines. */
22 | #define WITH_SIMD 1
23 |
24 | /*
25 | * Define BITS_IN_JSAMPLE as either
26 | * 8 for 8-bit sample values (the usual setting)
27 | * 12 for 12-bit sample values
28 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the
29 | * JPEG standard, and the IJG code does not support anything else!
30 | * We do not support run-time selection of data precision, sorry.
31 | */
32 |
33 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
34 |
35 | /* Define to 1 if you have the header file. */
36 | #define HAVE_LOCALE_H 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDDEF_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define if you need to include to get size_t. */
45 | #define NEED_SYS_TYPES_H 1
46 |
47 | /* Define if you have BSD-like bzero and bcopy in rather than
48 | memset/memcpy in . */
49 | /* #undef NEED_BSD_STRINGS */
50 |
51 | /* Define to 1 if the system has the type `unsigned char'. */
52 | #define HAVE_UNSIGNED_CHAR 1
53 |
54 | /* Define to 1 if the system has the type `unsigned short'. */
55 | #define HAVE_UNSIGNED_SHORT 1
56 |
57 | /* Compiler does not support pointers to undefined structures. */
58 | /* #undef INCOMPLETE_TYPES_BROKEN */
59 |
60 | /* Define if your (broken) compiler shifts signed values as if they were
61 | unsigned. */
62 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */
63 |
64 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */
65 | #ifndef __CHAR_UNSIGNED__
66 | /* #undef __CHAR_UNSIGNED__ */
67 | #endif
68 |
69 | /* Define to empty if `const' does not conform to ANSI C. */
70 | /* #undef const */
71 |
72 | /* Define to `unsigned int' if does not define. */
73 | /* #undef size_t */
74 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86_64/libjpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86_64/libjpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86_64/libjpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86_64/libjpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86_64/libturbojpeg.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86_64/libturbojpeg.a
--------------------------------------------------------------------------------
/native-libjpeg-turbo/libs/x86_64/libturbojpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/libs/x86_64/libturbojpeg.so
--------------------------------------------------------------------------------
/native-libjpeg-turbo/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-libjpeg-turbo/src/androidTest/java/com/onzhou/libjpeg/turbo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.libjpeg.turbo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.onzhou.libjpeg.turbo.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/src/main/assets/input.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libjpeg-turbo/src/main/assets/input.jpeg
--------------------------------------------------------------------------------
/native-libjpeg-turbo/src/main/cpp/native_image.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_onzhou_opengles_color_NativeColorRenderer */
4 |
5 | #ifndef NATIVE_YUV2JPEG_H
6 | #define NATIVE_YUV2JPEG_H
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | JNIEXPORT void JNICALL loadJPEGImage(JNIEnv *, jobject, jstring, jobject);
12 |
13 |
14 | #ifdef __cplusplus
15 | }
16 | #endif
17 | #endif
18 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/src/main/java/com/onzhou/libjpeg/turbo/loader/NativeImageLoader.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.libjpeg.turbo.loader;
2 |
3 | import android.view.Surface;
4 |
5 | /**
6 | * @anchor: andy
7 | * @date: 2018-11-21
8 | * @description:
9 | */
10 | public class NativeImageLoader {
11 |
12 | static {
13 | System.loadLibrary("native-image");
14 | }
15 |
16 |
17 | public native void loadJPEGImage(String imagePath, Surface surface);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/src/main/java/com/onzhou/libjpeg/turbo/main/NativeImageActivity.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.libjpeg.turbo.main;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.os.AsyncTaskCompat;
6 | import android.view.SurfaceHolder;
7 | import android.view.SurfaceView;
8 |
9 | import com.onzhou.common.base.AbsBaseActivity;
10 | import com.onzhou.common.task.AssertReleaseTask;
11 | import com.onzhou.libjpeg.turbo.loader.NativeImageLoader;
12 |
13 | import java.io.File;
14 |
15 | /**
16 | * @anchor: andy
17 | * @date: 2018-11-21
18 | * @description:
19 | */
20 | public class NativeImageActivity extends AbsBaseActivity implements AssertReleaseTask.ReleaseCallback {
21 |
22 | private SurfaceView mSurfaceView;
23 |
24 | @Override
25 | protected void onCreate(@Nullable Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setupView();
28 | }
29 |
30 | @Override
31 | protected void onPostCreate(@Nullable Bundle savedInstanceState) {
32 | super.onPostCreate(savedInstanceState);
33 | AssertReleaseTask task = new AssertReleaseTask(this, "input.jpeg", this);
34 | AsyncTaskCompat.executeParallel(task);
35 | }
36 |
37 | private void setupView() {
38 | mSurfaceView = new SurfaceView(this);
39 | setContentView(mSurfaceView);
40 | mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
41 | @Override
42 | public void surfaceCreated(SurfaceHolder holder) {
43 | NativeImageLoader nativeImageLoader = new NativeImageLoader();
44 | File file = new File(getExternalFilesDir(null), "input.jpeg");
45 | nativeImageLoader.loadJPEGImage(file.getAbsolutePath(), holder.getSurface());
46 | }
47 |
48 | @Override
49 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
50 |
51 | }
52 |
53 | @Override
54 | public void surfaceDestroyed(SurfaceHolder holder) {
55 |
56 | }
57 | });
58 | }
59 |
60 | @Override
61 | public void onReleaseComplete() {
62 |
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 加载JPEG图片
3 |
4 |
--------------------------------------------------------------------------------
/native-libjpeg-turbo/src/test/java/com/onzhou/libjpeg/turbo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.libjpeg.turbo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/native-libpng/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/native-libpng/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | cmake_minimum_required(VERSION 3.4.1)
3 |
4 | ##官方标准配置
5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")
7 |
8 | add_library(native-png
9 | SHARED
10 | src/main/cpp/native_png.cpp)
11 |
12 | add_library(png
13 | SHARED
14 | IMPORTED)
15 |
16 | set_target_properties(png
17 | PROPERTIES IMPORTED_LOCATION
18 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libpng.so
19 | )
20 |
21 | add_library(zip
22 | SHARED
23 | IMPORTED)
24 |
25 | set_target_properties(zip
26 | PROPERTIES IMPORTED_LOCATION
27 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libz.so
28 | )
29 |
30 | #头文件
31 | include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include_png)
32 | include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include_zlib)
33 |
34 | target_link_libraries(native-png
35 | png
36 | zip
37 | android
38 | jnigraphics
39 | log)
40 |
--------------------------------------------------------------------------------
/native-libpng/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 |
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", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
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 |
49 | compile project(':common')
50 | }
--------------------------------------------------------------------------------
/native-libpng/libs/arm64-v8a/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/arm64-v8a/libpng.so
--------------------------------------------------------------------------------
/native-libpng/libs/arm64-v8a/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/arm64-v8a/libz.so
--------------------------------------------------------------------------------
/native-libpng/libs/armeabi-v7a/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/armeabi-v7a/libpng.so
--------------------------------------------------------------------------------
/native-libpng/libs/armeabi-v7a/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/armeabi-v7a/libz.so
--------------------------------------------------------------------------------
/native-libpng/libs/armeabi/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/armeabi/libpng.so
--------------------------------------------------------------------------------
/native-libpng/libs/armeabi/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/armeabi/libz.so
--------------------------------------------------------------------------------
/native-libpng/libs/mips/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/mips/libpng.so
--------------------------------------------------------------------------------
/native-libpng/libs/mips/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/mips/libz.so
--------------------------------------------------------------------------------
/native-libpng/libs/mips64/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/mips64/libpng.so
--------------------------------------------------------------------------------
/native-libpng/libs/mips64/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/mips64/libz.so
--------------------------------------------------------------------------------
/native-libpng/libs/x86/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/x86/libpng.so
--------------------------------------------------------------------------------
/native-libpng/libs/x86/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/x86/libz.so
--------------------------------------------------------------------------------
/native-libpng/libs/x86_64/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/x86_64/libpng.so
--------------------------------------------------------------------------------
/native-libpng/libs/x86_64/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/libs/x86_64/libz.so
--------------------------------------------------------------------------------
/native-libpng/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-libpng/src/androidTest/java/com/onzhou/graphic/png/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.png;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.onzhou.graphic.png.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/native-libpng/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/native-libpng/src/main/assets/input.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libpng/src/main/assets/input.png
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_png/PngFile.h:
--------------------------------------------------------------------------------
1 | /*------------------------------------------*/
2 | /* PNGFILE.H -- Header File for pngfile.c*/
3 | /*------------------------------------------*/
4 |
5 | /* Copyright 2000, Willem van Schaik.*/
6 |
7 | /* This code is released under the libpng license.*/
8 | /* For conditions of distribution and use, see the disclaimer*/
9 | /* and license in png.h*/
10 |
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | void PngFileInitialize (HWND hwnd) ;
17 | BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
18 | BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
19 |
20 | BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
21 | int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor);
22 | BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
23 | int iWidth, int iHeight, png_color BkgColor);
24 |
25 | #ifndef PNG_STDIO_SUPPORTED
26 | static void png_read_data(png_structp png_ptr, png_bytep data, size_t length);
27 | static void png_write_data(png_structp png_ptr, png_bytep data, size_t length);
28 | static void png_flush(png_structp png_ptr);
29 | #endif
30 |
31 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_png/pngusr.h:
--------------------------------------------------------------------------------
1 | /* minrdpngconf.h: headers to make a minimal png-read-only library
2 | *
3 | * Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
4 | *
5 | * This code is released under the libpng license.
6 | * For conditions of distribution and use, see the disclaimer
7 | * and license in png.h
8 | *
9 | * Derived from pngcrush.h, Copyright 1998-2007, Glenn Randers-Pehrson
10 | */
11 |
12 | #ifndef MINRDPNGCONF_H
13 | #define MINRDPNGCONF_H
14 |
15 | /* To include pngusr.h set -DPNG_USER_CONFIG in CPPFLAGS */
16 |
17 | /* List options to turn off features of the build that do not
18 | * affect the API (so are not recorded in pnglibconf.h)
19 | */
20 |
21 | #define PNG_ALIGN_TYPE PNG_ALIGN_NONE
22 |
23 | #endif /* MINRDPNGCONF_H */
24 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_png/readpng.h:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------
2 |
3 | rpng - simple PNG display program readpng.h
4 |
5 | ---------------------------------------------------------------------------
6 |
7 | Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
8 |
9 | This software is provided "as is," without warranty of any kind,
10 | express or implied. In no event shall the author or contributors
11 | be held liable for any damages arising in any way from the use of
12 | this software.
13 |
14 | The contents of this file are DUAL-LICENSED. You may modify and/or
15 | redistribute this software according to the terms of one of the
16 | following two licenses (at your option):
17 |
18 |
19 | LICENSE 1 ("BSD-like with advertising clause"):
20 |
21 | Permission is granted to anyone to use this software for any purpose,
22 | including commercial applications, and to alter it and redistribute
23 | it freely, subject to the following restrictions:
24 |
25 | 1. Redistributions of source code must retain the above copyright
26 | notice, disclaimer, and this list of conditions.
27 | 2. Redistributions in binary form must reproduce the above copyright
28 | notice, disclaimer, and this list of conditions in the documenta-
29 | tion and/or other materials provided with the distribution.
30 | 3. All advertising materials mentioning features or use of this
31 | software must display the following acknowledgment:
32 |
33 | This product includes software developed by Greg Roelofs
34 | and contributors for the book, "PNG: The Definitive Guide,"
35 | published by O'Reilly and Associates.
36 |
37 |
38 | LICENSE 2 (GNU GPL v2 or later):
39 |
40 | This program is free software; you can redistribute it and/or modify
41 | it under the terms of the GNU General Public License as published by
42 | the Free Software Foundation; either version 2 of the License, or
43 | (at your option) any later version.
44 |
45 | This program is distributed in the hope that it will be useful,
46 | but WITHOUT ANY WARRANTY; without even the implied warranty of
47 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 | GNU General Public License for more details.
49 |
50 | You should have received a copy of the GNU General Public License
51 | along with this program; if not, write to the Free Software Foundation,
52 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53 |
54 | ---------------------------------------------------------------------------*/
55 |
56 | #ifndef TRUE
57 | # define TRUE 1
58 | # define FALSE 0
59 | #endif
60 |
61 | #ifndef MAX
62 | # define MAX(a,b) ((a) > (b)? (a) : (b))
63 | # define MIN(a,b) ((a) < (b)? (a) : (b))
64 | #endif
65 |
66 | #ifdef DEBUG
67 | # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
68 | #else
69 | # define Trace(x) ;
70 | #endif
71 |
72 | typedef unsigned char uch;
73 | typedef unsigned short ush;
74 | typedef unsigned long ulg;
75 |
76 |
77 | /* prototypes for public functions in readpng.c */
78 |
79 | void readpng_version_info(void);
80 |
81 | int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight);
82 |
83 | int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue);
84 |
85 | uch *readpng_get_image(double display_exponent, int *pChannels,
86 | ulg *pRowbytes);
87 |
88 | void readpng_cleanup(int free_image_data);
89 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_png/readpng2.h:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------
2 |
3 | rpng2 - progressive-model PNG display program readpng2.h
4 |
5 | ---------------------------------------------------------------------------
6 |
7 | Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
8 |
9 | This software is provided "as is," without warranty of any kind,
10 | express or implied. In no event shall the author or contributors
11 | be held liable for any damages arising in any way from the use of
12 | this software.
13 |
14 | The contents of this file are DUAL-LICENSED. You may modify and/or
15 | redistribute this software according to the terms of one of the
16 | following two licenses (at your option):
17 |
18 |
19 | LICENSE 1 ("BSD-like with advertising clause"):
20 |
21 | Permission is granted to anyone to use this software for any purpose,
22 | including commercial applications, and to alter it and redistribute
23 | it freely, subject to the following restrictions:
24 |
25 | 1. Redistributions of source code must retain the above copyright
26 | notice, disclaimer, and this list of conditions.
27 | 2. Redistributions in binary form must reproduce the above copyright
28 | notice, disclaimer, and this list of conditions in the documenta-
29 | tion and/or other materials provided with the distribution.
30 | 3. All advertising materials mentioning features or use of this
31 | software must display the following acknowledgment:
32 |
33 | This product includes software developed by Greg Roelofs
34 | and contributors for the book, "PNG: The Definitive Guide,"
35 | published by O'Reilly and Associates.
36 |
37 |
38 | LICENSE 2 (GNU GPL v2 or later):
39 |
40 | This program is free software; you can redistribute it and/or modify
41 | it under the terms of the GNU General Public License as published by
42 | the Free Software Foundation; either version 2 of the License, or
43 | (at your option) any later version.
44 |
45 | This program is distributed in the hope that it will be useful,
46 | but WITHOUT ANY WARRANTY; without even the implied warranty of
47 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 | GNU General Public License for more details.
49 |
50 | You should have received a copy of the GNU General Public License
51 | along with this program; if not, write to the Free Software Foundation,
52 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53 |
54 | ---------------------------------------------------------------------------*/
55 |
56 | #ifndef TRUE
57 | # define TRUE 1
58 | # define FALSE 0
59 | #endif
60 |
61 | #ifndef MAX
62 | # define MAX(a,b) ((a) > (b)? (a) : (b))
63 | # define MIN(a,b) ((a) < (b)? (a) : (b))
64 | #endif
65 |
66 | #ifdef DEBUG
67 | # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
68 | #else
69 | # define Trace(x) ;
70 | #endif
71 |
72 | enum rpng2_states {
73 | kPreInit = 0,
74 | kWindowInit,
75 | kDone
76 | };
77 |
78 | typedef unsigned char uch;
79 | typedef unsigned short ush;
80 | typedef unsigned long ulg;
81 |
82 | typedef struct _mainprog_info {
83 | double display_exponent;
84 | ulg width;
85 | ulg height;
86 | void *png_ptr;
87 | void *info_ptr;
88 | void (*mainprog_init)(void);
89 | void (*mainprog_display_row)(ulg row_num);
90 | void (*mainprog_finish_display)(void);
91 | uch *image_data;
92 | uch **row_pointers;
93 | jmp_buf jmpbuf;
94 | int passes; /* not used */
95 | int pass;
96 | int rowbytes;
97 | int channels;
98 | int need_bgcolor;
99 | int state;
100 | uch bg_red;
101 | uch bg_green;
102 | uch bg_blue;
103 | } mainprog_info;
104 |
105 |
106 | /* prototypes for public functions in readpng2.c */
107 |
108 | void readpng2_version_info(void);
109 |
110 | int readpng2_check_sig(uch *sig, int num);
111 |
112 | int readpng2_init(mainprog_info *mainprog_ptr);
113 |
114 | int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length);
115 |
116 | void readpng2_cleanup(mainprog_info *mainprog_ptr);
117 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_png/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by VisualPng.rc
4 | //
5 | #define IDM_FILE_OPEN 40001
6 | #define IDM_FILE_SAVE 40002
7 | #define IDM_FILE_NEXT 40003
8 | #define IDM_FILE_PREVIOUS 40004
9 | #define IDM_FILE_EXIT 40005
10 | #define IDM_OPTIONS_BACKGROUND 40006
11 | #define IDM_OPTIONS_STRETCH 40007
12 | #define IDM_HELP_ABOUT 40008
13 |
14 | // Next default values for new objects
15 | //
16 | #ifdef APSTUDIO_INVOKED
17 | #ifndef APSTUDIO_READONLY_SYMBOLS
18 | #define _APS_NEXT_RESOURCE_VALUE 113
19 | #define _APS_NEXT_COMMAND_VALUE 40009
20 | #define _APS_NEXT_CONTROL_VALUE 1001
21 | #define _APS_NEXT_SYMED_VALUE 101
22 | #endif
23 | #endif
24 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_png/sRGB.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * sRGB.h
3 | *
4 | * Last changed in libpng 1.6.0 [February 14, 2013]
5 | *
6 | * COPYRIGHT: Written by John Cunningham Bowler, 2013.
7 | * To the extent possible under law, the author has waived all copyright and
8 | * related or neighboring rights to this work. This work is published from:
9 | * United States.
10 | *
11 | * Utility file; not actually a header, this contains definitions of sRGB
12 | * calculation functions for inclusion in those test programs that need them.
13 | *
14 | * All routines take and return a floating point value in the range
15 | * 0 to 1.0, doing a calculation according to the sRGB specification
16 | * (in fact the source of the numbers is the wikipedia article at
17 | * https://en.wikipedia.org/wiki/SRGB).
18 | */
19 | static double
20 | sRGB_from_linear(double l)
21 | {
22 | if (l <= 0.0031308)
23 | l *= 12.92;
24 |
25 | else
26 | l = 1.055 * pow(l, 1/2.4) - 0.055;
27 |
28 | return l;
29 | }
30 |
31 | static double
32 | linear_from_sRGB(double s)
33 | {
34 | if (s <= 0.04045)
35 | return s / 12.92;
36 |
37 | else
38 | return pow((s+0.055)/1.055, 2.4);
39 | }
40 |
41 | static double
42 | YfromRGB(double r, double g, double b)
43 | {
44 | /* Use the sRGB (rounded) coefficients for Rlinear, Glinear, Blinear to get
45 | * the CIE Y value (also linear).
46 | */
47 | return 0.2126 * r + 0.7152 * g + 0.0722 * b;
48 | }
49 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/blast.h:
--------------------------------------------------------------------------------
1 | /* blast.h -- interface for blast.c
2 | Copyright (C) 2003, 2012, 2013 Mark Adler
3 | version 1.3, 24 Aug 2013
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the author be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 |
21 | Mark Adler madler@alumni.caltech.edu
22 | */
23 |
24 |
25 | /*
26 | * blast() decompresses the PKWare Data Compression Library (DCL) compressed
27 | * format. It provides the same functionality as the explode() function in
28 | * that library. (Note: PKWare overused the "implode" verb, and the format
29 | * used by their library implode() function is completely different and
30 | * incompatible with the implode compression method supported by PKZIP.)
31 | *
32 | * The binary mode for stdio functions should be used to assure that the
33 | * compressed data is not corrupted when read or written. For example:
34 | * fopen(..., "rb") and fopen(..., "wb").
35 | */
36 |
37 |
38 | typedef unsigned (*blast_in)(void *how, unsigned char **buf);
39 | typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len);
40 | /* Definitions for input/output functions passed to blast(). See below for
41 | * what the provided functions need to do.
42 | */
43 |
44 |
45 | int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
46 | unsigned *left, unsigned char **in);
47 | /* Decompress input to output using the provided infun() and outfun() calls.
48 | * On success, the return value of blast() is zero. If there is an error in
49 | * the source data, i.e. it is not in the proper format, then a negative value
50 | * is returned. If there is not enough input available or there is not enough
51 | * output space, then a positive error is returned.
52 | *
53 | * The input function is invoked: len = infun(how, &buf), where buf is set by
54 | * infun() to point to the input buffer, and infun() returns the number of
55 | * available bytes there. If infun() returns zero, then blast() returns with
56 | * an input error. (blast() only asks for input if it needs it.) inhow is for
57 | * use by the application to pass an input descriptor to infun(), if desired.
58 | *
59 | * If left and in are not NULL and *left is not zero when blast() is called,
60 | * then the *left bytes are *in are consumed for input before infun() is used.
61 | *
62 | * The output function is invoked: err = outfun(how, buf, len), where the bytes
63 | * to be written are buf[0..len-1]. If err is not zero, then blast() returns
64 | * with an output error. outfun() is always called with len <= 4096. outhow
65 | * is for use by the application to pass an output descriptor to outfun(), if
66 | * desired.
67 | *
68 | * If there is any unused input, *left is set to the number of bytes that were
69 | * read and *in points to them. Otherwise *left is set to zero and *in is set
70 | * to NULL. If left or in are NULL, then they are not set.
71 | *
72 | * The return codes are:
73 | *
74 | * 2: ran out of input before completing decompression
75 | * 1: output error before completing decompression
76 | * 0: successful decompression
77 | * -1: literal flag not zero or one
78 | * -2: dictionary size not in 4..6
79 | * -3: distance is too far back
80 | *
81 | * At the bottom of blast.c is an example program that uses blast() that can be
82 | * compiled to produce a command-line decompression filter by defining TEST.
83 | */
84 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/infback9.h:
--------------------------------------------------------------------------------
1 | /* infback9.h -- header for using inflateBack9 functions
2 | * Copyright (C) 2003 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /*
7 | * This header file and associated patches provide a decoder for PKWare's
8 | * undocumented deflate64 compression method (method 9). Use with infback9.c,
9 | * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported.
10 | * This should be compiled with zlib, since it uses zutil.h and zutil.o.
11 | * This code has not yet been tested on 16-bit architectures. See the
12 | * comments in zlib.h for inflateBack() usage. These functions are used
13 | * identically, except that there is no windowBits parameter, and a 64K
14 | * window must be provided. Also if int's are 16 bits, then a zero for
15 | * the third parameter of the "out" function actually means 65536UL.
16 | * zlib.h must be included before this header file.
17 | */
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm,
24 | in_func in, void FAR *in_desc,
25 | out_func out, void FAR *out_desc));
26 | ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm));
27 | ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm,
28 | unsigned char FAR *window,
29 | const char *version,
30 | int stream_size));
31 | #define inflateBack9Init(strm, window) \
32 | inflateBack9Init_((strm), (window), \
33 | ZLIB_VERSION, sizeof(z_stream))
34 |
35 | #ifdef __cplusplus
36 | }
37 | #endif
38 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/inffast.h:
--------------------------------------------------------------------------------
1 | /* inffast.h -- header to use inffast.c
2 | * Copyright (C) 1995-2003, 2010 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
12 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/inflate9.h:
--------------------------------------------------------------------------------
1 | /* inflate9.h -- internal inflate state definition
2 | * Copyright (C) 1995-2003 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | /* Possible inflate modes between inflate() calls */
12 | typedef enum {
13 | TYPE, /* i: waiting for type bits, including last-flag bit */
14 | STORED, /* i: waiting for stored size (length and complement) */
15 | TABLE, /* i: waiting for dynamic block table lengths */
16 | LEN, /* i: waiting for length/lit code */
17 | DONE, /* finished check, done -- remain here until reset */
18 | BAD /* got a data error -- remain here until reset */
19 | } inflate_mode;
20 |
21 | /*
22 | State transitions between above modes -
23 |
24 | (most modes can go to the BAD mode -- not shown for clarity)
25 |
26 | Read deflate blocks:
27 | TYPE -> STORED or TABLE or LEN or DONE
28 | STORED -> TYPE
29 | TABLE -> LENLENS -> CODELENS -> LEN
30 | Read deflate codes:
31 | LEN -> LEN or TYPE
32 | */
33 |
34 | /* state maintained between inflate() calls. Approximately 7K bytes. */
35 | struct inflate_state {
36 | /* sliding window */
37 | unsigned char FAR *window; /* allocated sliding window, if needed */
38 | /* dynamic table building */
39 | unsigned ncode; /* number of code length code lengths */
40 | unsigned nlen; /* number of length code lengths */
41 | unsigned ndist; /* number of distance code lengths */
42 | unsigned have; /* number of code lengths in lens[] */
43 | code FAR *next; /* next available space in codes[] */
44 | unsigned short lens[320]; /* temporary storage for code lengths */
45 | unsigned short work[288]; /* work area for code table building */
46 | code codes[ENOUGH]; /* space for code tables */
47 | };
48 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/inftree9.h:
--------------------------------------------------------------------------------
1 | /* inftree9.h -- header to use inftree9.c
2 | * Copyright (C) 1995-2008 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | /* Structure for decoding tables. Each entry provides either the
12 | information needed to do the operation requested by the code that
13 | indexed that table entry, or it provides a pointer to another
14 | table that indexes more bits of the code. op indicates whether
15 | the entry is a pointer to another table, a literal, a length or
16 | distance, an end-of-block, or an invalid code. For a table
17 | pointer, the low four bits of op is the number of index bits of
18 | that table. For a length or distance, the low four bits of op
19 | is the number of extra bits to get after the code. bits is
20 | the number of bits in this code or part of the code to drop off
21 | of the bit buffer. val is the actual byte to output in the case
22 | of a literal, the base length or distance, or the offset from
23 | the current table to the next table. Each entry is four bytes. */
24 | typedef struct {
25 | unsigned char op; /* operation, extra bits, table bits */
26 | unsigned char bits; /* bits in this part of the code */
27 | unsigned short val; /* offset in table or code value */
28 | } code;
29 |
30 | /* op values as set by inflate_table():
31 | 00000000 - literal
32 | 0000tttt - table link, tttt != 0 is the number of table index bits
33 | 100eeeee - length or distance, eeee is the number of extra bits
34 | 01100000 - end of block
35 | 01000000 - invalid code
36 | */
37 |
38 | /* Maximum size of the dynamic table. The maximum number of code structures is
39 | 1446, which is the sum of 852 for literal/length codes and 594 for distance
40 | codes. These values were found by exhaustive searches using the program
41 | examples/enough.c found in the zlib distribtution. The arguments to that
42 | program are the number of symbols, the initial root table size, and the
43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes
44 | returns returns 852, and "enough 32 6 15" for distance codes returns 594.
45 | The initial root table size (9 or 6) is found in the fifth argument of the
46 | inflate_table() calls in infback9.c. If the root table size is changed,
47 | then these maximum sizes would be need to be recalculated and updated. */
48 | #define ENOUGH_LENS 852
49 | #define ENOUGH_DISTS 594
50 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
51 |
52 | /* Type of code to build for inflate_table9() */
53 | typedef enum {
54 | CODES,
55 | LENS,
56 | DISTS
57 | } codetype;
58 |
59 | extern int inflate_table9 OF((codetype type, unsigned short FAR *lens,
60 | unsigned codes, code FAR * FAR *table,
61 | unsigned FAR *bits, unsigned short FAR *work));
62 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/inftrees.h:
--------------------------------------------------------------------------------
1 | /* inftrees.h -- header to use inftrees.c
2 | * Copyright (C) 1995-2005, 2010 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | /* Structure for decoding tables. Each entry provides either the
12 | information needed to do the operation requested by the code that
13 | indexed that table entry, or it provides a pointer to another
14 | table that indexes more bits of the code. op indicates whether
15 | the entry is a pointer to another table, a literal, a length or
16 | distance, an end-of-block, or an invalid code. For a table
17 | pointer, the low four bits of op is the number of index bits of
18 | that table. For a length or distance, the low four bits of op
19 | is the number of extra bits to get after the code. bits is
20 | the number of bits in this code or part of the code to drop off
21 | of the bit buffer. val is the actual byte to output in the case
22 | of a literal, the base length or distance, or the offset from
23 | the current table to the next table. Each entry is four bytes. */
24 | typedef struct {
25 | unsigned char op; /* operation, extra bits, table bits */
26 | unsigned char bits; /* bits in this part of the code */
27 | unsigned short val; /* offset in table or code value */
28 | } code;
29 |
30 | /* op values as set by inflate_table():
31 | 00000000 - literal
32 | 0000tttt - table link, tttt != 0 is the number of table index bits
33 | 0001eeee - length or distance, eeee is the number of extra bits
34 | 01100000 - end of block
35 | 01000000 - invalid code
36 | */
37 |
38 | /* Maximum size of the dynamic table. The maximum number of code structures is
39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance
40 | codes. These values were found by exhaustive searches using the program
41 | examples/enough.c found in the zlib distribtution. The arguments to that
42 | program are the number of symbols, the initial root table size, and the
43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes
44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592.
45 | The initial root table size (9 or 6) is found in the fifth argument of the
46 | inflate_table() calls in inflate.c and infback.c. If the root table size is
47 | changed, then these maximum sizes would be need to be recalculated and
48 | updated. */
49 | #define ENOUGH_LENS 852
50 | #define ENOUGH_DISTS 592
51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
52 |
53 | /* Type of code to build for inflate_table() */
54 | typedef enum {
55 | CODES,
56 | LENS,
57 | DISTS
58 | } codetype;
59 |
60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
61 | unsigned codes, code FAR * FAR *table,
62 | unsigned FAR *bits, unsigned short FAR *work));
63 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/iowin32.h:
--------------------------------------------------------------------------------
1 | /* iowin32.h -- IO base function header for compress/uncompress .zip
2 | Version 1.1, February 14h, 2010
3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
4 |
5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
6 |
7 | Modifications for Zip64 support
8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
9 |
10 | For more info read MiniZip_info.txt
11 |
12 | */
13 |
14 | #include
15 |
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
22 | void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
23 | void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
24 | void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/mztools.h:
--------------------------------------------------------------------------------
1 | /*
2 | Additional tools for Minizip
3 | Code: Xavier Roche '2004
4 | License: Same as ZLIB (www.gzip.org)
5 | */
6 |
7 | #ifndef _zip_tools_H
8 | #define _zip_tools_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | #ifndef _ZLIB_H
15 | #include "zlib.h"
16 | #endif
17 |
18 | #include "unzip.h"
19 |
20 | /* Repair a ZIP file (missing central directory)
21 | file: file to recover
22 | fileOut: output file after recovery
23 | fileOutTmp: temporary file name used for recovery
24 | */
25 | extern int ZEXPORT unzRepair(const char* file,
26 | const char* fileOut,
27 | const char* fileOutTmp,
28 | uLong* nRecovered,
29 | uLong* bytesRecovered);
30 |
31 |
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 |
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/include_zlib/puff.h:
--------------------------------------------------------------------------------
1 | /* puff.h
2 | Copyright (C) 2002-2013 Mark Adler, all rights reserved
3 | version 2.3, 21 Jan 2013
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the author be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 |
21 | Mark Adler madler@alumni.caltech.edu
22 | */
23 |
24 |
25 | /*
26 | * See puff.c for purpose and usage.
27 | */
28 | #ifndef NIL
29 | # define NIL ((unsigned char *)0) /* for no output option */
30 | #endif
31 |
32 | int puff(unsigned char *dest, /* pointer to destination pointer */
33 | unsigned long *destlen, /* amount of output space */
34 | const unsigned char *source, /* pointer to source data pointer */
35 | unsigned long *sourcelen); /* amount of input available */
36 |
--------------------------------------------------------------------------------
/native-libpng/src/main/cpp/native_png.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_onzhou_opengles_color_NativeColorRenderer */
4 |
5 | #ifndef NATIVE_YUV2JPEG_H
6 | #define NATIVE_YUV2JPEG_H
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | JNIEXPORT void JNICALL loadPNGImage(JNIEnv *, jobject, jstring, jobject);
12 |
13 |
14 | #ifdef __cplusplus
15 | }
16 | #endif
17 | #endif
18 |
--------------------------------------------------------------------------------
/native-libpng/src/main/java/com/onzhou/graphic/main/NativePngActivity.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.main;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.os.AsyncTaskCompat;
6 | import android.view.SurfaceHolder;
7 | import android.view.SurfaceView;
8 |
9 | import com.onzhou.common.base.AbsBaseActivity;
10 | import com.onzhou.common.task.AssertReleaseTask;
11 | import com.onzhou.graphic.png.NativePngLoader;
12 |
13 | import java.io.File;
14 |
15 | /**
16 | * @anchor: andy
17 | * @date: 18-11-22
18 | */
19 |
20 | public class NativePngActivity extends AbsBaseActivity implements AssertReleaseTask.ReleaseCallback {
21 |
22 | private SurfaceView mSurfaceView;
23 |
24 | @Override
25 | protected void onCreate(@Nullable Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setupView();
28 | }
29 |
30 | @Override
31 | protected void onPostCreate(@Nullable Bundle savedInstanceState) {
32 | super.onPostCreate(savedInstanceState);
33 | AssertReleaseTask task = new AssertReleaseTask(this, "input.png", this);
34 | AsyncTaskCompat.executeParallel(task);
35 | }
36 |
37 | private void setupView() {
38 | mSurfaceView = new SurfaceView(this);
39 | setContentView(mSurfaceView);
40 | mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
41 | @Override
42 | public void surfaceCreated(SurfaceHolder holder) {
43 | NativePngLoader nativeImageLoader = new NativePngLoader();
44 | File file = new File(getExternalFilesDir(null), "input.png");
45 | nativeImageLoader.loadPNGImage(file.getAbsolutePath(), holder.getSurface());
46 | }
47 |
48 | @Override
49 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
50 |
51 | }
52 |
53 | @Override
54 | public void surfaceDestroyed(SurfaceHolder holder) {
55 |
56 | }
57 | });
58 | }
59 |
60 | @Override
61 | public void onReleaseComplete() {
62 |
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/native-libpng/src/main/java/com/onzhou/graphic/png/NativePngLoader.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.png;
2 |
3 | import android.view.Surface;
4 |
5 | /**
6 | * @anchor: andy
7 | * @date: 18-11-22
8 | */
9 |
10 | public class NativePngLoader {
11 |
12 | static {
13 | System.loadLibrary("native-png");
14 | }
15 |
16 | public native void loadPNGImage(String imagePath, Surface surface);
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/native-libpng/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 加载PNG图片
3 |
4 |
--------------------------------------------------------------------------------
/native-libpng/src/test/java/com/onzhou/graphic/png/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.png;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/native-libyuv/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/native-libyuv/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | cmake_minimum_required(VERSION 3.4.1)
3 |
4 | ##官方标准配置
5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")
7 |
8 | add_library(native-yuv
9 | SHARED
10 | src/main/cpp/native_yuv.cpp)
11 |
12 | add_library(yuv
13 | SHARED
14 | IMPORTED)
15 |
16 | set_target_properties(yuv
17 | PROPERTIES IMPORTED_LOCATION
18 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libyuv.so
19 | )
20 |
21 | include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include)
22 |
23 | target_link_libraries(native-yuv
24 | yuv
25 | android
26 | jnigraphics
27 | log)
28 |
--------------------------------------------------------------------------------
/native-libyuv/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 |
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", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
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 |
49 | compile project(':common')
50 | }
--------------------------------------------------------------------------------
/native-libyuv/libs/arm64-v8a/libyuv.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/libs/arm64-v8a/libyuv.so
--------------------------------------------------------------------------------
/native-libyuv/libs/armeabi-v7a/libyuv.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/libs/armeabi-v7a/libyuv.so
--------------------------------------------------------------------------------
/native-libyuv/libs/armeabi/libyuv.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/libs/armeabi/libyuv.so
--------------------------------------------------------------------------------
/native-libyuv/libs/x86/libyuv.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/libs/x86/libyuv.so
--------------------------------------------------------------------------------
/native-libyuv/libs/x86_64/libyuv.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/libs/x86_64/libyuv.so
--------------------------------------------------------------------------------
/native-libyuv/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-libyuv/src/androidTest/java/com/onzhou/graphic/libyuv/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.libyuv;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.onzhou.graphic.libyuv.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/assets/nv12.yuv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/src/main/assets/nv12.yuv
--------------------------------------------------------------------------------
/native-libyuv/src/main/assets/nv21.yuv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/src/main/assets/nv21.yuv
--------------------------------------------------------------------------------
/native-libyuv/src/main/assets/yuv420p.yuv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-libyuv/src/main/assets/yuv420p.yuv
--------------------------------------------------------------------------------
/native-libyuv/src/main/cpp/include/libyuv.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_H_
12 | #define INCLUDE_LIBYUV_H_
13 |
14 | #include "libyuv/basic_types.h"
15 | #include "libyuv/compare.h"
16 | #include "libyuv/convert.h"
17 | #include "libyuv/convert_argb.h"
18 | #include "libyuv/convert_from.h"
19 | #include "libyuv/convert_from_argb.h"
20 | #include "libyuv/cpu_id.h"
21 | #include "libyuv/mjpeg_decoder.h"
22 | #include "libyuv/planar_functions.h"
23 | #include "libyuv/rotate.h"
24 | #include "libyuv/rotate_argb.h"
25 | #include "libyuv/row.h"
26 | #include "libyuv/scale.h"
27 | #include "libyuv/scale_argb.h"
28 | #include "libyuv/scale_row.h"
29 | #include "libyuv/version.h"
30 | #include "libyuv/video_common.h"
31 |
32 | #endif // INCLUDE_LIBYUV_H_
33 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/cpp/include/libyuv/basic_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_
12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_
13 |
14 | #include // For size_t and NULL
15 |
16 | #if !defined(INT_TYPES_DEFINED) && !defined(GG_LONGLONG)
17 | #define INT_TYPES_DEFINED
18 |
19 | #if defined(_MSC_VER) && (_MSC_VER < 1600)
20 | #include // for uintptr_t on x86
21 | typedef unsigned __int64 uint64_t;
22 | typedef __int64 int64_t;
23 | typedef unsigned int uint32_t;
24 | typedef int int32_t;
25 | typedef unsigned short uint16_t;
26 | typedef short int16_t;
27 | typedef unsigned char uint8_t;
28 | typedef signed char int8_t;
29 | #else
30 | #include // for uintptr_t and C99 types
31 | #endif // defined(_MSC_VER) && (_MSC_VER < 1600)
32 | // Types are deprecated. Enable this macro for legacy types.
33 | #ifdef LIBYUV_LEGACY_TYPES
34 | typedef uint64_t uint64;
35 | typedef int64_t int64;
36 | typedef uint32_t uint32;
37 | typedef int32_t int32;
38 | typedef uint16_t uint16;
39 | typedef int16_t int16;
40 | typedef uint8_t uint8;
41 | typedef int8_t int8;
42 | #endif // LIBYUV_LEGACY_TYPES
43 | #endif // INT_TYPES_DEFINED
44 |
45 | #if !defined(LIBYUV_API)
46 | #if defined(_WIN32) || defined(__CYGWIN__)
47 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY)
48 | #define LIBYUV_API __declspec(dllexport)
49 | #elif defined(LIBYUV_USING_SHARED_LIBRARY)
50 | #define LIBYUV_API __declspec(dllimport)
51 | #else
52 | #define LIBYUV_API
53 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY
54 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \
55 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \
56 | defined(LIBYUV_USING_SHARED_LIBRARY))
57 | #define LIBYUV_API __attribute__((visibility("default")))
58 | #else
59 | #define LIBYUV_API
60 | #endif // __GNUC__
61 | #endif // LIBYUV_API
62 |
63 | // TODO(fbarchard): Remove bool macros.
64 | #define LIBYUV_BOOL int
65 | #define LIBYUV_FALSE 0
66 | #define LIBYUV_TRUE 1
67 |
68 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_
69 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/cpp/include/libyuv/compare.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_COMPARE_H_
12 | #define INCLUDE_LIBYUV_COMPARE_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | // Compute a hash for specified memory. Seed of 5381 recommended.
22 | LIBYUV_API
23 | uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed);
24 |
25 | // Hamming Distance
26 | LIBYUV_API
27 | uint64_t ComputeHammingDistance(const uint8_t* src_a,
28 | const uint8_t* src_b,
29 | int count);
30 |
31 | // Scan an opaque argb image and return fourcc based on alpha offset.
32 | // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown.
33 | LIBYUV_API
34 | uint32_t ARGBDetect(const uint8_t* argb,
35 | int stride_argb,
36 | int width,
37 | int height);
38 |
39 | // Sum Square Error - used to compute Mean Square Error or PSNR.
40 | LIBYUV_API
41 | uint64_t ComputeSumSquareError(const uint8_t* src_a,
42 | const uint8_t* src_b,
43 | int count);
44 |
45 | LIBYUV_API
46 | uint64_t ComputeSumSquareErrorPlane(const uint8_t* src_a,
47 | int stride_a,
48 | const uint8_t* src_b,
49 | int stride_b,
50 | int width,
51 | int height);
52 |
53 | static const int kMaxPsnr = 128;
54 |
55 | LIBYUV_API
56 | double SumSquareErrorToPsnr(uint64_t sse, uint64_t count);
57 |
58 | LIBYUV_API
59 | double CalcFramePsnr(const uint8_t* src_a,
60 | int stride_a,
61 | const uint8_t* src_b,
62 | int stride_b,
63 | int width,
64 | int height);
65 |
66 | LIBYUV_API
67 | double I420Psnr(const uint8_t* src_y_a,
68 | int stride_y_a,
69 | const uint8_t* src_u_a,
70 | int stride_u_a,
71 | const uint8_t* src_v_a,
72 | int stride_v_a,
73 | const uint8_t* src_y_b,
74 | int stride_y_b,
75 | const uint8_t* src_u_b,
76 | int stride_u_b,
77 | const uint8_t* src_v_b,
78 | int stride_v_b,
79 | int width,
80 | int height);
81 |
82 | LIBYUV_API
83 | double CalcFrameSsim(const uint8_t* src_a,
84 | int stride_a,
85 | const uint8_t* src_b,
86 | int stride_b,
87 | int width,
88 | int height);
89 |
90 | LIBYUV_API
91 | double I420Ssim(const uint8_t* src_y_a,
92 | int stride_y_a,
93 | const uint8_t* src_u_a,
94 | int stride_u_a,
95 | const uint8_t* src_v_a,
96 | int stride_v_a,
97 | const uint8_t* src_y_b,
98 | int stride_y_b,
99 | const uint8_t* src_u_b,
100 | int stride_u_b,
101 | const uint8_t* src_v_b,
102 | int stride_v_b,
103 | int width,
104 | int height);
105 |
106 | #ifdef __cplusplus
107 | } // extern "C"
108 | } // namespace libyuv
109 | #endif
110 |
111 | #endif // INCLUDE_LIBYUV_COMPARE_H_
112 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/cpp/include/libyuv/rotate_argb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_
12 | #define INCLUDE_LIBYUV_ROTATE_ARGB_H_
13 |
14 | #include "libyuv/basic_types.h"
15 | #include "libyuv/rotate.h" // For RotationMode.
16 |
17 | #ifdef __cplusplus
18 | namespace libyuv {
19 | extern "C" {
20 | #endif
21 |
22 | // Rotate ARGB frame
23 | LIBYUV_API
24 | int ARGBRotate(const uint8_t* src_argb,
25 | int src_stride_argb,
26 | uint8_t* dst_argb,
27 | int dst_stride_argb,
28 | int src_width,
29 | int src_height,
30 | enum RotationMode mode);
31 |
32 | #ifdef __cplusplus
33 | } // extern "C"
34 | } // namespace libyuv
35 | #endif
36 |
37 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_
38 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/cpp/include/libyuv/scale_argb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_
12 | #define INCLUDE_LIBYUV_SCALE_ARGB_H_
13 |
14 | #include "libyuv/basic_types.h"
15 | #include "libyuv/scale.h" // For FilterMode
16 |
17 | #ifdef __cplusplus
18 | namespace libyuv {
19 | extern "C" {
20 | #endif
21 |
22 | LIBYUV_API
23 | int ARGBScale(const uint8_t* src_argb,
24 | int src_stride_argb,
25 | int src_width,
26 | int src_height,
27 | uint8_t* dst_argb,
28 | int dst_stride_argb,
29 | int dst_width,
30 | int dst_height,
31 | enum FilterMode filtering);
32 |
33 | // Clipped scale takes destination rectangle coordinates for clip values.
34 | LIBYUV_API
35 | int ARGBScaleClip(const uint8_t* src_argb,
36 | int src_stride_argb,
37 | int src_width,
38 | int src_height,
39 | uint8_t* dst_argb,
40 | int dst_stride_argb,
41 | int dst_width,
42 | int dst_height,
43 | int clip_x,
44 | int clip_y,
45 | int clip_width,
46 | int clip_height,
47 | enum FilterMode filtering);
48 |
49 | // Scale with YUV conversion to ARGB and clipping.
50 | LIBYUV_API
51 | int YUVToARGBScaleClip(const uint8_t* src_y,
52 | int src_stride_y,
53 | const uint8_t* src_u,
54 | int src_stride_u,
55 | const uint8_t* src_v,
56 | int src_stride_v,
57 | uint32_t src_fourcc,
58 | int src_width,
59 | int src_height,
60 | uint8_t* dst_argb,
61 | int dst_stride_argb,
62 | uint32_t dst_fourcc,
63 | int dst_width,
64 | int dst_height,
65 | int clip_x,
66 | int clip_y,
67 | int clip_width,
68 | int clip_height,
69 | enum FilterMode filtering);
70 |
71 | #ifdef __cplusplus
72 | } // extern "C"
73 | } // namespace libyuv
74 | #endif
75 |
76 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_
77 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/cpp/include/libyuv/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_VERSION_H_
12 | #define INCLUDE_LIBYUV_VERSION_H_
13 |
14 | #define LIBYUV_VERSION 1717
15 |
16 | #endif // INCLUDE_LIBYUV_VERSION_H_
17 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/cpp/native_yuv.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_onzhou_opengles_color_NativeColorRenderer */
4 |
5 | #ifndef NATIVE_YUV_H
6 | #define NATIVE_YUV_H
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | JNIEXPORT void JNICALL yuv2rgb(JNIEnv *, jobject, jstring, jint, jint, jint, jobject);
12 |
13 | #ifdef __cplusplus
14 | }
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/java/com/onzhou/graphic/libyuv/NativeYUV.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.libyuv;
2 |
3 | import android.view.Surface;
4 |
5 | /**
6 | * @anchor: andy
7 | * @date: 18-11-23
8 | */
9 |
10 | public class NativeYUV {
11 |
12 | static {
13 | System.loadLibrary("native-yuv");
14 | }
15 |
16 | /**
17 | * 转换类型
18 | */
19 | public interface Type {
20 | int YUV420P_TO_RGB24 = 0;
21 | int NV12_TO_RGB24 = 1;
22 | int NV21_TO_RGB24 = 2;
23 | }
24 |
25 | public native void yuv2rgb(String yuvPath, int type, int width, int height, Surface surface);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/java/com/onzhou/graphic/main/NativeYUVActivity.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.main;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.os.AsyncTaskCompat;
6 | import android.view.SurfaceHolder;
7 | import android.view.SurfaceView;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Button;
11 |
12 | import com.onzhou.common.base.AbsBaseActivity;
13 | import com.onzhou.common.task.AssertReleaseTask;
14 | import com.onzhou.graphic.libyuv.NativeYUV;
15 | import com.onzhou.graphic.libyuv.R;
16 |
17 | import java.io.File;
18 |
19 | /**
20 | * @anchor: andy
21 | * @date: 2018-11-23
22 | * @description:
23 | */
24 | public class NativeYUVActivity extends AbsBaseActivity implements AssertReleaseTask.ReleaseCallback {
25 |
26 | private ViewGroup mRootLayer;
27 |
28 | private Button mBtnYuv420p, mBtnNV12, mBtnNV21;
29 |
30 | private SurfaceView mSurfaceView;
31 |
32 | private NativeYUV mNativeYUV;
33 |
34 | @Override
35 | protected void onCreate(@Nullable Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_native_yuv);
38 | }
39 |
40 | @Override
41 | protected void onPostCreate(@Nullable Bundle savedInstanceState) {
42 | super.onPostCreate(savedInstanceState);
43 | setupView();
44 | setupAsserts();
45 | }
46 |
47 | private void setupAsserts() {
48 | String[] targetFiles = {"yuv420p.yuv", "nv12.yuv", "nv21.yuv"};
49 | AssertReleaseTask task = new AssertReleaseTask(this, targetFiles, this);
50 | AsyncTaskCompat.executeParallel(task);
51 | }
52 |
53 | private void setupView() {
54 | mRootLayer = (ViewGroup) findViewById(R.id.native_yub2rgb_root_layer);
55 | mBtnYuv420p = (Button) findViewById(R.id.btn_yuv420p);
56 | mBtnNV12 = (Button) findViewById(R.id.btn_nv12);
57 | mBtnNV21 = (Button) findViewById(R.id.btn_nv21);
58 |
59 | mSurfaceView = new SurfaceView(this);
60 | mRootLayer.addView(mSurfaceView);
61 | mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
62 | @Override
63 | public void surfaceCreated(SurfaceHolder holder) {
64 | mNativeYUV = new NativeYUV();
65 | }
66 |
67 | @Override
68 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
69 |
70 | }
71 |
72 | @Override
73 | public void surfaceDestroyed(SurfaceHolder holder) {
74 |
75 | }
76 | });
77 | }
78 |
79 | public void onYUV420PToRGB24(View view) {
80 | File file = new File(getExternalFilesDir(null), "yuv420p.yuv");
81 | mNativeYUV.yuv2rgb(file.getAbsolutePath(), NativeYUV.Type.YUV420P_TO_RGB24, 510, 510, mSurfaceView.getHolder().getSurface());
82 | }
83 |
84 | public void onNV12ToRGB24(View view) {
85 | File file = new File(getExternalFilesDir(null), "nv12.yuv");
86 | mNativeYUV.yuv2rgb(file.getAbsolutePath(), NativeYUV.Type.NV12_TO_RGB24, 510, 510, mSurfaceView.getHolder().getSurface());
87 | }
88 |
89 | public void onNV21ToRGB24(View view) {
90 | File file = new File(getExternalFilesDir(null), "nv21.yuv");
91 | mNativeYUV.yuv2rgb(file.getAbsolutePath(), NativeYUV.Type.NV21_TO_RGB24, 510, 510, mSurfaceView.getHolder().getSurface());
92 | }
93 |
94 | @Override
95 | public void onReleaseComplete() {
96 | mBtnYuv420p.setEnabled(true);
97 | mBtnNV12.setEnabled(true);
98 | mBtnNV21.setEnabled(true);
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/res/layout/activity_native_yuv.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/native-libyuv/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LIBYUV
3 |
4 |
--------------------------------------------------------------------------------
/native-libyuv/src/test/java/com/onzhou/graphic/libyuv/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.libyuv;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/native-yuv2image/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/native-yuv2image/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | cmake_minimum_required(VERSION 3.4.1)
3 |
4 | ##官方标准配置
5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")
7 |
8 | ##################### libjpeg-turbo start #################################
9 |
10 | add_library(native-yuv2image
11 | SHARED
12 | src/main/cpp/native_yuv2image.cpp
13 | src/main/cpp/native_yuv2jpeg.cpp
14 | src/main/cpp/native_yuv2png.cpp
15 | src/main/cpp/native_yuvutils.cpp)
16 |
17 | add_library(jpeg
18 | SHARED
19 | IMPORTED)
20 |
21 | set_target_properties(jpeg
22 | PROPERTIES IMPORTED_LOCATION
23 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libjpeg.so
24 | )
25 |
26 | add_library(jpeg-turbo
27 | SHARED
28 | IMPORTED)
29 |
30 | set_target_properties(jpeg-turbo
31 | PROPERTIES IMPORTED_LOCATION
32 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libturbojpeg.so)
33 |
34 | #头文件
35 | include_directories(${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/include)
36 |
37 | ##################### libjpeg-turbo end #################################
38 |
39 | ##################### libpng start #################################
40 |
41 | add_library(png
42 | SHARED
43 | IMPORTED)
44 |
45 | set_target_properties(png
46 | PROPERTIES IMPORTED_LOCATION
47 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libpng.so
48 | )
49 |
50 | add_library(zip
51 | SHARED
52 | IMPORTED)
53 |
54 | set_target_properties(zip
55 | PROPERTIES IMPORTED_LOCATION
56 | ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libz.so
57 | )
58 |
59 | #PNG头文件
60 | include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include_png)
61 | include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include_zlib)
62 |
63 | ##################### libpng end #################################
64 |
65 | target_link_libraries(native-yuv2image
66 | jpeg
67 | jpeg-turbo
68 | png
69 | zip
70 | android
71 | jnigraphics
72 | log)
73 |
--------------------------------------------------------------------------------
/native-yuv2image/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 |
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 |
49 | compile project(':common')
50 | }
--------------------------------------------------------------------------------
/native-yuv2image/libs/armeabi-v7a/include/jconfig.h:
--------------------------------------------------------------------------------
1 | /* Version ID for the JPEG library.
2 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
3 | */
4 | #define JPEG_LIB_VERSION 80
5 |
6 | /* libjpeg-turbo version */
7 | #define LIBJPEG_TURBO_VERSION 2.0.1
8 |
9 | /* libjpeg-turbo version in integer form */
10 | #define LIBJPEG_TURBO_VERSION_NUMBER 2000001
11 |
12 | /* Support arithmetic encoding */
13 | #define C_ARITH_CODING_SUPPORTED 1
14 |
15 | /* Support arithmetic decoding */
16 | #define D_ARITH_CODING_SUPPORTED 1
17 |
18 | /* Support in-memory source/destination managers */
19 | /* #undef MEM_SRCDST_SUPPORTED */
20 |
21 | /* Use accelerated SIMD routines. */
22 | #define WITH_SIMD 1
23 |
24 | /*
25 | * Define BITS_IN_JSAMPLE as either
26 | * 8 for 8-bit sample values (the usual setting)
27 | * 12 for 12-bit sample values
28 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the
29 | * JPEG standard, and the IJG code does not support anything else!
30 | * We do not support run-time selection of data precision, sorry.
31 | */
32 |
33 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
34 |
35 | /* Define to 1 if you have the header file. */
36 | #define HAVE_LOCALE_H 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDDEF_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define if you need to include to get size_t. */
45 | #define NEED_SYS_TYPES_H 1
46 |
47 | /* Define if you have BSD-like bzero and bcopy in rather than
48 | memset/memcpy in . */
49 | /* #undef NEED_BSD_STRINGS */
50 |
51 | /* Define to 1 if the system has the type `unsigned char'. */
52 | #define HAVE_UNSIGNED_CHAR 1
53 |
54 | /* Define to 1 if the system has the type `unsigned short'. */
55 | #define HAVE_UNSIGNED_SHORT 1
56 |
57 | /* Compiler does not support pointers to undefined structures. */
58 | /* #undef INCOMPLETE_TYPES_BROKEN */
59 |
60 | /* Define if your (broken) compiler shifts signed values as if they were
61 | unsigned. */
62 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */
63 |
64 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */
65 | #ifndef __CHAR_UNSIGNED__
66 | /* #undef __CHAR_UNSIGNED__ */
67 | #endif
68 |
69 | /* Define to empty if `const' does not conform to ANSI C. */
70 | /* #undef const */
71 |
72 | /* Define to `unsigned int' if does not define. */
73 | /* #undef size_t */
74 |
--------------------------------------------------------------------------------
/native-yuv2image/libs/armeabi-v7a/libjpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2image/libs/armeabi-v7a/libjpeg.so
--------------------------------------------------------------------------------
/native-yuv2image/libs/armeabi-v7a/libpng.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2image/libs/armeabi-v7a/libpng.so
--------------------------------------------------------------------------------
/native-yuv2image/libs/armeabi-v7a/libturbojpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2image/libs/armeabi-v7a/libturbojpeg.so
--------------------------------------------------------------------------------
/native-yuv2image/libs/armeabi-v7a/libz.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2image/libs/armeabi-v7a/libz.so
--------------------------------------------------------------------------------
/native-yuv2image/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-yuv2image/src/androidTest/java/com/onzhou/graphic/yuv2image/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.yuv2image;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.onzhou.graphic.yuv2bmp.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/assets/input.yuv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2image/src/main/assets/input.yuv
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_png/PngFile.h:
--------------------------------------------------------------------------------
1 | /*------------------------------------------*/
2 | /* PNGFILE.H -- Header File for pngfile.c*/
3 | /*------------------------------------------*/
4 |
5 | /* Copyright 2000, Willem van Schaik.*/
6 |
7 | /* This code is released under the libpng license.*/
8 | /* For conditions of distribution and use, see the disclaimer*/
9 | /* and license in png.h*/
10 |
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | void PngFileInitialize (HWND hwnd) ;
17 | BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
18 | BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
19 |
20 | BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
21 | int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor);
22 | BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
23 | int iWidth, int iHeight, png_color BkgColor);
24 |
25 | #ifndef PNG_STDIO_SUPPORTED
26 | static void png_read_data(png_structp png_ptr, png_bytep data, size_t length);
27 | static void png_write_data(png_structp png_ptr, png_bytep data, size_t length);
28 | static void png_flush(png_structp png_ptr);
29 | #endif
30 |
31 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_png/pngusr.h:
--------------------------------------------------------------------------------
1 | /* minrdpngconf.h: headers to make a minimal png-read-only library
2 | *
3 | * Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
4 | *
5 | * This code is released under the libpng license.
6 | * For conditions of distribution and use, see the disclaimer
7 | * and license in png.h
8 | *
9 | * Derived from pngcrush.h, Copyright 1998-2007, Glenn Randers-Pehrson
10 | */
11 |
12 | #ifndef MINRDPNGCONF_H
13 | #define MINRDPNGCONF_H
14 |
15 | /* To include pngusr.h set -DPNG_USER_CONFIG in CPPFLAGS */
16 |
17 | /* List options to turn off features of the build that do not
18 | * affect the API (so are not recorded in pnglibconf.h)
19 | */
20 |
21 | #define PNG_ALIGN_TYPE PNG_ALIGN_NONE
22 |
23 | #endif /* MINRDPNGCONF_H */
24 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_png/readpng.h:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------
2 |
3 | rpng - simple PNG display program readpng.h
4 |
5 | ---------------------------------------------------------------------------
6 |
7 | Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
8 |
9 | This software is provided "as is," without warranty of any kind,
10 | express or implied. In no event shall the author or contributors
11 | be held liable for any damages arising in any way from the use of
12 | this software.
13 |
14 | The contents of this file are DUAL-LICENSED. You may modify and/or
15 | redistribute this software according to the terms of one of the
16 | following two licenses (at your option):
17 |
18 |
19 | LICENSE 1 ("BSD-like with advertising clause"):
20 |
21 | Permission is granted to anyone to use this software for any purpose,
22 | including commercial applications, and to alter it and redistribute
23 | it freely, subject to the following restrictions:
24 |
25 | 1. Redistributions of source code must retain the above copyright
26 | notice, disclaimer, and this list of conditions.
27 | 2. Redistributions in binary form must reproduce the above copyright
28 | notice, disclaimer, and this list of conditions in the documenta-
29 | tion and/or other materials provided with the distribution.
30 | 3. All advertising materials mentioning features or use of this
31 | software must display the following acknowledgment:
32 |
33 | This product includes software developed by Greg Roelofs
34 | and contributors for the book, "PNG: The Definitive Guide,"
35 | published by O'Reilly and Associates.
36 |
37 |
38 | LICENSE 2 (GNU GPL v2 or later):
39 |
40 | This program is free software; you can redistribute it and/or modify
41 | it under the terms of the GNU General Public License as published by
42 | the Free Software Foundation; either version 2 of the License, or
43 | (at your option) any later version.
44 |
45 | This program is distributed in the hope that it will be useful,
46 | but WITHOUT ANY WARRANTY; without even the implied warranty of
47 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 | GNU General Public License for more details.
49 |
50 | You should have received a copy of the GNU General Public License
51 | along with this program; if not, write to the Free Software Foundation,
52 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53 |
54 | ---------------------------------------------------------------------------*/
55 |
56 | #ifndef TRUE
57 | # define TRUE 1
58 | # define FALSE 0
59 | #endif
60 |
61 | #ifndef MAX
62 | # define MAX(a,b) ((a) > (b)? (a) : (b))
63 | # define MIN(a,b) ((a) < (b)? (a) : (b))
64 | #endif
65 |
66 | #ifdef DEBUG
67 | # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
68 | #else
69 | # define Trace(x) ;
70 | #endif
71 |
72 | typedef unsigned char uch;
73 | typedef unsigned short ush;
74 | typedef unsigned long ulg;
75 |
76 |
77 | /* prototypes for public functions in readpng.c */
78 |
79 | void readpng_version_info(void);
80 |
81 | int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight);
82 |
83 | int readpng_get_bgcolor(uch *bg_red, uch *bg_green, uch *bg_blue);
84 |
85 | uch *readpng_get_image(double display_exponent, int *pChannels,
86 | ulg *pRowbytes);
87 |
88 | void readpng_cleanup(int free_image_data);
89 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_png/readpng2.h:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------
2 |
3 | rpng2 - progressive-model PNG display program readpng2.h
4 |
5 | ---------------------------------------------------------------------------
6 |
7 | Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
8 |
9 | This software is provided "as is," without warranty of any kind,
10 | express or implied. In no event shall the author or contributors
11 | be held liable for any damages arising in any way from the use of
12 | this software.
13 |
14 | The contents of this file are DUAL-LICENSED. You may modify and/or
15 | redistribute this software according to the terms of one of the
16 | following two licenses (at your option):
17 |
18 |
19 | LICENSE 1 ("BSD-like with advertising clause"):
20 |
21 | Permission is granted to anyone to use this software for any purpose,
22 | including commercial applications, and to alter it and redistribute
23 | it freely, subject to the following restrictions:
24 |
25 | 1. Redistributions of source code must retain the above copyright
26 | notice, disclaimer, and this list of conditions.
27 | 2. Redistributions in binary form must reproduce the above copyright
28 | notice, disclaimer, and this list of conditions in the documenta-
29 | tion and/or other materials provided with the distribution.
30 | 3. All advertising materials mentioning features or use of this
31 | software must display the following acknowledgment:
32 |
33 | This product includes software developed by Greg Roelofs
34 | and contributors for the book, "PNG: The Definitive Guide,"
35 | published by O'Reilly and Associates.
36 |
37 |
38 | LICENSE 2 (GNU GPL v2 or later):
39 |
40 | This program is free software; you can redistribute it and/or modify
41 | it under the terms of the GNU General Public License as published by
42 | the Free Software Foundation; either version 2 of the License, or
43 | (at your option) any later version.
44 |
45 | This program is distributed in the hope that it will be useful,
46 | but WITHOUT ANY WARRANTY; without even the implied warranty of
47 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 | GNU General Public License for more details.
49 |
50 | You should have received a copy of the GNU General Public License
51 | along with this program; if not, write to the Free Software Foundation,
52 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53 |
54 | ---------------------------------------------------------------------------*/
55 |
56 | #ifndef TRUE
57 | # define TRUE 1
58 | # define FALSE 0
59 | #endif
60 |
61 | #ifndef MAX
62 | # define MAX(a,b) ((a) > (b)? (a) : (b))
63 | # define MIN(a,b) ((a) < (b)? (a) : (b))
64 | #endif
65 |
66 | #ifdef DEBUG
67 | # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
68 | #else
69 | # define Trace(x) ;
70 | #endif
71 |
72 | enum rpng2_states {
73 | kPreInit = 0,
74 | kWindowInit,
75 | kDone
76 | };
77 |
78 | typedef unsigned char uch;
79 | typedef unsigned short ush;
80 | typedef unsigned long ulg;
81 |
82 | typedef struct _mainprog_info {
83 | double display_exponent;
84 | ulg width;
85 | ulg height;
86 | void *png_ptr;
87 | void *info_ptr;
88 | void (*mainprog_init)(void);
89 | void (*mainprog_display_row)(ulg row_num);
90 | void (*mainprog_finish_display)(void);
91 | uch *image_data;
92 | uch **row_pointers;
93 | jmp_buf jmpbuf;
94 | int passes; /* not used */
95 | int pass;
96 | int rowbytes;
97 | int channels;
98 | int need_bgcolor;
99 | int state;
100 | uch bg_red;
101 | uch bg_green;
102 | uch bg_blue;
103 | } mainprog_info;
104 |
105 |
106 | /* prototypes for public functions in readpng2.c */
107 |
108 | void readpng2_version_info(void);
109 |
110 | int readpng2_check_sig(uch *sig, int num);
111 |
112 | int readpng2_init(mainprog_info *mainprog_ptr);
113 |
114 | int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length);
115 |
116 | void readpng2_cleanup(mainprog_info *mainprog_ptr);
117 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_png/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by VisualPng.rc
4 | //
5 | #define IDM_FILE_OPEN 40001
6 | #define IDM_FILE_SAVE 40002
7 | #define IDM_FILE_NEXT 40003
8 | #define IDM_FILE_PREVIOUS 40004
9 | #define IDM_FILE_EXIT 40005
10 | #define IDM_OPTIONS_BACKGROUND 40006
11 | #define IDM_OPTIONS_STRETCH 40007
12 | #define IDM_HELP_ABOUT 40008
13 |
14 | // Next default values for new objects
15 | //
16 | #ifdef APSTUDIO_INVOKED
17 | #ifndef APSTUDIO_READONLY_SYMBOLS
18 | #define _APS_NEXT_RESOURCE_VALUE 113
19 | #define _APS_NEXT_COMMAND_VALUE 40009
20 | #define _APS_NEXT_CONTROL_VALUE 1001
21 | #define _APS_NEXT_SYMED_VALUE 101
22 | #endif
23 | #endif
24 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_png/sRGB.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * sRGB.h
3 | *
4 | * Last changed in libpng 1.6.0 [February 14, 2013]
5 | *
6 | * COPYRIGHT: Written by John Cunningham Bowler, 2013.
7 | * To the extent possible under law, the author has waived all copyright and
8 | * related or neighboring rights to this work. This work is published from:
9 | * United States.
10 | *
11 | * Utility file; not actually a header, this contains definitions of sRGB
12 | * calculation functions for inclusion in those test programs that need them.
13 | *
14 | * All routines take and return a floating point value in the range
15 | * 0 to 1.0, doing a calculation according to the sRGB specification
16 | * (in fact the source of the numbers is the wikipedia article at
17 | * https://en.wikipedia.org/wiki/SRGB).
18 | */
19 | static double
20 | sRGB_from_linear(double l)
21 | {
22 | if (l <= 0.0031308)
23 | l *= 12.92;
24 |
25 | else
26 | l = 1.055 * pow(l, 1/2.4) - 0.055;
27 |
28 | return l;
29 | }
30 |
31 | static double
32 | linear_from_sRGB(double s)
33 | {
34 | if (s <= 0.04045)
35 | return s / 12.92;
36 |
37 | else
38 | return pow((s+0.055)/1.055, 2.4);
39 | }
40 |
41 | static double
42 | YfromRGB(double r, double g, double b)
43 | {
44 | /* Use the sRGB (rounded) coefficients for Rlinear, Glinear, Blinear to get
45 | * the CIE Y value (also linear).
46 | */
47 | return 0.2126 * r + 0.7152 * g + 0.0722 * b;
48 | }
49 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/blast.h:
--------------------------------------------------------------------------------
1 | /* blast.h -- interface for blast.c
2 | Copyright (C) 2003, 2012, 2013 Mark Adler
3 | version 1.3, 24 Aug 2013
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the author be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 |
21 | Mark Adler madler@alumni.caltech.edu
22 | */
23 |
24 |
25 | /*
26 | * blast() decompresses the PKWare Data Compression Library (DCL) compressed
27 | * format. It provides the same functionality as the explode() function in
28 | * that library. (Note: PKWare overused the "implode" verb, and the format
29 | * used by their library implode() function is completely different and
30 | * incompatible with the implode compression method supported by PKZIP.)
31 | *
32 | * The binary mode for stdio functions should be used to assure that the
33 | * compressed data is not corrupted when read or written. For example:
34 | * fopen(..., "rb") and fopen(..., "wb").
35 | */
36 |
37 |
38 | typedef unsigned (*blast_in)(void *how, unsigned char **buf);
39 | typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len);
40 | /* Definitions for input/output functions passed to blast(). See below for
41 | * what the provided functions need to do.
42 | */
43 |
44 |
45 | int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
46 | unsigned *left, unsigned char **in);
47 | /* Decompress input to output using the provided infun() and outfun() calls.
48 | * On success, the return value of blast() is zero. If there is an error in
49 | * the source data, i.e. it is not in the proper format, then a negative value
50 | * is returned. If there is not enough input available or there is not enough
51 | * output space, then a positive error is returned.
52 | *
53 | * The input function is invoked: len = infun(how, &buf), where buf is set by
54 | * infun() to point to the input buffer, and infun() returns the number of
55 | * available bytes there. If infun() returns zero, then blast() returns with
56 | * an input error. (blast() only asks for input if it needs it.) inhow is for
57 | * use by the application to pass an input descriptor to infun(), if desired.
58 | *
59 | * If left and in are not NULL and *left is not zero when blast() is called,
60 | * then the *left bytes are *in are consumed for input before infun() is used.
61 | *
62 | * The output function is invoked: err = outfun(how, buf, len), where the bytes
63 | * to be written are buf[0..len-1]. If err is not zero, then blast() returns
64 | * with an output error. outfun() is always called with len <= 4096. outhow
65 | * is for use by the application to pass an output descriptor to outfun(), if
66 | * desired.
67 | *
68 | * If there is any unused input, *left is set to the number of bytes that were
69 | * read and *in points to them. Otherwise *left is set to zero and *in is set
70 | * to NULL. If left or in are NULL, then they are not set.
71 | *
72 | * The return codes are:
73 | *
74 | * 2: ran out of input before completing decompression
75 | * 1: output error before completing decompression
76 | * 0: successful decompression
77 | * -1: literal flag not zero or one
78 | * -2: dictionary size not in 4..6
79 | * -3: distance is too far back
80 | *
81 | * At the bottom of blast.c is an example program that uses blast() that can be
82 | * compiled to produce a command-line decompression filter by defining TEST.
83 | */
84 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/infback9.h:
--------------------------------------------------------------------------------
1 | /* infback9.h -- header for using inflateBack9 functions
2 | * Copyright (C) 2003 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /*
7 | * This header file and associated patches provide a decoder for PKWare's
8 | * undocumented deflate64 compression method (method 9). Use with infback9.c,
9 | * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported.
10 | * This should be compiled with zlib, since it uses zutil.h and zutil.o.
11 | * This code has not yet been tested on 16-bit architectures. See the
12 | * comments in zlib.h for inflateBack() usage. These functions are used
13 | * identically, except that there is no windowBits parameter, and a 64K
14 | * window must be provided. Also if int's are 16 bits, then a zero for
15 | * the third parameter of the "out" function actually means 65536UL.
16 | * zlib.h must be included before this header file.
17 | */
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm,
24 | in_func in, void FAR *in_desc,
25 | out_func out, void FAR *out_desc));
26 | ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm));
27 | ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm,
28 | unsigned char FAR *window,
29 | const char *version,
30 | int stream_size));
31 | #define inflateBack9Init(strm, window) \
32 | inflateBack9Init_((strm), (window), \
33 | ZLIB_VERSION, sizeof(z_stream))
34 |
35 | #ifdef __cplusplus
36 | }
37 | #endif
38 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/inffast.h:
--------------------------------------------------------------------------------
1 | /* inffast.h -- header to use inffast.c
2 | * Copyright (C) 1995-2003, 2010 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
12 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/inflate9.h:
--------------------------------------------------------------------------------
1 | /* inflate9.h -- internal inflate state definition
2 | * Copyright (C) 1995-2003 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | /* Possible inflate modes between inflate() calls */
12 | typedef enum {
13 | TYPE, /* i: waiting for type bits, including last-flag bit */
14 | STORED, /* i: waiting for stored size (length and complement) */
15 | TABLE, /* i: waiting for dynamic block table lengths */
16 | LEN, /* i: waiting for length/lit code */
17 | DONE, /* finished check, done -- remain here until reset */
18 | BAD /* got a data error -- remain here until reset */
19 | } inflate_mode;
20 |
21 | /*
22 | State transitions between above modes -
23 |
24 | (most modes can go to the BAD mode -- not shown for clarity)
25 |
26 | Read deflate blocks:
27 | TYPE -> STORED or TABLE or LEN or DONE
28 | STORED -> TYPE
29 | TABLE -> LENLENS -> CODELENS -> LEN
30 | Read deflate codes:
31 | LEN -> LEN or TYPE
32 | */
33 |
34 | /* state maintained between inflate() calls. Approximately 7K bytes. */
35 | struct inflate_state {
36 | /* sliding window */
37 | unsigned char FAR *window; /* allocated sliding window, if needed */
38 | /* dynamic table building */
39 | unsigned ncode; /* number of code length code lengths */
40 | unsigned nlen; /* number of length code lengths */
41 | unsigned ndist; /* number of distance code lengths */
42 | unsigned have; /* number of code lengths in lens[] */
43 | code FAR *next; /* next available space in codes[] */
44 | unsigned short lens[320]; /* temporary storage for code lengths */
45 | unsigned short work[288]; /* work area for code table building */
46 | code codes[ENOUGH]; /* space for code tables */
47 | };
48 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/inftree9.h:
--------------------------------------------------------------------------------
1 | /* inftree9.h -- header to use inftree9.c
2 | * Copyright (C) 1995-2008 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | /* Structure for decoding tables. Each entry provides either the
12 | information needed to do the operation requested by the code that
13 | indexed that table entry, or it provides a pointer to another
14 | table that indexes more bits of the code. op indicates whether
15 | the entry is a pointer to another table, a literal, a length or
16 | distance, an end-of-block, or an invalid code. For a table
17 | pointer, the low four bits of op is the number of index bits of
18 | that table. For a length or distance, the low four bits of op
19 | is the number of extra bits to get after the code. bits is
20 | the number of bits in this code or part of the code to drop off
21 | of the bit buffer. val is the actual byte to output in the case
22 | of a literal, the base length or distance, or the offset from
23 | the current table to the next table. Each entry is four bytes. */
24 | typedef struct {
25 | unsigned char op; /* operation, extra bits, table bits */
26 | unsigned char bits; /* bits in this part of the code */
27 | unsigned short val; /* offset in table or code value */
28 | } code;
29 |
30 | /* op values as set by inflate_table():
31 | 00000000 - literal
32 | 0000tttt - table link, tttt != 0 is the number of table index bits
33 | 100eeeee - length or distance, eeee is the number of extra bits
34 | 01100000 - end of block
35 | 01000000 - invalid code
36 | */
37 |
38 | /* Maximum size of the dynamic table. The maximum number of code structures is
39 | 1446, which is the sum of 852 for literal/length codes and 594 for distance
40 | codes. These values were found by exhaustive searches using the program
41 | examples/enough.c found in the zlib distribtution. The arguments to that
42 | program are the number of symbols, the initial root table size, and the
43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes
44 | returns returns 852, and "enough 32 6 15" for distance codes returns 594.
45 | The initial root table size (9 or 6) is found in the fifth argument of the
46 | inflate_table() calls in infback9.c. If the root table size is changed,
47 | then these maximum sizes would be need to be recalculated and updated. */
48 | #define ENOUGH_LENS 852
49 | #define ENOUGH_DISTS 594
50 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
51 |
52 | /* Type of code to build for inflate_table9() */
53 | typedef enum {
54 | CODES,
55 | LENS,
56 | DISTS
57 | } codetype;
58 |
59 | extern int inflate_table9 OF((codetype type, unsigned short FAR *lens,
60 | unsigned codes, code FAR * FAR *table,
61 | unsigned FAR *bits, unsigned short FAR *work));
62 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/inftrees.h:
--------------------------------------------------------------------------------
1 | /* inftrees.h -- header to use inftrees.c
2 | * Copyright (C) 1995-2005, 2010 Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* WARNING: this file should *not* be used by applications. It is
7 | part of the implementation of the compression library and is
8 | subject to change. Applications should only use zlib.h.
9 | */
10 |
11 | /* Structure for decoding tables. Each entry provides either the
12 | information needed to do the operation requested by the code that
13 | indexed that table entry, or it provides a pointer to another
14 | table that indexes more bits of the code. op indicates whether
15 | the entry is a pointer to another table, a literal, a length or
16 | distance, an end-of-block, or an invalid code. For a table
17 | pointer, the low four bits of op is the number of index bits of
18 | that table. For a length or distance, the low four bits of op
19 | is the number of extra bits to get after the code. bits is
20 | the number of bits in this code or part of the code to drop off
21 | of the bit buffer. val is the actual byte to output in the case
22 | of a literal, the base length or distance, or the offset from
23 | the current table to the next table. Each entry is four bytes. */
24 | typedef struct {
25 | unsigned char op; /* operation, extra bits, table bits */
26 | unsigned char bits; /* bits in this part of the code */
27 | unsigned short val; /* offset in table or code value */
28 | } code;
29 |
30 | /* op values as set by inflate_table():
31 | 00000000 - literal
32 | 0000tttt - table link, tttt != 0 is the number of table index bits
33 | 0001eeee - length or distance, eeee is the number of extra bits
34 | 01100000 - end of block
35 | 01000000 - invalid code
36 | */
37 |
38 | /* Maximum size of the dynamic table. The maximum number of code structures is
39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance
40 | codes. These values were found by exhaustive searches using the program
41 | examples/enough.c found in the zlib distribtution. The arguments to that
42 | program are the number of symbols, the initial root table size, and the
43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes
44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592.
45 | The initial root table size (9 or 6) is found in the fifth argument of the
46 | inflate_table() calls in inflate.c and infback.c. If the root table size is
47 | changed, then these maximum sizes would be need to be recalculated and
48 | updated. */
49 | #define ENOUGH_LENS 852
50 | #define ENOUGH_DISTS 592
51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
52 |
53 | /* Type of code to build for inflate_table() */
54 | typedef enum {
55 | CODES,
56 | LENS,
57 | DISTS
58 | } codetype;
59 |
60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
61 | unsigned codes, code FAR * FAR *table,
62 | unsigned FAR *bits, unsigned short FAR *work));
63 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/iowin32.h:
--------------------------------------------------------------------------------
1 | /* iowin32.h -- IO base function header for compress/uncompress .zip
2 | Version 1.1, February 14h, 2010
3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
4 |
5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
6 |
7 | Modifications for Zip64 support
8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
9 |
10 | For more info read MiniZip_info.txt
11 |
12 | */
13 |
14 | #include
15 |
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
22 | void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
23 | void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
24 | void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/mztools.h:
--------------------------------------------------------------------------------
1 | /*
2 | Additional tools for Minizip
3 | Code: Xavier Roche '2004
4 | License: Same as ZLIB (www.gzip.org)
5 | */
6 |
7 | #ifndef _zip_tools_H
8 | #define _zip_tools_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | #ifndef _ZLIB_H
15 | #include "zlib.h"
16 | #endif
17 |
18 | #include "unzip.h"
19 |
20 | /* Repair a ZIP file (missing central directory)
21 | file: file to recover
22 | fileOut: output file after recovery
23 | fileOutTmp: temporary file name used for recovery
24 | */
25 | extern int ZEXPORT unzRepair(const char* file,
26 | const char* fileOut,
27 | const char* fileOutTmp,
28 | uLong* nRecovered,
29 | uLong* bytesRecovered);
30 |
31 |
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 |
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/include_zlib/puff.h:
--------------------------------------------------------------------------------
1 | /* puff.h
2 | Copyright (C) 2002-2013 Mark Adler, all rights reserved
3 | version 2.3, 21 Jan 2013
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the author be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 |
21 | Mark Adler madler@alumni.caltech.edu
22 | */
23 |
24 |
25 | /*
26 | * See puff.c for purpose and usage.
27 | */
28 | #ifndef NIL
29 | # define NIL ((unsigned char *)0) /* for no output option */
30 | #endif
31 |
32 | int puff(unsigned char *dest, /* pointer to destination pointer */
33 | unsigned long *destlen, /* amount of output space */
34 | const unsigned char *source, /* pointer to source data pointer */
35 | unsigned long *sourcelen); /* amount of input available */
36 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuv2image.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "native_yuv2image.h"
10 | #include "native_yuv2jpeg.h"
11 | #include "native_yuv2png.h"
12 |
13 |
14 | /**
15 | * 动态注册
16 | */
17 | JNINativeMethod methods[] = {
18 | {"yuv2jpeg", "(Ljava/lang/String;Ljava/lang/String;II)V", (void *) yuv2jpeg},
19 | {"yuv2png", "(Ljava/lang/String;Ljava/lang/String;II)V", (void *) yuv2png}
20 | };
21 |
22 | /**
23 | * 动态注册
24 | * @param env
25 | * @return
26 | */
27 | jint registerNativeMethod(JNIEnv *env) {
28 | jclass cl = env->FindClass("com/onzhou/graphic/yuv2image/NativeYUV2IMAGE");
29 | if ((env->RegisterNatives(cl, methods, sizeof(methods) / sizeof(methods[0]))) < 0) {
30 | return -1;
31 | }
32 | return 0;
33 | }
34 |
35 | /**
36 | * 加载默认回调
37 | * @param vm
38 | * @param reserved
39 | * @return
40 | */
41 | jint JNI_OnLoad(JavaVM *vm, void *reserved) {
42 | JNIEnv *env = NULL;
43 | if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) {
44 | return -1;
45 | }
46 | //注册方法
47 | if (registerNativeMethod(env) != JNI_OK) {
48 | return -1;
49 | }
50 | return JNI_VERSION_1_6;
51 | }
52 |
53 | void
54 | yuv2jpeg(JNIEnv *env, jobject obj, jstring jyuvPath, jstring jjpegPath, jint width, jint height) {
55 |
56 | const char *yuvPath = env->GetStringUTFChars(jyuvPath, 0);
57 | const char *jpegPath = env->GetStringUTFChars(jjpegPath, 0);
58 |
59 | YUV2JPEG::YUV420P_TO_JPEG(yuvPath, jpegPath, width, height);
60 |
61 | env->ReleaseStringUTFChars(jyuvPath, yuvPath);
62 | env->ReleaseStringUTFChars(jjpegPath, jpegPath);
63 | }
64 |
65 | void
66 | yuv2png(JNIEnv *env, jobject obj, jstring jyuvPath, jstring jjpegPath, jint width, jint height) {
67 |
68 | const char *yuvPath = env->GetStringUTFChars(jyuvPath, 0);
69 | const char *jpegPath = env->GetStringUTFChars(jjpegPath, 0);
70 |
71 | YUV2PNG::YUV420P_TO_PNG(yuvPath, jpegPath, width, height);
72 |
73 | env->ReleaseStringUTFChars(jyuvPath, yuvPath);
74 | env->ReleaseStringUTFChars(jjpegPath, jpegPath);
75 | }
76 |
77 |
78 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuv2image.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_onzhou_opengles_color_NativeColorRenderer */
4 |
5 | #ifndef NATIVE_YUV2JPEG_H
6 | #define NATIVE_YUV2JPEG_H
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | JNIEXPORT void JNICALL yuv2jpeg(JNIEnv *, jobject, jstring, jstring, jint, jint);
12 |
13 | JNIEXPORT void JNICALL yuv2png(JNIEnv *, jobject, jstring, jstring, jint, jint);
14 |
15 |
16 | #ifdef __cplusplus
17 | }
18 | #endif
19 | #endif
20 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuv2jpeg.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include "native_yuv2jpeg.h"
4 | #include "native_yuvutils.h"
5 | #include "jpeglib.h"
6 |
7 |
8 | int YUV2JPEG::RGB24_TO_JPEG(const char *filename, u_char *rgbData, int image_width,
9 | int image_height,
10 | int quality) {
11 | jpeg_compress_struct jpegCompress;
12 | jpeg_error_mgr jpegError;
13 |
14 | jpegCompress.err = jpeg_std_error(&jpegError);
15 | //初始化压缩对象
16 | jpeg_create_compress(&jpegCompress);
17 |
18 | FILE *pFile = fopen(filename, "wb");
19 | if (pFile == NULL) {
20 | return -1;
21 | }
22 |
23 | jpeg_stdio_dest(&jpegCompress, pFile);
24 |
25 | //设置压缩参数
26 | jpegCompress.client_data = &pFile;
27 | jpegCompress.image_width = image_width;
28 | jpegCompress.image_height = image_height;
29 | jpegCompress.input_components = 3;
30 | jpegCompress.in_color_space = JCS_RGB;
31 | jpeg_set_defaults(&jpegCompress);
32 | //指定亮度及色度质量
33 | jpegCompress.q_scale_factor[0] = jpeg_quality_scaling(100);
34 | jpegCompress.q_scale_factor[1] = jpeg_quality_scaling(100);
35 | //图像采样率,默认为2 * 2
36 | jpegCompress.comp_info[0].v_samp_factor = 2;
37 | jpegCompress.comp_info[0].h_samp_factor = 2;
38 | //设置压缩质量
39 | jpeg_set_quality(&jpegCompress, quality, TRUE); //100 is the highest
40 |
41 | //开始压缩图片
42 | jpeg_start_compress(&jpegCompress, TRUE);
43 |
44 | JSAMPROW row_pointer[1];
45 |
46 | //从上到下,设置每一个像素
47 | for (unsigned int i = 0; i < jpegCompress.image_height; i++) {
48 | row_pointer[0] = rgbData + i * jpegCompress.image_width * 3;
49 | jpeg_write_scanlines(&jpegCompress, row_pointer, 1);
50 | }
51 | //完成压缩
52 | jpeg_finish_compress(&jpegCompress);
53 |
54 | fclose(pFile);
55 | pFile = NULL;
56 | jpeg_destroy_compress(&jpegCompress);
57 | return 0;
58 |
59 | }
60 |
61 | void YUV2JPEG::YUV420P_TO_JPEG(const char *yuvPath, const char *jpegPath, int width, int height) {
62 | FILE *file = fopen(yuvPath, "rb");
63 |
64 | unsigned char *yuv420p = new unsigned char[width * height * 3 / 2];
65 |
66 | fread(yuv420p, 1, width * height * 3 / 2, file);
67 |
68 | unsigned char *rgb24 = new unsigned char[width * height * 3];
69 |
70 | //YUV420P转RGB24
71 | yuvutils::YUV420P_TO_RGB24(yuv420p, rgb24, width, height);
72 |
73 | RGB24_TO_JPEG(jpegPath, rgb24, width, height, 100);
74 |
75 | //释放内存
76 | delete[] yuv420p;
77 | delete[] rgb24;
78 |
79 | //关闭文件句柄
80 | fclose(file);
81 | }
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuv2jpeg.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by byhook on 18-11-24.
3 | //
4 |
5 | #ifndef GRAPHIC4ANDROID_NATIVE_YUV2JPEG_H
6 | #define GRAPHIC4ANDROID_NATIVE_YUV2JPEG_H
7 |
8 |
9 | #include
10 |
11 | namespace YUV2JPEG {
12 |
13 |
14 | int
15 | RGB24_TO_JPEG(const char *filename, u_char *rgbData, int image_width, int image_height,
16 | int quality);
17 |
18 | void YUV420P_TO_JPEG(const char *yuvPath, const char *jpegPath, int width, int height);
19 |
20 | };
21 |
22 |
23 | #endif //GRAPHIC4ANDROID_NATIVE_YUV2JPEG_H
24 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuv2png.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by byhook on 18-11-24.
3 | //
4 |
5 | #include
6 | #include "native_yuv2png.h"
7 | #include "native_yuvutils.h"
8 | #include "include_png/png.h"
9 |
10 |
11 | bool YUV2PNG::RGB24_TO_PNG(const char *filename, u_char *rgbData, int width, int height,
12 | int quality) {
13 | FILE *fp;
14 | png_structp png_ptr = NULL;
15 | png_infop info_ptr = NULL;
16 | fp = fopen(filename, "wb");
17 | if (fp) {
18 | png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
19 | info_ptr = png_create_info_struct(png_ptr);
20 | if (png_ptr == NULL || info_ptr == NULL) {
21 | fclose(fp);
22 | return false;
23 | }
24 | png_init_io(png_ptr, fp);
25 | png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
26 | PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
27 | png_write_info(png_ptr, info_ptr);
28 | png_set_packing(png_ptr);
29 | uint8_t *data = new uint8_t[width * 3];
30 | memset(data, 255, width * 3);
31 | int nv_start = width * height;
32 | uint32_t rgb_index = 0, pos;
33 | int r, g, b, nv_index, y, ru, rv;
34 | for (uint32_t i = 0; i < height; ++i) {
35 | for (uint32_t j = 0; j < width; ++j) {
36 | data[j * 3 + 0] = rgbData[rgb_index++];
37 | data[j * 3 + 1] = rgbData[rgb_index++];
38 | data[j * 3 + 2] = rgbData[rgb_index++];
39 | }
40 | png_write_row(png_ptr, data);
41 | }
42 |
43 | delete data;
44 | png_write_end(png_ptr, info_ptr);
45 | png_destroy_write_struct(&png_ptr, &info_ptr);
46 | fclose(fp);
47 | return true;
48 | }
49 | return false;
50 | }
51 |
52 |
53 | void YUV2PNG::YUV420P_TO_PNG(const char *yuvPath, const char *pngPath, int width, int height) {
54 | FILE *file = fopen(yuvPath, "rb");
55 |
56 | unsigned char *yuv420p = new unsigned char[width * height * 3 / 2];
57 |
58 | fread(yuv420p, 1, width * height * 3 / 2, file);
59 |
60 | unsigned char *rgb24 = new unsigned char[width * height * 3];
61 |
62 | //YUV420P转RGB24
63 | yuvutils::YUV420P_TO_RGB24(yuv420p, rgb24, width, height);
64 |
65 | //RGB24转PNG文件
66 | RGB24_TO_PNG(pngPath, rgb24, width, height, 100);
67 |
68 | //释放内存
69 | delete[] yuv420p;
70 | delete[] rgb24;
71 |
72 | //关闭文件句柄
73 | fclose(file);
74 | }
75 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuv2png.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by byhook on 18-11-24.
3 | //
4 |
5 | #ifndef GRAPHIC4ANDROID_NATIVE_YUV2PNG_H
6 | #define GRAPHIC4ANDROID_NATIVE_YUV2PNG_H
7 |
8 |
9 | #include
10 |
11 | namespace YUV2PNG {
12 |
13 |
14 | bool
15 | RGB24_TO_PNG(const char *filename, u_char *rgbData, int image_width, int image_height,
16 | int quality);
17 |
18 | void YUV420P_TO_PNG(const char *yuvPath, const char *pngPath, int width, int height);
19 |
20 | };
21 |
22 |
23 | #endif //GRAPHIC4ANDROID_NATIVE_YUV2PNG_H
24 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuvutils.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by byhook on 18-11-24.
3 | //
4 |
5 | #include
6 | #include "native_yuvutils.h"
7 |
8 | void yuvutils::YUV420P_TO_RGB24(unsigned char *yuv420p, unsigned char *rgb24, int width, int height) {
9 | int index = 0;
10 | for (int y = 0; y < height; y++) {
11 | for (int x = 0; x < width; x++) {
12 |
13 | int indexY = y * width + x;
14 | int indexU = width * height + y / 2 * width / 2 + x / 2;
15 | int indexV = width * height + width * height / 4 + y / 2 * width / 2 + x / 2;
16 |
17 | u_char Y = yuv420p[indexY];
18 | u_char U = yuv420p[indexU];
19 | u_char V = yuv420p[indexV];
20 |
21 | rgb24[index++] = Y + 1.402 * (V - 128); //R
22 | rgb24[index++] = Y - 0.34413 * (U - 128) - 0.71414 * (V - 128); //G
23 | rgb24[index++] = Y + 1.772 * (U - 128); //B
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/cpp/native_yuvutils.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by byhook on 18-11-24.
3 | //
4 |
5 | #ifndef GRAPHIC4ANDROID_NATIVE_YUVUTILS_H
6 | #define GRAPHIC4ANDROID_NATIVE_YUVUTILS_H
7 |
8 |
9 | namespace yuvutils {
10 |
11 | void YUV420P_TO_RGB24(unsigned char *yuv420p, unsigned char *rgb24, int width, int height);
12 |
13 | };
14 |
15 |
16 | #endif //GRAPHIC4ANDROID_NATIVE_YUVUTILS_H
17 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/java/com/onzhou/graphic/main/NativeGraphicActivity.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.main;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.os.AsyncTaskCompat;
6 | import android.view.View;
7 |
8 | import com.onzhou.common.base.AbsBaseActivity;
9 | import com.onzhou.common.task.AssertReleaseTask;
10 | import com.onzhou.graphic.yuv2image.NativeYUV2IMAGE;
11 | import com.onzhou.graphic.yuv2image.R;
12 |
13 | import java.io.File;
14 |
15 | /**
16 | * @anchor: andy
17 | * @date: 18-11-23
18 | */
19 |
20 | public class NativeGraphicActivity extends AbsBaseActivity implements AssertReleaseTask.ReleaseCallback {
21 |
22 | @Override
23 | protected void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_native_yuv2image);
26 | }
27 |
28 | @Override
29 | protected void onPostCreate(@Nullable Bundle savedInstanceState) {
30 | super.onPostCreate(savedInstanceState);
31 | AssertReleaseTask task = new AssertReleaseTask(this, "input.yuv", this);
32 | AsyncTaskCompat.executeParallel(task);
33 | }
34 |
35 | public void onTransferJPEG(View view) {
36 | NativeYUV2IMAGE yuv420p2jpeg = new NativeYUV2IMAGE();
37 | File yuvFile = new File(getExternalFilesDir(null), "input.yuv");
38 | File jpegFile = new File(getExternalFilesDir(null), "output.jpeg");
39 | yuv420p2jpeg.yuv2jpeg(yuvFile.getAbsolutePath(), jpegFile.getAbsolutePath(), 510, 510);
40 | }
41 |
42 | public void onTransferPNG(View view){
43 | NativeYUV2IMAGE yuv2image = new NativeYUV2IMAGE();
44 | File yuvFile = new File(getExternalFilesDir(null), "input.yuv");
45 | File jpegFile = new File(getExternalFilesDir(null), "output.png");
46 | yuv2image.yuv2png(yuvFile.getAbsolutePath(), jpegFile.getAbsolutePath(), 510, 510);
47 | }
48 |
49 | @Override
50 | public void onReleaseComplete() {
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/java/com/onzhou/graphic/yuv2image/NativeYUV2IMAGE.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.yuv2image;
2 |
3 | /**
4 | * @anchor: andy
5 | * @date: 18-11-23
6 | */
7 |
8 | public class NativeYUV2IMAGE {
9 |
10 | static {
11 | System.loadLibrary("native-yuv2image");
12 | }
13 |
14 | public native void yuv2jpeg(String yuvPath, String jpegPath, int width, int height);
15 |
16 | public native void yuv2png(String yuvPath, String pngPath, int width, int height);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/res/layout/activity_native_yuv2image.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/native-yuv2image/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | YUV2IMAGE
3 |
4 |
--------------------------------------------------------------------------------
/native-yuv2image/src/test/java/com/onzhou/graphic/yuv2image/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.yuv2image;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/native-yuv2rgb/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/native-yuv2rgb/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | cmake_minimum_required(VERSION 3.4.1)
3 |
4 | ##官方标准配置
5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")
7 |
8 | add_library(native-yuv2rgb
9 | SHARED
10 | src/main/cpp/native_yuv2rgb.cpp)
11 |
12 | target_link_libraries(native-yuv2rgb
13 | android
14 | jnigraphics
15 | log)
16 |
--------------------------------------------------------------------------------
/native-yuv2rgb/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 |
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", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
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 |
49 | compile project(':common')
50 | }
--------------------------------------------------------------------------------
/native-yuv2rgb/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-yuv2rgb/src/androidTest/java/com/onzhou/graphic/yuv2rgb/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.yuv2rgb;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.onzhou.graphic.yuv2rgb.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/assets/nv12.yuv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2rgb/src/main/assets/nv12.yuv
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/assets/nv21.yuv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2rgb/src/main/assets/nv21.yuv
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/assets/yuv420p.yuv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/byhook/graphic4android/de74b9330538b330cb7894834c5c179d519abe72/native-yuv2rgb/src/main/assets/yuv420p.yuv
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/cpp/native_yuv2rgb.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_onzhou_opengles_color_NativeColorRenderer */
4 |
5 | #ifndef COM_ONZHOU_OPENGLES_COLOR_NATIVECOLORRENDERER
6 | #define COM_ONZHOU_OPENGLES_COLOR_NATIVECOLORRENDERER
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | JNIEXPORT void JNICALL yuv2rgb(JNIEnv *, jobject, jstring, jint, jint, jint, jobject);
12 |
13 | #ifdef __cplusplus
14 | }
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/java/com/onzhou/graphic/main/NativeYUV2RGBActivity.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.main;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.os.AsyncTaskCompat;
6 | import android.view.SurfaceHolder;
7 | import android.view.SurfaceView;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Button;
11 |
12 | import com.onzhou.common.base.AbsBaseActivity;
13 | import com.onzhou.common.task.AssertReleaseTask;
14 | import com.onzhou.graphic.yuv2rgb.NativeYUV2RGB;
15 | import com.onzhou.graphic.yuv2rgb.R;
16 |
17 | import java.io.File;
18 |
19 | /**
20 | * @anchor: andy
21 | * @date: 2018-11-23
22 | * @description:
23 | */
24 | public class NativeYUV2RGBActivity extends AbsBaseActivity implements AssertReleaseTask.ReleaseCallback {
25 |
26 | private ViewGroup mRootLayer;
27 |
28 | private Button mBtnYuv420p, mBtnNV12, mBtnNV21;
29 |
30 | private SurfaceView mSurfaceView;
31 |
32 | private NativeYUV2RGB mNativeYUV2RGB;
33 |
34 | @Override
35 | protected void onCreate(@Nullable Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_native_yuv2rgb);
38 |
39 | }
40 |
41 | @Override
42 | protected void onPostCreate(@Nullable Bundle savedInstanceState) {
43 | super.onPostCreate(savedInstanceState);
44 | setupView();
45 | setupAsserts();
46 | }
47 |
48 | private void setupAsserts() {
49 | String[] targetFiles = {"yuv420p.yuv", "nv12.yuv", "nv21.yuv"};
50 | AssertReleaseTask task = new AssertReleaseTask(this, targetFiles, this);
51 | AsyncTaskCompat.executeParallel(task);
52 | }
53 |
54 | private void setupView() {
55 | mRootLayer = (ViewGroup) findViewById(R.id.native_yub2rgb_root_layer);
56 | mBtnYuv420p = (Button) findViewById(R.id.btn_yuv420p);
57 | mBtnNV12 = (Button) findViewById(R.id.btn_nv12);
58 | mBtnNV21 = (Button) findViewById(R.id.btn_nv21);
59 |
60 | mSurfaceView = new SurfaceView(this);
61 | mRootLayer.addView(mSurfaceView);
62 | mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
63 | @Override
64 | public void surfaceCreated(SurfaceHolder holder) {
65 | mNativeYUV2RGB = new NativeYUV2RGB();
66 | }
67 |
68 | @Override
69 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
70 |
71 | }
72 |
73 | @Override
74 | public void surfaceDestroyed(SurfaceHolder holder) {
75 |
76 | }
77 | });
78 | }
79 |
80 | public void onYUV420PToRGB24(View view) {
81 | File file = new File(getExternalFilesDir(null), "yuv420p.yuv");
82 | mNativeYUV2RGB.yuv2rgb(file.getAbsolutePath(), NativeYUV2RGB.Type.YUV420P_TO_RGB24, 510, 510, mSurfaceView.getHolder().getSurface());
83 | }
84 |
85 | public void onNV12ToRGB24(View view) {
86 | File file = new File(getExternalFilesDir(null), "nv12.yuv");
87 | mNativeYUV2RGB.yuv2rgb(file.getAbsolutePath(), NativeYUV2RGB.Type.NV12_TO_RGB24, 510, 510, mSurfaceView.getHolder().getSurface());
88 | }
89 |
90 | public void onNV21ToRGB24(View view) {
91 | File file = new File(getExternalFilesDir(null), "nv21.yuv");
92 | mNativeYUV2RGB.yuv2rgb(file.getAbsolutePath(), NativeYUV2RGB.Type.NV21_TO_RGB24, 510, 510, mSurfaceView.getHolder().getSurface());
93 | }
94 |
95 | @Override
96 | public void onReleaseComplete() {
97 | mBtnYuv420p.setEnabled(true);
98 | mBtnNV12.setEnabled(true);
99 | mBtnNV21.setEnabled(true);
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/java/com/onzhou/graphic/yuv2rgb/NativeYUV2RGB.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.yuv2rgb;
2 |
3 | import android.view.Surface;
4 |
5 | /**
6 | * @anchor: andy
7 | * @date: 2018-11-23
8 | * @description:
9 | */
10 | public class NativeYUV2RGB {
11 |
12 | static {
13 | System.loadLibrary("native-yuv2rgb");
14 | }
15 |
16 | /**
17 | * 转换类型
18 | */
19 | public interface Type {
20 | int YUV420P_TO_RGB24 = 0;
21 | int NV12_TO_RGB24 = 1;
22 | int NV21_TO_RGB24 = 2;
23 | }
24 |
25 | public native void yuv2rgb(String imagePath, int type, int width, int height, Surface surface);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/res/layout/activity_native_yuv2rgb.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
23 |
24 |
25 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/native-yuv2rgb/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | YUV2RGB
3 |
4 |
--------------------------------------------------------------------------------
/native-yuv2rgb/src/test/java/com/onzhou/graphic/yuv2rgb/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.onzhou.graphic.yuv2rgb;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':common', ':native-libjpeg-turbo', ':native-libpng', ':native-yuv2rgb', ':native-yuv2image', ':native-libyuv'
2 | include ':native-gauss'
3 |
--------------------------------------------------------------------------------