├── .gitignore ├── LICENSE ├── LICENSE_CN ├── README.md ├── README_CN.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidyuan │ │ └── jpg_rotate │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ ├── com │ │ │ └── androidyuan │ │ │ │ └── jpg_rotate │ │ │ │ └── MainActivity.java │ │ └── net │ │ │ └── bither │ │ │ └── util │ │ │ └── NativeUtil.java │ ├── jni │ │ ├── Android.mk │ │ ├── Application.mk │ │ ├── LICENSE │ │ ├── bypassdalvik.c │ │ ├── compress.c │ │ ├── compress.h │ │ ├── libjpeg-turbo │ │ │ ├── android │ │ │ │ ├── config.h │ │ │ │ └── jconfig.h │ │ │ ├── cderror.h │ │ │ ├── cdjpeg.h │ │ │ ├── jconfig.h │ │ │ ├── jerror.h │ │ │ ├── jinclude.h │ │ │ ├── jmorecfg.h │ │ │ ├── jpeglib.h │ │ │ ├── jversion.h │ │ │ ├── transupp.c │ │ │ └── transupp.h │ │ ├── libjpeg.so │ │ ├── libpng │ │ │ ├── Android.mk │ │ │ ├── config.h │ │ │ ├── png.c │ │ │ ├── png.h │ │ │ ├── pngconf.h │ │ │ ├── pngdebug.h │ │ │ ├── pngerror.c │ │ │ ├── pngget.c │ │ │ ├── pnginfo.h │ │ │ ├── pnglibconf.h │ │ │ ├── pngmem.c │ │ │ ├── pngpread.c │ │ │ ├── pngpriv.h │ │ │ ├── pngread.c │ │ │ ├── pngrio.c │ │ │ ├── pngrtran.c │ │ │ ├── pngrutil.c │ │ │ ├── pngset.c │ │ │ ├── pngstruct.h │ │ │ ├── pngtrans.c │ │ │ ├── pngwio.c │ │ │ ├── pngwrite.c │ │ │ ├── pngwtran.c │ │ │ └── pngwutil.c │ │ ├── logger.h │ │ ├── resize.c │ │ ├── resize.h │ │ └── rotate.c │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.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 │ └── test │ └── java │ └── com │ └── androidyuan │ └── jpg_rotate │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/ 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild/ 9 | ### Android template 10 | # Built application files 11 | *.apk 12 | *.ap_ 13 | 14 | # Files for the ART/Dalvik VM 15 | *.dex 16 | 17 | # Java class files 18 | *.class 19 | 20 | # Generated files 21 | bin/ 22 | gen/ 23 | out/ 24 | 25 | # Gradle files 26 | .gradle/ 27 | build/ 28 | 29 | # Local configuration file (sdk path, etc) 30 | local.properties 31 | 32 | # Proguard folder generated by Eclipse 33 | proguard/ 34 | 35 | # Log Files 36 | *.log 37 | 38 | # Android Studio Navigation editor temp files 39 | .navigation/ 40 | 41 | # Android Studio captures folder 42 | captures/ 43 | 44 | # IntelliJ 45 | *.iml 46 | .idea/workspace.xml 47 | .idea/tasks.xml 48 | .idea/gradle.xml 49 | .idea/dictionaries 50 | .idea/libraries 51 | 52 | # Keystore files 53 | # Uncomment the following line if you do not want to check your keystore files in. 54 | #*.jks 55 | 56 | # External native build folder generated in Android Studio 2.2 and later 57 | .externalNativeBuild 58 | 59 | # Google Services (e.g. APIs or Firebase) 60 | google-services.json 61 | 62 | # Freeline 63 | freeline.py 64 | freeline/ 65 | freeline_project_description.json 66 | ### CMake template 67 | CMakeCache.txt 68 | CMakeFiles 69 | CMakeScripts 70 | Testing 71 | Makefile 72 | cmake_install.cmake 73 | install_manifest.txt 74 | compile_commands.json 75 | CTestTestfile.cmake 76 | ### C template 77 | # Prerequisites 78 | *.d 79 | 80 | # Object files 81 | *.o 82 | *.ko 83 | *.obj 84 | *.elf 85 | 86 | # Linker output 87 | *.ilk 88 | *.map 89 | *.exp 90 | 91 | # Precompiled Headers 92 | *.gch 93 | *.pch 94 | 95 | # Libraries 96 | *.lib 97 | *.la 98 | *.lo 99 | 100 | # Shared objects (inc. Windows DLLs) 101 | *.dll 102 | 103 | *.dylib 104 | 105 | # Executables 106 | *.exe 107 | *.out 108 | *.app 109 | *.i*86 110 | *.x86_64 111 | *.hex 112 | 113 | # Debug files 114 | *.dSYM/ 115 | *.su 116 | *.idb 117 | *.pdb 118 | 119 | # Kernel Module Compile Results 120 | *.mod* 121 | *.cmd 122 | .tmp_versions/ 123 | modules.order 124 | Module.symvers 125 | Mkfile.old 126 | dkms.conf 127 | ### C++ template 128 | # Prerequisites 129 | *.d 130 | 131 | # Compiled Object files 132 | *.slo 133 | *.lo 134 | *.o 135 | *.obj 136 | 137 | # Precompiled Headers 138 | *.gch 139 | *.pch 140 | 141 | # Compiled Dynamic libraries 142 | 143 | *.dylib 144 | *.dll 145 | 146 | # Fortran module files 147 | *.mod 148 | *.smod 149 | 150 | # Compiled Static libraries 151 | *.lai 152 | *.la 153 | *.a 154 | *.lib 155 | 156 | # Executables 157 | *.exe 158 | *.out 159 | *.app 160 | 161 | app/libs/ 162 | app/src/main/libs/ 163 | app/src/main/obj/ 164 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 @androidyuan.com 2 | 3 | 996 License Version 1.0 (Draft) 4 | 5 | Permission is hereby granted to any individual or legal entity 6 | obtaining a copy of this licensed work (including the source code, 7 | documentation and/or related items, hereinafter collectively referred 8 | to as the "licensed work"), free of charge, to deal with the licensed 9 | work for any purpose, including without limitation, the rights to use, 10 | reproduce, modify, prepare derivative works of, distribute, publish 11 | and sublicense the licensed work, subject to the following conditions: 12 | 13 | 1. The individual or the legal entity must conspicuously display, 14 | without modification, this License and the notice on each redistributed 15 | or derivative copy of the Licensed Work. 16 | 17 | 2. The individual or the legal entity must strictly comply with all 18 | applicable laws, regulations, rules and standards of the jurisdiction 19 | relating to labor and employment where the individual is physically 20 | located or where the individual was born or naturalized; or where the 21 | legal entity is registered or is operating (whichever is stricter). In 22 | case that the jurisdiction has no such laws, regulations, rules and 23 | standards or its laws, regulations, rules and standards are 24 | unenforceable, the individual or the legal entity are required to 25 | comply with Core International Labor Standards. 26 | 27 | 3. The individual or the legal entity shall not induce or force its 28 | employee(s), whether full-time or part-time, or its independent 29 | contractor(s), in any methods, to agree in oral or written form, to 30 | directly or indirectly restrict, weaken or relinquish his or her 31 | rights or remedies under such laws, regulations, rules and standards 32 | relating to labor and employment as mentioned above, no matter whether 33 | such written or oral agreement are enforceable under the laws of the 34 | said jurisdiction, nor shall such individual or the legal entity 35 | limit, in any methods, the rights of its employee(s) or independent 36 | contractor(s) from reporting or complaining to the copyright holder or 37 | relevant authorities monitoring the compliance of the license about 38 | its violation(s) of the said license. 39 | 40 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 41 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 42 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 43 | IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, 44 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 45 | OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE 46 | LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK. 47 | -------------------------------------------------------------------------------- /LICENSE_CN: -------------------------------------------------------------------------------- 1 | 版权所有(c)2019 @androidyuan.com 2 | 3 | 反996许可证版本1.0 4 | 5 | 在符合下列条件的情况下,特此免费向任何得到本授权作品的副本(包括源代码、文件和/或相关内容,以下 6 | 统称为“授权作品”)的个人和法人实体授权:被授权个人或法人实体有权以任何目的处置授权作品,包括但 7 | 不限于使用、复制,修改,衍生利用、散布,发布和再许可: 8 | 9 | 1. 个人或法人实体必须在许可作品的每个再散布或衍生副本上包含以上版权声明和本许可证,不得自行修 10 | 改。 11 | 2. 个人或法人实体必须严格遵守与个人实际所在地或个人出生地或归化地、或法人实体注册地或经营地 12 | (以较严格者为准)的司法管辖区所有适用的与劳动和就业相关法律、法规、规则和标准。如果该司法管辖 13 | 区没有此类法律、法规、规章和标准或其法律、法规、规章和标准不可执行,则个人或法人实体必须遵守国 14 | 际劳工标准的核心公约。 15 | 3. 个人或法人不得以任何方式诱导或强迫其全职或兼职员工或其独立承包人以口头或书面形式同意直接或 16 | 间接限制、削弱或放弃其所拥有的,受相关与劳动和就业有关的法律、法规、规则和标准保护的权利或补救 17 | 措施,无论该等书面或口头协议是否被该司法管辖区的法律所承认,该等个人或法人实体也不得以任何方法 18 | 限制其雇员或独立承包人向版权持有人或监督许可证合规情况的有关当局报告或投诉上述违反许可证的行为 19 | 的权利。 20 | 21 | 该授权作品是"按原样"提供,不做任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性和非侵 22 | 权性的保证。在任何情况下,无论是在合同诉讼、侵权诉讼或其他诉讼中,版权持有人均不承担因本软件或 23 | 本软件的使用或其他交易而产生、引起或与之相关的任何索赔、损害或其他责任。 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OperatingImageBypassJavaHeap 2 | ------------------ 3 | [中文](https://github.com/BruceWind/OperatingImageBypassDalvik/blob/master/README_CN.md) 4 | 5 | ***Announcement regarding discontinued maintenance in 2021:*** 6 | > [In devices above Android 8.0, bitmaps store in native heaps](https://developer.android.com/topic/performance/graphics/manage-memory). 7 | > In the future, most devices will keep upgrading to new above 8.0, so this repo will be useless. This is why I have decided to stop maintaining it. 8 | > I apologize to anyone who looks forward to updates. 9 | ------------------ 10 | 11 | 12 | The size of physical memory **RAM** has been increasing for a decade; the limitation of the Java heap exists, though. Furthermore, the camera is improved, and the size of the images that we need to operate keeps increasing. 13 | By the way, even though some brands or companies produce phones whose **xmx** has been modified, the limitations on those devices are still insufficient for immensely large images. 14 | 15 | It is a fact that Android's JVMs such as **Dalvik** and **ART** accord with JVM standards. So that the Android JVM has a configuration with **xmx**. 16 | > In the README, I don't explain more about what **xmx** is. You can look into docs or websites for more about it. 17 | 18 | Due to the limitation of Java heap for one application, while you operate large bitmaps, the device may throw OOM. 19 | 20 | On the other hand, **the native heap** has no limitation. It is able to allocate reach physical size. 21 | So, operating images in the native heap can avoid OOM. In this repo, I bypass Bitmap. In case it bypasses bitmap, it will bypass the Java heap. 22 | 23 | To sum up, the native heap is unlimited for every developer. This is why the repo works. All operations of images are in the native heap, which will completely avoid OOM. 24 | 25 | ### The evidence for that the native heap doesn't have limitations. 26 |
27 | click to expand 28 | 29 | I have tried to allocate numerous memory in the native heap and don't execute `free`. The allocated memory exceeds 1G, which didn't give rise to OOM. 30 | 31 | Below a picture, I run ```adb shell dumpsys meminfo PACKAGENAME ``` to print that memory information. 32 | 33 | ![](https://github.com/weizongwei5/my_blog_datasave/raw/62e952490c7fc3ef1f478c52985d4686331d17e0/img/native_memory_show.png) 34 | 35 |
36 | 37 | ## The repo progress 38 | 39 | - [x] rotate jpeg 40 | - [x] compress jpeg 41 | - [x] resize jpeg 42 | 43 | - [x] compress png (2018.04.10) 44 | > - [ ] provide other algorithms about compression, may introduce `optipng`, which has been used in most services or applications. 45 | - [ ] rotate png 46 | - [ ] resize png 47 | 48 | ## Build tips 49 | 1. before you run on the device, you need to put a `test.jpg` on external storage. 50 | 51 | 2. After you start this app: 52 | ``` 53 | test.jpg ----------compress/rotate---------> test2.jpg 54 | ``` 55 | 56 | 57 | Thanks 58 | ------------------------------ 59 | [base on::bither-android-lib](https://github.com/bither/bither-android-lib) 60 | 61 | [github:libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo) 62 | 63 | [source.android.com/...../dalvik_vm_properties](https://source.android.com/devices/tech/dalvik/configure?hl=zh-cn#dalvik_vm_properties) 64 | 65 | [sourceforge:libjpeg](http://libjpeg.sourceforge.net/) 66 | 67 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | 2 | **停止维护公告 2021** 3 | 4 | > [Android 8.0之后bitmap的内存就是创建在native heap中](https://developer.android.com/topic/performance/graphics/manage-memory),随着用户不断更换新手机,慢慢都用到8.0更新的系统了,这个库就没有使用的意义了. 5 | > 6 | > 因此,我需要跟所有期待这个repo的更新的朋友们道歉! 7 | 8 | # 绕过Bitmap操作图片,100%防止OOM 9 | 10 | ------------------ 11 | 虽然,现在新的android系统提供的这个限制都在调大,6.0官方ROM限制在96M,非官方ROM要大一些,因为非官方ROM在编译时修改了xmx参数配置,但是新出的手机相机拍摄出来的图片更大,相机技术的增长速度远大于这个限制的开放程度,进行大图操作,你懂得。 12 | 我们都知道JVM xmx参数,这个`xmx`不做具体介绍,这是jvm的基本参数,不了解的请自行查询Java虚拟机原理。android的Dalvik/ART遵守了JVM的规范,有堆内存限制,遇到大图操作缩放旋转Bitmap的时候,就很容易OOM。 13 | 14 | 上面说的核心原因在于你的bitmap内存申请都在Java heap中,这个最大内存的限制。 15 | 但是native内存处于不太受管理的状态,这一点很多人不知道。 16 | 17 | 18 | 这个库的目的在于绕过Dalvik heap 限制,去操作图片,保证无需担心OOM。怎么绕过Dalvik呢?就是绕过bitmap去直接对图片进行操作,毕竟Android 4.0以后的机器bitmap内存都在Dalvik中,我们所有操作图片时的内存申请都在Native heap中。 19 | 20 | 21 | ### 如下证明native heap内存申请无限制 22 |
23 | 点击查看 24 | 我尝试用native写了个申请巨大内存又不执行`free()`的代码进行测试,申请了1G多的内存还是不会OOM,下图是我用```adb shell dumpsys meminfo PACKAGENAME ```打印出来的当前memory信息。 25 | 26 | ![](https://github.com/weizongwei5/my_blog_datasave/raw/62e952490c7fc3ef1f478c52985d4686331d17e0/img/native_memory_show.png) 27 |
28 | 29 | ## 当前仓库进度 30 | 31 | - [x] rotate jpeg 32 | - [x] compress jpeg 33 | - [x] resize jpeg 34 | 35 | - [x] compress png (2018.04.10) 36 | > - [ ] 提供除了libpng单纯压缩level之外的算法,参考optipng这个古老的开源库 37 | - [ ] rotate png 38 | - [ ] resize png 39 | 40 | ## 编译运行提示 41 | 该项目需要在外部存储空间(SD卡)根目录下存储一个test.jpg 的大图。 42 | 运行项目之后: 43 | ``` 44 | test.jpg ----------compress/rotate---------> test2.jpg 45 | 46 | ``` 47 | 48 | 特别鸣谢 49 | ------------------------------ 50 | 51 | [base on::bither-android-lib](https://github.com/bither/bither-android-lib) 52 | 53 | 54 | [github:libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo) 55 | 56 | 57 | [source.android.com/...../dalvik_vm_properties](https://source.android.com/devices/tech/dalvik/configure?hl=zh-cn#dalvik_vm_properties) 58 | 59 | [sourceforge:libjpeg](http://libjpeg.sourceforge.net/) 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | defaultConfig { 6 | applicationId "com.androidyuan.jpg_rotate" 7 | minSdkVersion 15 8 | targetSdkVersion 19 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | externalNativeBuild { 13 | ndkBuild { 14 | cppFlags "-frtti -fexceptions" 15 | } 16 | } 17 | 18 | 19 | ndk { 20 | // Specifies the ABI configurations of your native 21 | // libraries Gradle should build and package with your APK. 22 | abiFilters 'armeabi-v7a' 23 | cFlags '-std=c++11 -fexceptions -fpermissive' 24 | stl 'stlport_static' 25 | } 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | 34 | //使用这个可以直接debug 35 | externalNativeBuild{ 36 | ndkBuild{ 37 | path file("src/main/jni/Android.mk") 38 | } 39 | } 40 | } 41 | 42 | dependencies { 43 | implementation fileTree(dir: 'libs', include: ['*.jar']) 44 | implementation 'com.android.support:appcompat-v7:25.4.0' 45 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 46 | testImplementation 'junit:junit:4.12' 47 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 48 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 49 | } 50 | -------------------------------------------------------------------------------- /app/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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/androidyuan/jpg_rotate/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.androidyuan.jpg_rotate; 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.androidyuan.jpg_rotate", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/androidyuan/jpg_rotate/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidyuan.jpg_rotate; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.os.Bundle; 5 | import android.os.Environment; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.util.Log; 8 | import net.bither.util.NativeUtil; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | 13 | @SuppressLint("SetTextI18n") 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | 19 | testCompress(); 20 | } 21 | 22 | private void testCompress() { 23 | 24 | 25 | for(int i=0;i<1;i++) { 26 | 27 | try { 28 | Thread.sleep(100); 29 | } catch (InterruptedException e) { 30 | e.printStackTrace(); 31 | } 32 | 33 | new Thread( 34 | new Runnable() { 35 | @Override 36 | public void run() { 37 | Log.d("TEST", "begin"); 38 | 39 | String in = Environment.getExternalStorageDirectory().getAbsolutePath() + "/test.png"; 40 | String out = Environment.getExternalStorageDirectory().getAbsolutePath() + "/test2.png"; 41 | 42 | //这里可以循环几十次测试内存释放 43 | // NativeUtil.compressJpeg(in, out,20); 44 | // NativeUtil.resizeJpeg(in, out,0.6f); 45 | int result = NativeUtil.compressPng(in, out, 9); 46 | 47 | Log.d("TEST", "end : " + result); 48 | 49 | } 50 | }).start(); 51 | 52 | } 53 | 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/net/bither/util/NativeUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.util; 18 | 19 | 20 | /** 21 | * 所有native return 0 都代表操作成功 22 | */ 23 | public class NativeUtil { 24 | 25 | 26 | /** 27 | * 28 | * @param in 29 | * @param out 30 | * @param quality must between 1-99 31 | * @return 0 : success else :failed 32 | */ 33 | public static native int compressJpeg(String in,String out,int quality); 34 | 35 | 36 | /** 37 | * 该方法比较耗时 较大图片4s左右 38 | * @param in 39 | * @param out 40 | * @param factor : <1 && >0.5f 41 | * @return 0 : success else :failed 42 | */ 43 | public static native int resizeJpeg(String in,String out,float factor); 44 | 45 | /** 46 | * 顺时针旋转 90×n 度数 47 | * @param in 48 | * @param out 49 | * @param degreee must in 90 ,180 ,270 50 | * @return 0 : success else :failed 51 | */ 52 | public static native int rotateJpeg(String in,String out,int degreee); 53 | 54 | 55 | 56 | 57 | /** 58 | * 59 | * test记录:循环200次的内存的释放回收通过 60 | * 61 | * @param in 62 | * @param out 63 | * @param level must between 1-9,不同于jpeg的参数,这里是压缩等级 64 | * TODO ==> if(level == 10) 可能会修改颜色,透明度,像素深度,具体算法参考optipng这个linux开源库 65 | * @return 0 : success else :failed 66 | */ 67 | public static native int compressPng(String in,String out,int level); 68 | 69 | 70 | static { 71 | System.loadLibrary("jpeg"); 72 | System.loadLibrary("bypassdalvik"); 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /app/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | 17 | # Copyright 2014 http://Bither.net 18 | # 19 | # Licensed under the Apache License, Version 2.0 (the "License"); 20 | # you may not use this file except in compliance with the License. 21 | # You may obtain a copy of the License at 22 | # 23 | # http://www.apache.org/licenses/LICENSE-2.0 24 | # 25 | # Unless required by applicable law or agreed to in writing, software 26 | # distributed under the License is distributed on an "AS IS" BASIS, 27 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 | # See the License for the specific language governing permissions and 29 | # limitations under the License. 30 | 31 | LOCAL_PATH := $(call my-dir) 32 | 33 | 34 | #jpeg-turbo 35 | include $(CLEAR_VARS) 36 | LOCAL_MODULE := libjpeg 37 | LOCAL_SRC_FILES := libjpeg.so 38 | include $(PREBUILT_SHARED_LIBRARY) 39 | 40 | 41 | include $(CLEAR_VARS) 42 | LOCAL_MODULE := bypassdalvik 43 | LOCAL_SRC_FILES := bypassdalvik.c \ 44 | compress.c \ 45 | resize.c 46 | LOCAL_SHARED_LIBRARIES := libjpeg 47 | LOCAL_STATIC_LIBRARIES += png 48 | # 依赖zlib 因为libpng依赖zlib 49 | LOCAL_LDLIBS := -ljnigraphics -llog -lz 50 | LOCAL_C_INCLUDES := $(LOCAL_PATH) \ 51 | $(LOCAL_PATH)/libjpeg-turbo \ 52 | $(LOCAL_PATH)/libjpeg-turbo/android 53 | 54 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/libpng 55 | 56 | 57 | include $(BUILD_SHARED_LIBRARY) 58 | 59 | include $(CLEAR_VARS) 60 | include $(LOCAL_PATH)/libpng/Android.mk -------------------------------------------------------------------------------- /app/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi-v7a arm64-v8a 2 | 3 | # armeabi-v7a armeabi -------------------------------------------------------------------------------- /app/src/main/jni/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {2014} {http://Bither.net} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /app/src/main/jni/bypassdalvik.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "jpeglib.h" 25 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 26 | #include "jversion.h" /* for version message */ 27 | #include "config.h" 28 | #include "rotate.c" 29 | #include "compress.h" 30 | #include "resize.h" 31 | 32 | 33 | jint Java_net_bither_util_NativeUtil_compressJpeg(JNIEnv* env,jobject thiz,jstring file,jstring fileout,jint quality) 34 | { 35 | const char *in = (*env)->GetStringUTFChars(env, file, JNI_FALSE); 36 | const char *out = (*env)->GetStringUTFChars(env, fileout, JNI_FALSE); 37 | 38 | return compress_jpeg(in,out,(int)quality); 39 | } 40 | 41 | 42 | jint Java_net_bither_util_NativeUtil_resizeJpeg(JNIEnv* env,jobject thiz,jstring file,jstring fileout,jfloat factor) 43 | { 44 | const char *in = (*env)->GetStringUTFChars(env, file, JNI_FALSE); 45 | const char *out = (*env)->GetStringUTFChars(env, fileout, JNI_FALSE); 46 | 47 | return zoom_jpeg_file(in,out,(float)factor); 48 | } 49 | 50 | jint Java_net_bither_util_NativeUtil_rotateJpeg(JNIEnv* env,jobject thiz,jstring file,jstring fileout,jint degree) { 51 | const char *in = (*env)->GetStringUTFChars(env, file, JNI_FALSE); 52 | const char *out = (*env)->GetStringUTFChars(env, fileout, JNI_FALSE); 53 | 54 | return rotate_jpeg(in,out,(int)degree); 55 | } 56 | 57 | 58 | 59 | 60 | jint Java_net_bither_util_NativeUtil_compressPng(JNIEnv* env,jobject thiz,jstring file,jstring fileout,jint level) 61 | { 62 | const char *in = (*env)->GetStringUTFChars(env, file, JNI_FALSE); 63 | const char *out = (*env)->GetStringUTFChars(env, fileout, JNI_FALSE); 64 | 65 | return compress_png(in,out,(int)level); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /app/src/main/jni/compress.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "compress.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | //#####################jpeg begin################## 12 | 13 | void read_jpeg(char * filename, unsigned char * * data, int * width, int * height) { 14 | FILE * infile = fopen(filename, "rb"); 15 | struct jpeg_decompress_struct cinfo; 16 | struct jpeg_error_mgr jerr; 17 | cinfo.err = jpeg_std_error( & jerr); 18 | jpeg_create_decompress( & cinfo); 19 | jpeg_stdio_src( & cinfo, infile); 20 | jpeg_read_header( & cinfo, TRUE); 21 | jpeg_start_decompress( & cinfo); * width = cinfo.output_width; * height = cinfo.output_height; * data = (unsigned char * ) malloc( 22 | cinfo.output_height * cinfo.output_width * cinfo.output_components); 23 | unsigned char * line_pointer; 24 | int i = 0; 25 | while (cinfo.output_scanline < cinfo.image_height) { 26 | line_pointer = * data + i * cinfo.output_width * cinfo.output_components; 27 | jpeg_read_scanlines( & cinfo, & line_pointer, 1); 28 | i++; 29 | } 30 | jpeg_finish_decompress( & cinfo); 31 | jpeg_destroy_decompress( & cinfo); 32 | 33 | fclose(infile); 34 | //free(&cinfo); 35 | //free(&jerr); 36 | // free(line_pointer); 37 | } 38 | 39 | void write_jpeg(char * filename, unsigned char * * data, int * width, int * height, int quality) { 40 | FILE * outfile = fopen(filename, "wb"); 41 | struct jpeg_compress_struct cinfo; 42 | struct jpeg_error_mgr jerr; 43 | cinfo.err = jpeg_std_error( & jerr); 44 | jpeg_create_compress( & cinfo); 45 | jpeg_stdio_dest( & cinfo, outfile); 46 | cinfo.image_width = * width; 47 | cinfo.image_height = * height; 48 | cinfo.in_color_space = JCS_RGB; //JCS_GRAYSCALE:灰度图,JCS_RGB:彩色图 49 | cinfo.input_components = 3; // 在此为1,表示灰度图, 如果是彩色位图,则为3 50 | jpeg_set_defaults( & cinfo); 51 | jpeg_set_quality( & cinfo, quality, TRUE); 52 | jpeg_start_compress( & cinfo, TRUE); 53 | unsigned char * line_pointer; 54 | int i = 0; 55 | while (cinfo.next_scanline < cinfo.image_height) { 56 | line_pointer = * data + i * cinfo.image_width * cinfo.input_components; 57 | jpeg_write_scanlines( & cinfo, & line_pointer, 1); 58 | i++; 59 | } 60 | jpeg_finish_compress( & cinfo); 61 | jpeg_destroy_compress( & cinfo); 62 | 63 | fclose(outfile); 64 | 65 | //free(&cinfo); 66 | //free(&jerr); 67 | //free(line_pointer); 68 | } 69 | 70 | void 71 | get_pixel_of(int x, int y, unsigned char * dest, unsigned char * * data, int * width, int * height) { 72 | if ((x >= * width) || (x < 0) || (y >= * height) || (y < 0)) { 73 | dest[0] = 0; 74 | dest[1] = 0; 75 | dest[2] = 0; 76 | return; 77 | } 78 | unsigned char * pos; 79 | pos = * data + (y * * width + x) * 3; 80 | dest[0] = pos[0]; 81 | dest[1] = pos[1]; 82 | dest[2] = pos[2]; 83 | } 84 | 85 | void 86 | set_pixel_of(int x, int y, unsigned char * dest, unsigned char * * data, int * width, int * height) { 87 | if ((x >= * width) || (x < 0) || (y >= * height) || (y < 0)) { 88 | return; 89 | } 90 | unsigned char * pos; 91 | pos = * data + (y * * width + x) * 3; 92 | pos[0] = dest[0]; 93 | pos[1] = dest[1]; 94 | pos[2] = dest[2]; 95 | } 96 | 97 | int compress_jpeg(char * in , char * out, int quality) { 98 | 99 | if (quality < 1 && quality >= 100) 100 | return -1; 101 | 102 | int width, height = 0; 103 | unsigned char * data; 104 | 105 | read_jpeg( in , & data, & width, & height); 106 | unsigned char pixel[3] = { 107 | 0, 108 | 0, 109 | 0 110 | }; 111 | set_pixel_of(0, 0, pixel, & data, & width, & height); 112 | write_jpeg(out, & data, & width, & height, quality); 113 | 114 | free(data); 115 | //free(width); 116 | //free(height); 117 | return 0; 118 | } 119 | 120 | //############## jpeg end ############## 121 | 122 | // #############png begin ############### 123 | 124 | int compress_png(char * inname , char * outname,int level) { 125 | 126 | static png_FILE_p fpin; 127 | static png_FILE_p fpout; 128 | 129 | //读: 130 | png_structp read_ptr; 131 | png_infop read_info_ptr, end_info_ptr; 132 | //写 133 | png_structp write_ptr; 134 | png_infop write_info_ptr,write_end_info_ptr; 135 | // 136 | png_bytep row_buf; 137 | png_uint_32 y; 138 | int num_pass, pass; 139 | png_uint_32 width, height;//宽度,高度 140 | int bit_depth, color_type;//位深,颜色类型 141 | int interlace_type, compression_type, filter_type;//扫描方式,压缩方式,滤波方式 142 | //读 143 | row_buf = NULL; 144 | //打开读文件 145 | if ((fpin = fopen(inname, "rb")) == NULL) 146 | { 147 | LOGD(stderr,"Could not find input file %s\n", inname); 148 | return (1); 149 | } 150 | //打开写文件 151 | if ((fpout = fopen(outname, "wb")) == NULL) 152 | { 153 | LOGD("Could not open output file %s\n", outname); 154 | fclose(fpin); 155 | return (1); 156 | } 157 | //我们这里不处理未知的块unknown chunk 158 | //初始化1 159 | read_ptr = 160 | png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 161 | write_ptr = 162 | png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 163 | read_info_ptr = png_create_info_struct(read_ptr); 164 | end_info_ptr = png_create_info_struct(read_ptr); 165 | write_info_ptr = png_create_info_struct(write_ptr); 166 | write_end_info_ptr = png_create_info_struct(write_ptr); 167 | //初始化2 168 | png_init_io(read_ptr, fpin); 169 | png_init_io(write_ptr, fpout); 170 | //读文件有high level(高层)和low level两种,我们选择从底层具体信息中读取。 171 | //这里我们读取所有可选。 172 | png_read_info(read_ptr, read_info_ptr); 173 | //(1)IHDR 174 | //读取图像宽度(width),高度(height),位深(bit_depth),颜色类型(color_type),压缩方法(compression_type) 175 | //滤波器方法(filter_type),隔行扫描方式(interlace_type) 176 | if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, 177 | &color_type, &interlace_type, &compression_type, &filter_type)) 178 | { 179 | //我们采用默认扫描方式 180 | png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, 181 | color_type, PNG_INTERLACE_NONE, compression_type, filter_type); 182 | } 183 | 184 | 185 | //(2)cHRM 186 | //读取白色度信息 白/红/绿/蓝 点的x,y坐标,这里采用整形,不采用浮点数 187 | png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,blue_y; 188 | 189 | if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, 190 | &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y)) 191 | { 192 | png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, 193 | red_y, green_x, green_y, blue_x, blue_y); 194 | } 195 | //(3)gAMA 196 | png_fixed_point gamma; 197 | 198 | if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) 199 | png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); 200 | //(4)iCCP 201 | png_charp name; 202 | png_bytep profile; 203 | png_uint_32 proflen; 204 | 205 | if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, 206 | &profile, &proflen)) 207 | { 208 | png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, 209 | profile, proflen); 210 | } 211 | //(5)sRGB 212 | int intent; 213 | if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) 214 | png_set_sRGB(write_ptr, write_info_ptr, intent); 215 | //(7)PLTE 216 | png_colorp palette; 217 | int num_palette; 218 | 219 | if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) 220 | png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); 221 | //(8)bKGD 222 | png_color_16p background; 223 | 224 | if (png_get_bKGD(read_ptr, read_info_ptr, &background)) 225 | { 226 | png_set_bKGD(write_ptr, write_info_ptr, background); 227 | } 228 | //(9)hist 229 | 230 | png_uint_16p hist; 231 | 232 | if (png_get_hIST(read_ptr, read_info_ptr, &hist)) 233 | png_set_hIST(write_ptr, write_info_ptr, hist); 234 | //(10)oFFs 235 | png_int_32 offset_x, offset_y; 236 | int unit_type; 237 | 238 | if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y, 239 | &unit_type)) 240 | { 241 | png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); 242 | } 243 | //(11)pCAL 244 | png_charp purpose, units; 245 | png_charpp params; 246 | png_int_32 X0, X1; 247 | int type, nparams; 248 | 249 | if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, 250 | &nparams, &units, ¶ms)) 251 | { 252 | png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, 253 | nparams, units, params); 254 | } 255 | //(12)pHYs 256 | 257 | png_uint_32 res_x, res_y; 258 | 259 | if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) 260 | png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); 261 | //(13)sBIT 262 | png_color_8p sig_bit; 263 | 264 | if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) 265 | png_set_sBIT(write_ptr, write_info_ptr, sig_bit); 266 | //(14)sCAL 267 | int unit; 268 | png_charp scal_width, scal_height; 269 | 270 | if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, 271 | &scal_height)) 272 | { 273 | png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, 274 | scal_height); 275 | } 276 | //(15)iTXt 277 | png_textp text_ptr; 278 | int num_text; 279 | 280 | if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) 281 | { 282 | png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); 283 | } 284 | //(16)tIME,这里我们不支持RFC1123 285 | png_timep mod_time; 286 | 287 | if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) 288 | { 289 | png_set_tIME(write_ptr, write_info_ptr, mod_time); 290 | } 291 | //(17)tRNS 292 | png_bytep trans_alpha; 293 | int num_trans; 294 | png_color_16p trans_color; 295 | 296 | if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans, 297 | &trans_color)) 298 | { 299 | int sample_max = (1 << bit_depth); 300 | /* libpng doesn't reject a tRNS chunk with out-of-range samples */ 301 | if (!((color_type == PNG_COLOR_TYPE_GRAY && 302 | (int)trans_color->gray > sample_max) || 303 | (color_type == PNG_COLOR_TYPE_RGB && 304 | ((int)trans_color->red > sample_max || 305 | (int)trans_color->green > sample_max || 306 | (int)trans_color->blue > sample_max)))) 307 | png_set_tRNS(write_ptr, write_info_ptr, trans_alpha, num_trans, 308 | trans_color); 309 | } 310 | 311 | //(18)控制压缩level 312 | //check params invalid. 313 | if(level<1 || level>9){ 314 | level = Z_BEST_COMPRESSION; 315 | } 316 | png_set_compression_level(write_ptr,level); 317 | 318 | //写进新的png文件中 319 | png_write_info(write_ptr, write_info_ptr); 320 | //读真正的图像数据 321 | num_pass = 1; 322 | for (pass = 0; pass < num_pass; pass++) 323 | { 324 | for (y = 0; y < height; y++) 325 | { 326 | //分配内存 327 | row_buf = (png_bytep)png_malloc(read_ptr, 328 | png_get_rowbytes(read_ptr, read_info_ptr)); 329 | png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1); 330 | png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); 331 | png_free(read_ptr, row_buf); 332 | row_buf = NULL; 333 | } 334 | } 335 | //结束 336 | png_read_end(read_ptr, end_info_ptr); 337 | // 338 | //tTXt 339 | if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) 340 | { 341 | png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); 342 | } 343 | //tIME 344 | if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) 345 | { 346 | png_set_tIME(write_ptr, write_end_info_ptr, mod_time); 347 | } 348 | // 349 | png_write_end(write_ptr, write_end_info_ptr); 350 | //回收 351 | png_free(read_ptr, row_buf); 352 | row_buf = NULL; 353 | png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); 354 | png_destroy_info_struct(write_ptr, &write_end_info_ptr); 355 | png_destroy_write_struct(&write_ptr, &write_info_ptr); 356 | // 357 | fclose(fpin); 358 | fclose(fpout); 359 | //测试,比较两个PNG文件是否相同 360 | if ((fpin = fopen(inname, "rb")) == NULL) 361 | { 362 | LOGD("Could not find file %s\n", inname); 363 | return (1); 364 | } 365 | 366 | if ((fpout = fopen(outname, "rb")) == NULL) 367 | { 368 | LOGD("Could not find file %s\n", outname); 369 | fclose(fpin); 370 | return (1); 371 | } 372 | char inbuf[256], outbuf[256]; 373 | for (;;) 374 | { 375 | png_size_t num_in, num_out; 376 | 377 | num_in = fread(inbuf, 1, 1, fpin); 378 | num_out = fread(outbuf, 1, 1, fpout); 379 | 380 | if (num_in != num_out) 381 | { 382 | LOGD("\nFiles %s and %s 大小不同\n", 383 | inname, outname); 384 | 385 | fclose(fpin); 386 | fclose(fpout); 387 | return (0); 388 | } 389 | 390 | if (!num_in) 391 | break; 392 | 393 | if (memcmp(inbuf, outbuf, num_in)) 394 | { 395 | LOGD("\nFiles %s and %s 内容不同\n", inname, outname); 396 | fclose(fpin); 397 | fclose(fpout); 398 | return (0); 399 | } 400 | } 401 | 402 | fclose(fpin); 403 | fclose(fpout); 404 | 405 | return (0); 406 | } 407 | 408 | //############### png end ################# 409 | -------------------------------------------------------------------------------- /app/src/main/jni/compress.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int compress_jpeg(char * in,char * out,int quality); 4 | 5 | int compress_png(char * in,char * out,int level); -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/android/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Build number */ 5 | #define BUILD "20110829" 6 | 7 | /* Support arithmetic encoding */ 8 | #define C_ARITH_CODING_SUPPORTED 1 9 | 10 | /* Support arithmetic decoding */ 11 | #define D_ARITH_CODING_SUPPORTED 1 12 | 13 | /* Define to 1 if you have the header file. */ 14 | #define HAVE_DLFCN_H 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_INTTYPES_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | /* #undef HAVE_JNI_H */ 21 | 22 | /* Define to 1 if you have the `memcpy' function. */ 23 | #define HAVE_MEMCPY 1 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #define HAVE_MEMORY_H 1 27 | 28 | /* Define to 1 if you have the `memset' function. */ 29 | #define HAVE_MEMSET 1 30 | 31 | /* Define if your compiler supports prototypes */ 32 | #define HAVE_PROTOTYPES 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_STDDEF_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_STDINT_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_STDLIB_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_STRINGS_H 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_STRING_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_SYS_STAT_H 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_SYS_TYPES_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_UNISTD_H 1 57 | 58 | /* Define to 1 if the system has the type `unsigned char'. */ 59 | #define HAVE_UNSIGNED_CHAR 1 60 | 61 | /* Define to 1 if the system has the type `unsigned short'. */ 62 | #define HAVE_UNSIGNED_SHORT 1 63 | 64 | /* Compiler does not support pointers to undefined structures. */ 65 | /* #undef INCOMPLETE_TYPES_BROKEN */ 66 | 67 | /* libjpeg API version */ 68 | #define JPEG_LIB_VERSION 62 69 | 70 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 71 | */ 72 | #define LT_OBJDIR ".libs/" 73 | 74 | /* Define if you have BSD-like bzero and bcopy */ 75 | /* #undef NEED_BSD_STRINGS */ 76 | 77 | /* Define if you need short function names */ 78 | /* #undef NEED_SHORT_EXTERNAL_NAMES */ 79 | 80 | /* Define if you have sys/types.h */ 81 | #define NEED_SYS_TYPES_H 1 82 | 83 | /* Name of package */ 84 | #define PACKAGE "libjpeg-turbo" 85 | 86 | /* Define to the address where bug reports for this package should be sent. */ 87 | #define PACKAGE_BUGREPORT "" 88 | 89 | /* Define to the full name of this package. */ 90 | #define PACKAGE_NAME "libjpeg-turbo" 91 | 92 | /* Define to the full name and version of this package. */ 93 | #define PACKAGE_STRING "libjpeg-turbo 1.1.90" 94 | 95 | /* Define to the one symbol short name of this package. */ 96 | #define PACKAGE_TARNAME "libjpeg-turbo" 97 | 98 | /* Define to the home page for this package. */ 99 | #define PACKAGE_URL "" 100 | 101 | /* Define to the version of this package. */ 102 | #define PACKAGE_VERSION "1.1.90" 103 | 104 | /* Define if shift is unsigned */ 105 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */ 106 | 107 | /* Define to 1 if you have the ANSI C header files. */ 108 | #define STDC_HEADERS 1 109 | 110 | /* Version number of package */ 111 | #define VERSION "1.1.90" 112 | 113 | /* Use accelerated SIMD routines. */ 114 | #define WITH_SIMD 1 115 | 116 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */ 117 | #ifndef __CHAR_UNSIGNED__ 118 | /* # undef __CHAR_UNSIGNED__ */ 119 | #endif 120 | 121 | /* Define to empty if `const' does not conform to ANSI C. */ 122 | /* #undef const */ 123 | 124 | /* Define to `__inline__' or `__inline' if that's what the C compiler 125 | calls it, or to nothing if 'inline' is not supported under any name. */ 126 | #ifndef __cplusplus 127 | /* #undef inline */ 128 | #endif 129 | 130 | /* Define to `unsigned int' if does not define. */ 131 | /* #undef size_t */ 132 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/android/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h. Generated from jconfig.h.in by configure. */ 2 | /* Version ID for the JPEG library. 3 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". 4 | */ 5 | #define JPEG_LIB_VERSION 62 6 | 7 | /* Support arithmetic encoding */ 8 | #define C_ARITH_CODING_SUPPORTED 1 9 | 10 | /* Support arithmetic decoding */ 11 | #define D_ARITH_CODING_SUPPORTED 1 12 | 13 | /* Define if your compiler supports prototypes */ 14 | #define HAVE_PROTOTYPES 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_STDDEF_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_STDLIB_H 1 21 | 22 | /* Define to 1 if the system has the type `unsigned char'. */ 23 | #define HAVE_UNSIGNED_CHAR 1 24 | 25 | /* Define to 1 if the system has the type `unsigned short'. */ 26 | #define HAVE_UNSIGNED_SHORT 1 27 | 28 | /* Define if you want use complete types */ 29 | /* #undef INCOMPLETE_TYPES_BROKEN */ 30 | 31 | /* Define if you have BSD-like bzero and bcopy */ 32 | /* #undef NEED_BSD_STRINGS */ 33 | 34 | /* Define if you need short function names */ 35 | /* #undef NEED_SHORT_EXTERNAL_NAMES */ 36 | 37 | /* Define if you have sys/types.h */ 38 | #define NEED_SYS_TYPES_H 1 39 | 40 | /* Define if shift is unsigned */ 41 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */ 42 | 43 | /* Use accelerated SIMD routines. */ 44 | #define WITH_SIMD 1 45 | 46 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */ 47 | #ifndef __CHAR_UNSIGNED__ 48 | /* # undef __CHAR_UNSIGNED__ */ 49 | #endif 50 | 51 | /* Define to empty if `const' does not conform to ANSI C. */ 52 | /* #undef const */ 53 | 54 | /* Define to `__inline__' or `__inline' if that's what the C compiler 55 | calls it, or to nothing if 'inline' is not supported under any name. */ 56 | #ifndef __cplusplus 57 | /* #undef inline */ 58 | #endif 59 | 60 | /* Define to `unsigned int' if does not define. */ 61 | /* #undef size_t */ 62 | 63 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/cderror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cderror.h 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * Modified 2009 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file defines the error and message codes for the cjpeg/djpeg 10 | * applications. These strings are not needed as part of the JPEG library 11 | * proper. 12 | * Edit this file to add new codes, or to translate the message strings to 13 | * some other language. 14 | */ 15 | 16 | /* 17 | * To define the enum list of message codes, include this file without 18 | * defining macro JMESSAGE. To create a message string table, include it 19 | * again with a suitable JMESSAGE definition (see jerror.c for an example). 20 | */ 21 | #ifndef JMESSAGE 22 | #ifndef CDERROR_H 23 | #define CDERROR_H 24 | /* First time through, define the enum list */ 25 | #define JMAKE_ENUM_LIST 26 | #else 27 | /* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ 28 | #define JMESSAGE(code,string) 29 | #endif /* CDERROR_H */ 30 | #endif /* JMESSAGE */ 31 | 32 | #ifdef JMAKE_ENUM_LIST 33 | 34 | typedef enum { 35 | 36 | #define JMESSAGE(code,string) code , 37 | 38 | #endif /* JMAKE_ENUM_LIST */ 39 | 40 | JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ 41 | 42 | #ifdef BMP_SUPPORTED 43 | JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") 44 | JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") 45 | JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") 46 | JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") 47 | JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") 48 | JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") 49 | JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image") 50 | JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") 51 | JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") 52 | JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") 53 | JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") 54 | JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") 55 | #endif /* BMP_SUPPORTED */ 56 | 57 | #ifdef GIF_SUPPORTED 58 | JMESSAGE(JERR_GIF_BUG, "GIF output got confused") 59 | JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") 60 | JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") 61 | JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") 62 | JMESSAGE(JERR_GIF_NOT, "Not a GIF file") 63 | JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") 64 | JMESSAGE(JTRC_GIF_BADVERSION, 65 | "Warning: unexpected GIF version number '%c%c%c'") 66 | JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") 67 | JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") 68 | JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") 69 | JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") 70 | JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") 71 | JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") 72 | #endif /* GIF_SUPPORTED */ 73 | 74 | #ifdef PPM_SUPPORTED 75 | JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") 76 | JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") 77 | JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file") 78 | JMESSAGE(JTRC_PGM, "%ux%u PGM image") 79 | JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") 80 | JMESSAGE(JTRC_PPM, "%ux%u PPM image") 81 | JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") 82 | #endif /* PPM_SUPPORTED */ 83 | 84 | #ifdef RLE_SUPPORTED 85 | JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") 86 | JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") 87 | JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") 88 | JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") 89 | JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") 90 | JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") 91 | JMESSAGE(JERR_RLE_NOT, "Not an RLE file") 92 | JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") 93 | JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") 94 | JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") 95 | JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") 96 | JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") 97 | JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") 98 | JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") 99 | #endif /* RLE_SUPPORTED */ 100 | 101 | #ifdef TARGA_SUPPORTED 102 | JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") 103 | JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") 104 | JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") 105 | JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") 106 | JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") 107 | JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") 108 | #else 109 | JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") 110 | #endif /* TARGA_SUPPORTED */ 111 | 112 | JMESSAGE(JERR_BAD_CMAP_FILE, 113 | "Color map file is invalid or of unsupported format") 114 | JMESSAGE(JERR_TOO_MANY_COLORS, 115 | "Output file format cannot handle %d colormap entries") 116 | JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") 117 | #ifdef TARGA_SUPPORTED 118 | JMESSAGE(JERR_UNKNOWN_FORMAT, 119 | "Unrecognized input file format --- perhaps you need -targa") 120 | #else 121 | JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") 122 | #endif 123 | JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") 124 | 125 | #ifdef JMAKE_ENUM_LIST 126 | 127 | JMSG_LASTADDONCODE 128 | } ADDON_MESSAGE_CODE; 129 | 130 | #undef JMAKE_ENUM_LIST 131 | #endif /* JMAKE_ENUM_LIST */ 132 | 133 | /* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ 134 | #undef JMESSAGE 135 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/cdjpeg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cdjpeg.h 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains common declarations for the sample applications 9 | * cjpeg and djpeg. It is NOT used by the core JPEG library. 10 | */ 11 | 12 | #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ 13 | #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ 14 | #include "jinclude.h" 15 | #include "jpeglib.h" 16 | #include "jerror.h" /* get library error codes too */ 17 | #include "cderror.h" /* get application-specific error codes */ 18 | 19 | 20 | /* 21 | * Object interface for cjpeg's source file decoding modules 22 | */ 23 | 24 | typedef struct cjpeg_source_struct * cjpeg_source_ptr; 25 | 26 | struct cjpeg_source_struct { 27 | JMETHOD(void, start_input, (j_compress_ptr cinfo, 28 | cjpeg_source_ptr sinfo)); 29 | JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, 30 | cjpeg_source_ptr sinfo)); 31 | JMETHOD(void, finish_input, (j_compress_ptr cinfo, 32 | cjpeg_source_ptr sinfo)); 33 | 34 | FILE *input_file; 35 | 36 | JSAMPARRAY buffer; 37 | JDIMENSION buffer_height; 38 | }; 39 | 40 | 41 | /* 42 | * Object interface for djpeg's output file encoding modules 43 | */ 44 | 45 | typedef struct djpeg_dest_struct * djpeg_dest_ptr; 46 | 47 | struct djpeg_dest_struct { 48 | /* start_output is called after jpeg_start_decompress finishes. 49 | * The color map will be ready at this time, if one is needed. 50 | */ 51 | JMETHOD(void, start_output, (j_decompress_ptr cinfo, 52 | djpeg_dest_ptr dinfo)); 53 | /* Emit the specified number of pixel rows from the buffer. */ 54 | JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, 55 | djpeg_dest_ptr dinfo, 56 | JDIMENSION rows_supplied)); 57 | /* Finish up at the end of the image. */ 58 | JMETHOD(void, finish_output, (j_decompress_ptr cinfo, 59 | djpeg_dest_ptr dinfo)); 60 | 61 | /* Target file spec; filled in by djpeg.c after object is created. */ 62 | FILE * output_file; 63 | 64 | /* Output pixel-row buffer. Created by module init or start_output. 65 | * Width is cinfo->output_width * cinfo->output_components; 66 | * height is buffer_height. 67 | */ 68 | JSAMPARRAY buffer; 69 | JDIMENSION buffer_height; 70 | }; 71 | 72 | 73 | /* 74 | * cjpeg/djpeg may need to perform extra passes to convert to or from 75 | * the source/destination file format. The JPEG library does not know 76 | * about these passes, but we'd like them to be counted by the progress 77 | * monitor. We use an expanded progress monitor object to hold the 78 | * additional pass count. 79 | */ 80 | 81 | struct cdjpeg_progress_mgr { 82 | struct jpeg_progress_mgr pub; /* fields known to JPEG library */ 83 | int completed_extra_passes; /* extra passes completed */ 84 | int total_extra_passes; /* total extra */ 85 | /* last printed percentage stored here to avoid multiple printouts */ 86 | int percent_done; 87 | }; 88 | 89 | typedef struct cdjpeg_progress_mgr * cd_progress_ptr; 90 | 91 | 92 | /* Short forms of external names for systems with brain-damaged linkers. */ 93 | 94 | #ifdef NEED_SHORT_EXTERNAL_NAMES 95 | #define jinit_read_bmp jIRdBMP 96 | #define jinit_write_bmp jIWrBMP 97 | #define jinit_read_gif jIRdGIF 98 | #define jinit_write_gif jIWrGIF 99 | #define jinit_read_ppm jIRdPPM 100 | #define jinit_write_ppm jIWrPPM 101 | #define jinit_read_rle jIRdRLE 102 | #define jinit_write_rle jIWrRLE 103 | #define jinit_read_targa jIRdTarga 104 | #define jinit_write_targa jIWrTarga 105 | #define read_quant_tables RdQTables 106 | #define read_scan_script RdScnScript 107 | #define set_quality_ratings SetQRates 108 | #define set_quant_slots SetQSlots 109 | #define set_sample_factors SetSFacts 110 | #define read_color_map RdCMap 111 | #define enable_signal_catcher EnSigCatcher 112 | #define start_progress_monitor StProgMon 113 | #define end_progress_monitor EnProgMon 114 | #define read_stdin RdStdin 115 | #define write_stdout WrStdout 116 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ 117 | 118 | /* Module selection routines for I/O modules. */ 119 | 120 | EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); 121 | EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, 122 | boolean is_os2)); 123 | EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); 124 | EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); 125 | EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); 126 | EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); 127 | EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); 128 | EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); 129 | EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); 130 | EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); 131 | 132 | /* cjpeg support routines (in rdswitch.c) */ 133 | 134 | EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, 135 | boolean force_baseline)); 136 | EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); 137 | EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg, 138 | boolean force_baseline)); 139 | EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); 140 | EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); 141 | 142 | /* djpeg support routines (in rdcolmap.c) */ 143 | 144 | EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); 145 | 146 | /* common support routines (in cdjpeg.c) */ 147 | 148 | EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); 149 | EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, 150 | cd_progress_ptr progress)); 151 | EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); 152 | EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); 153 | EXTERN(FILE *) read_stdin JPP((void)); 154 | EXTERN(FILE *) write_stdout JPP((void)); 155 | 156 | /* miscellaneous useful macros */ 157 | 158 | #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ 159 | #define READ_BINARY "r" 160 | #define WRITE_BINARY "w" 161 | #else 162 | #ifdef VMS /* VMS is very nonstandard */ 163 | #define READ_BINARY "rb", "ctx=stm" 164 | #define WRITE_BINARY "wb", "ctx=stm" 165 | #else /* standard ANSI-compliant case */ 166 | #define READ_BINARY "rb" 167 | #define WRITE_BINARY "wb" 168 | #endif 169 | #endif 170 | 171 | #ifndef EXIT_FAILURE /* define exit() codes if not provided */ 172 | #define EXIT_FAILURE 1 173 | #endif 174 | #ifndef EXIT_SUCCESS 175 | #ifdef VMS 176 | #define EXIT_SUCCESS 1 /* VMS is very nonstandard */ 177 | #else 178 | #define EXIT_SUCCESS 0 179 | #endif 180 | #endif 181 | #ifndef EXIT_WARNING 182 | #ifdef VMS 183 | #define EXIT_WARNING 1 /* VMS is very nonstandard */ 184 | #else 185 | #define EXIT_WARNING 2 186 | #endif 187 | #endif 188 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h. Generated from jconfig.h.in by configure. */ 2 | /* Version ID for the JPEG library. 3 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". 4 | */ 5 | #define JPEG_LIB_VERSION 62 6 | 7 | /* Support arithmetic encoding */ 8 | #define C_ARITH_CODING_SUPPORTED 1 9 | 10 | /* Support arithmetic decoding */ 11 | #define D_ARITH_CODING_SUPPORTED 1 12 | 13 | /* Define if your compiler supports prototypes */ 14 | #define HAVE_PROTOTYPES 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_STDDEF_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_STDLIB_H 1 21 | 22 | /* Define to 1 if the system has the type `unsigned char'. */ 23 | #define HAVE_UNSIGNED_CHAR 1 24 | 25 | /* Define to 1 if the system has the type `unsigned short'. */ 26 | #define HAVE_UNSIGNED_SHORT 1 27 | 28 | /* Define if you want use complete types */ 29 | /* #undef INCOMPLETE_TYPES_BROKEN */ 30 | 31 | /* Define if you have BSD-like bzero and bcopy */ 32 | /* #undef NEED_BSD_STRINGS */ 33 | 34 | /* Define if you need short function names */ 35 | /* #undef NEED_SHORT_EXTERNAL_NAMES */ 36 | 37 | /* Define if you have sys/types.h */ 38 | #define NEED_SYS_TYPES_H 1 39 | 40 | /* Define if shift is unsigned */ 41 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */ 42 | 43 | /* Use accelerated SIMD routines. */ 44 | #define WITH_SIMD 1 45 | 46 | /* Define to 1 if type `char' is unsigned and you are not using gcc. */ 47 | #ifndef __CHAR_UNSIGNED__ 48 | /* # undef __CHAR_UNSIGNED__ */ 49 | #endif 50 | 51 | /* Define to empty if `const' does not conform to ANSI C. */ 52 | /* #undef const */ 53 | 54 | /* Define to `__inline__' or `__inline' if that's what the C compiler 55 | calls it, or to nothing if 'inline' is not supported under any name. */ 56 | #ifndef __cplusplus 57 | /* #undef inline */ 58 | #endif 59 | 60 | #define INLINE inline 61 | 62 | /* Define to `unsigned int' if does not define. */ 63 | /* #undef size_t */ 64 | 65 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/jerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jerror.h 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * Modified 1997-2009 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file defines the error and message codes for the JPEG library. 10 | * Edit this file to add new codes, or to translate the message strings to 11 | * some other language. 12 | * A set of error-reporting macros are defined too. Some applications using 13 | * the JPEG library may wish to include this file to get the error codes 14 | * and/or the macros. 15 | */ 16 | 17 | /* 18 | * To define the enum list of message codes, include this file without 19 | * defining macro JMESSAGE. To create a message string table, include it 20 | * again with a suitable JMESSAGE definition (see jerror.c for an example). 21 | */ 22 | #ifndef JMESSAGE 23 | #ifndef JERROR_H 24 | /* First time through, define the enum list */ 25 | #define JMAKE_ENUM_LIST 26 | #else 27 | /* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ 28 | #define JMESSAGE(code,string) 29 | #endif /* JERROR_H */ 30 | #endif /* JMESSAGE */ 31 | 32 | #ifdef JMAKE_ENUM_LIST 33 | 34 | typedef enum { 35 | 36 | #define JMESSAGE(code,string) code , 37 | 38 | #endif /* JMAKE_ENUM_LIST */ 39 | 40 | JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ 41 | 42 | /* For maintenance convenience, list is alphabetical by message code name */ 43 | #if JPEG_LIB_VERSION < 70 44 | JMESSAGE(JERR_ARITH_NOTIMPL, 45 | "Sorry, arithmetic coding is not implemented") 46 | #endif 47 | JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") 48 | JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") 49 | JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") 50 | JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") 51 | #if JPEG_LIB_VERSION >= 70 52 | JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request") 53 | #endif 54 | JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") 55 | JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") 56 | #if JPEG_LIB_VERSION >= 70 57 | JMESSAGE(JERR_BAD_DROP_SAMPLING, 58 | "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c") 59 | #endif 60 | JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") 61 | JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") 62 | JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") 63 | JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") 64 | JMESSAGE(JERR_BAD_LIB_VERSION, 65 | "Wrong JPEG library version: library is %d, caller expects %d") 66 | JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") 67 | JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") 68 | JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") 69 | JMESSAGE(JERR_BAD_PROGRESSION, 70 | "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") 71 | JMESSAGE(JERR_BAD_PROG_SCRIPT, 72 | "Invalid progressive parameters at scan script entry %d") 73 | JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") 74 | JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") 75 | JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") 76 | JMESSAGE(JERR_BAD_STRUCT_SIZE, 77 | "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") 78 | JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") 79 | JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") 80 | JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") 81 | JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") 82 | JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") 83 | JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") 84 | JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") 85 | JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") 86 | JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") 87 | JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") 88 | JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") 89 | JMESSAGE(JERR_EMS_READ, "Read from EMS failed") 90 | JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") 91 | JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") 92 | JMESSAGE(JERR_FILE_READ, "Input file read error") 93 | JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") 94 | JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") 95 | JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") 96 | JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") 97 | JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") 98 | JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") 99 | JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") 100 | JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, 101 | "Cannot transcode due to multiple use of quantization table %d") 102 | JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") 103 | JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") 104 | JMESSAGE(JERR_NOTIMPL, "Not implemented yet") 105 | JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") 106 | #if JPEG_LIB_VERSION >= 70 107 | JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined") 108 | #endif 109 | JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") 110 | JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") 111 | JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") 112 | JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") 113 | JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") 114 | JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") 115 | JMESSAGE(JERR_QUANT_COMPONENTS, 116 | "Cannot quantize more than %d color components") 117 | JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") 118 | JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") 119 | JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") 120 | JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") 121 | JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") 122 | JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") 123 | JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") 124 | JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") 125 | JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") 126 | JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") 127 | JMESSAGE(JERR_TFILE_WRITE, 128 | "Write failed on temporary file --- out of disk space?") 129 | JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") 130 | JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") 131 | JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") 132 | JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") 133 | JMESSAGE(JERR_XMS_READ, "Read from XMS failed") 134 | JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") 135 | JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) 136 | JMESSAGE(JMSG_VERSION, JVERSION) 137 | JMESSAGE(JTRC_16BIT_TABLES, 138 | "Caution: quantization tables are too coarse for baseline JPEG") 139 | JMESSAGE(JTRC_ADOBE, 140 | "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") 141 | JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") 142 | JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") 143 | JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") 144 | JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") 145 | JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") 146 | JMESSAGE(JTRC_DRI, "Define Restart Interval %u") 147 | JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") 148 | JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") 149 | JMESSAGE(JTRC_EOI, "End Of Image") 150 | JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") 151 | JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") 152 | JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, 153 | "Warning: thumbnail image size does not match data length %u") 154 | JMESSAGE(JTRC_JFIF_EXTENSION, 155 | "JFIF extension marker: type 0x%02x, length %u") 156 | JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") 157 | JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") 158 | JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") 159 | JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") 160 | JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") 161 | JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") 162 | JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") 163 | JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") 164 | JMESSAGE(JTRC_RST, "RST%d") 165 | JMESSAGE(JTRC_SMOOTH_NOTIMPL, 166 | "Smoothing not supported with nonstandard sampling ratios") 167 | JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") 168 | JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") 169 | JMESSAGE(JTRC_SOI, "Start of Image") 170 | JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") 171 | JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") 172 | JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") 173 | JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") 174 | JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") 175 | JMESSAGE(JTRC_THUMB_JPEG, 176 | "JFIF extension marker: JPEG-compressed thumbnail image, length %u") 177 | JMESSAGE(JTRC_THUMB_PALETTE, 178 | "JFIF extension marker: palette thumbnail image, length %u") 179 | JMESSAGE(JTRC_THUMB_RGB, 180 | "JFIF extension marker: RGB thumbnail image, length %u") 181 | JMESSAGE(JTRC_UNKNOWN_IDS, 182 | "Unrecognized component IDs %d %d %d, assuming YCbCr") 183 | JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") 184 | JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") 185 | JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") 186 | #if JPEG_LIB_VERSION >= 70 187 | JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code") 188 | #endif 189 | JMESSAGE(JWRN_BOGUS_PROGRESSION, 190 | "Inconsistent progression sequence for component %d coefficient %d") 191 | JMESSAGE(JWRN_EXTRANEOUS_DATA, 192 | "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") 193 | JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") 194 | JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") 195 | JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") 196 | JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") 197 | JMESSAGE(JWRN_MUST_RESYNC, 198 | "Corrupt JPEG data: found marker 0x%02x instead of RST%d") 199 | JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") 200 | JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") 201 | #if JPEG_LIB_VERSION < 70 202 | JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request") 203 | #if defined(C_ARITH_CODING_SUPPORTED) || defined(D_ARITH_CODING_SUPPORTED) 204 | JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined") 205 | JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code") 206 | #endif 207 | #endif 208 | 209 | #ifdef JMAKE_ENUM_LIST 210 | 211 | JMSG_LASTMSGCODE 212 | } J_MESSAGE_CODE; 213 | 214 | #undef JMAKE_ENUM_LIST 215 | #endif /* JMAKE_ENUM_LIST */ 216 | 217 | /* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ 218 | #undef JMESSAGE 219 | 220 | 221 | #ifndef JERROR_H 222 | #define JERROR_H 223 | 224 | /* Macros to simplify using the error and trace message stuff */ 225 | /* The first parameter is either type of cinfo pointer */ 226 | 227 | /* Fatal errors (print message and exit) */ 228 | #define ERREXIT(cinfo,code) \ 229 | ((cinfo)->err->msg_code = (code), \ 230 | (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) 231 | #define ERREXIT1(cinfo,code,p1) \ 232 | ((cinfo)->err->msg_code = (code), \ 233 | (cinfo)->err->msg_parm.i[0] = (p1), \ 234 | (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) 235 | #define ERREXIT2(cinfo,code,p1,p2) \ 236 | ((cinfo)->err->msg_code = (code), \ 237 | (cinfo)->err->msg_parm.i[0] = (p1), \ 238 | (cinfo)->err->msg_parm.i[1] = (p2), \ 239 | (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) 240 | #define ERREXIT3(cinfo,code,p1,p2,p3) \ 241 | ((cinfo)->err->msg_code = (code), \ 242 | (cinfo)->err->msg_parm.i[0] = (p1), \ 243 | (cinfo)->err->msg_parm.i[1] = (p2), \ 244 | (cinfo)->err->msg_parm.i[2] = (p3), \ 245 | (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) 246 | #define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ 247 | ((cinfo)->err->msg_code = (code), \ 248 | (cinfo)->err->msg_parm.i[0] = (p1), \ 249 | (cinfo)->err->msg_parm.i[1] = (p2), \ 250 | (cinfo)->err->msg_parm.i[2] = (p3), \ 251 | (cinfo)->err->msg_parm.i[3] = (p4), \ 252 | (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) 253 | #define ERREXITS(cinfo,code,str) \ 254 | ((cinfo)->err->msg_code = (code), \ 255 | strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ 256 | (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) 257 | 258 | #define MAKESTMT(stuff) do { stuff } while (0) 259 | 260 | /* Nonfatal errors (we can keep going, but the data is probably corrupt) */ 261 | #define WARNMS(cinfo,code) \ 262 | ((cinfo)->err->msg_code = (code), \ 263 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) 264 | #define WARNMS1(cinfo,code,p1) \ 265 | ((cinfo)->err->msg_code = (code), \ 266 | (cinfo)->err->msg_parm.i[0] = (p1), \ 267 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) 268 | #define WARNMS2(cinfo,code,p1,p2) \ 269 | ((cinfo)->err->msg_code = (code), \ 270 | (cinfo)->err->msg_parm.i[0] = (p1), \ 271 | (cinfo)->err->msg_parm.i[1] = (p2), \ 272 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) 273 | 274 | /* Informational/debugging messages */ 275 | #define TRACEMS(cinfo,lvl,code) \ 276 | ((cinfo)->err->msg_code = (code), \ 277 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) 278 | #define TRACEMS1(cinfo,lvl,code,p1) \ 279 | ((cinfo)->err->msg_code = (code), \ 280 | (cinfo)->err->msg_parm.i[0] = (p1), \ 281 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) 282 | #define TRACEMS2(cinfo,lvl,code,p1,p2) \ 283 | ((cinfo)->err->msg_code = (code), \ 284 | (cinfo)->err->msg_parm.i[0] = (p1), \ 285 | (cinfo)->err->msg_parm.i[1] = (p2), \ 286 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) 287 | #define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ 288 | MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ 289 | _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ 290 | (cinfo)->err->msg_code = (code); \ 291 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) 292 | #define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ 293 | MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ 294 | _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ 295 | (cinfo)->err->msg_code = (code); \ 296 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) 297 | #define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ 298 | MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ 299 | _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ 300 | _mp[4] = (p5); \ 301 | (cinfo)->err->msg_code = (code); \ 302 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) 303 | #define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ 304 | MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ 305 | _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ 306 | _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ 307 | (cinfo)->err->msg_code = (code); \ 308 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) 309 | #define TRACEMSS(cinfo,lvl,code,str) \ 310 | ((cinfo)->err->msg_code = (code), \ 311 | strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ 312 | (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) 313 | 314 | #endif /* JERROR_H */ 315 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/jinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jinclude.h 3 | * 4 | * Copyright (C) 1991-1994, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file exists to provide a single place to fix any problems with 9 | * including the wrong system include files. (Common problems are taken 10 | * care of by the standard jconfig symbols, but on really weird systems 11 | * you may have to edit this file.) 12 | * 13 | * NOTE: this file is NOT intended to be included by applications using the 14 | * JPEG library. Most applications need only include jpeglib.h. 15 | */ 16 | 17 | 18 | /* Include auto-config file to find out which system include files we need. */ 19 | 20 | #include "jconfig.h" /* auto configuration options */ 21 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 22 | 23 | /* 24 | * We need the NULL macro and size_t typedef. 25 | * On an ANSI-conforming system it is sufficient to include . 26 | * Otherwise, we get them from or ; we may have to 27 | * pull in as well. 28 | * Note that the core JPEG library does not require ; 29 | * only the default error handler and data source/destination modules do. 30 | * But we must pull it in because of the references to FILE in jpeglib.h. 31 | * You can remove those references if you want to compile without . 32 | */ 33 | 34 | #ifdef HAVE_STDDEF_H 35 | #include 36 | #endif 37 | 38 | #ifdef HAVE_STDLIB_H 39 | #include 40 | #endif 41 | 42 | #ifdef NEED_SYS_TYPES_H 43 | #include 44 | #endif 45 | 46 | #include 47 | 48 | /* 49 | * We need memory copying and zeroing functions, plus strncpy(). 50 | * ANSI and System V implementations declare these in . 51 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 52 | * Some systems may declare memset and memcpy in . 53 | * 54 | * NOTE: we assume the size parameters to these functions are of type size_t. 55 | * Change the casts in these macros if not! 56 | */ 57 | 58 | #ifdef NEED_BSD_STRINGS 59 | 60 | #include 61 | #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 62 | #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 63 | 64 | #else /* not BSD, assume ANSI/SysV string lib */ 65 | 66 | #include 67 | #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 68 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 69 | 70 | #endif 71 | 72 | /* 73 | * In ANSI C, and indeed any rational implementation, size_t is also the 74 | * type returned by sizeof(). However, it seems there are some irrational 75 | * implementations out there, in which sizeof() returns an int even though 76 | * size_t is defined as long or unsigned long. To ensure consistent results 77 | * we always use this SIZEOF() macro in place of using sizeof() directly. 78 | */ 79 | 80 | #define SIZEOF(object) ((size_t) sizeof(object)) 81 | 82 | /* 83 | * The modules that use fread() and fwrite() always invoke them through 84 | * these macros. On some systems you may need to twiddle the argument casts. 85 | * CAUTION: argument order is different from underlying functions! 86 | */ 87 | 88 | #define JFREAD(file,buf,sizeofbuf) \ 89 | ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 90 | #define JFWRITE(file,buf,sizeofbuf) \ 91 | ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 92 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/jmorecfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jmorecfg.h 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * Copyright (C) 2009, 2011, D. R. Commander. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains additional configuration options that customize the 10 | * JPEG software for special applications or support machine-dependent 11 | * optimizations. Most users will not need to touch this file. 12 | */ 13 | 14 | /* 15 | * When we're building for android, turn on ANDROID_RGB by default. 16 | * This is needed for components like skia which make use of the 17 | * new encodings defined behind ANDROID_RBG. It's not a reasonable 18 | * config to have ANDROID_RBG off. 19 | */ 20 | #ifdef ANDROID 21 | #ifndef ANDROID_RGB 22 | #define ANDROID_RGB 23 | #endif 24 | #endif 25 | 26 | /* 27 | * Define BITS_IN_JSAMPLE as either 28 | * 8 for 8-bit sample values (the usual setting) 29 | * 12 for 12-bit sample values 30 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the 31 | * JPEG standard, and the IJG code does not support anything else! 32 | * We do not support run-time selection of data precision, sorry. 33 | */ 34 | 35 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ 36 | 37 | 38 | /* 39 | * Maximum number of components (color channels) allowed in JPEG image. 40 | * To meet the letter of the JPEG spec, set this to 255. However, darn 41 | * few applications need more than 4 channels (maybe 5 for CMYK + alpha 42 | * mask). We recommend 10 as a reasonable compromise; use 4 if you are 43 | * really short on memory. (Each allowed component costs a hundred or so 44 | * bytes of storage, whether actually used in an image or not.) 45 | */ 46 | 47 | #define MAX_COMPONENTS 10 /* maximum number of image components */ 48 | 49 | 50 | /* 51 | * Basic data types. 52 | * You may need to change these if you have a machine with unusual data 53 | * type sizes; for example, "char" not 8 bits, "short" not 16 bits, 54 | * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, 55 | * but it had better be at least 16. 56 | */ 57 | 58 | /* Representation of a single sample (pixel element value). 59 | * We frequently allocate large arrays of these, so it's important to keep 60 | * them small. But if you have memory to burn and access to char or short 61 | * arrays is very slow on your hardware, you might want to change these. 62 | */ 63 | 64 | #if BITS_IN_JSAMPLE == 8 65 | /* JSAMPLE should be the smallest type that will hold the values 0..255. 66 | * You can use a signed char by having GETJSAMPLE mask it with 0xFF. 67 | */ 68 | 69 | #ifdef HAVE_UNSIGNED_CHAR 70 | 71 | typedef unsigned char JSAMPLE; 72 | #define GETJSAMPLE(value) ((int) (value)) 73 | 74 | #else /* not HAVE_UNSIGNED_CHAR */ 75 | 76 | typedef char JSAMPLE; 77 | #ifdef __CHAR_UNSIGNED__ 78 | #define GETJSAMPLE(value) ((int) (value)) 79 | #else 80 | #define GETJSAMPLE(value) ((int) (value) & 0xFF) 81 | #endif /* __CHAR_UNSIGNED__ */ 82 | 83 | #endif /* HAVE_UNSIGNED_CHAR */ 84 | 85 | #define MAXJSAMPLE 255 86 | #define CENTERJSAMPLE 128 87 | 88 | #endif /* BITS_IN_JSAMPLE == 8 */ 89 | 90 | 91 | #if BITS_IN_JSAMPLE == 12 92 | /* JSAMPLE should be the smallest type that will hold the values 0..4095. 93 | * On nearly all machines "short" will do nicely. 94 | */ 95 | 96 | typedef short JSAMPLE; 97 | #define GETJSAMPLE(value) ((int) (value)) 98 | 99 | #define MAXJSAMPLE 4095 100 | #define CENTERJSAMPLE 2048 101 | 102 | #endif /* BITS_IN_JSAMPLE == 12 */ 103 | 104 | 105 | /* Representation of a DCT frequency coefficient. 106 | * This should be a signed value of at least 16 bits; "short" is usually OK. 107 | * Again, we allocate large arrays of these, but you can change to int 108 | * if you have memory to burn and "short" is really slow. 109 | */ 110 | 111 | typedef short JCOEF; 112 | 113 | 114 | /* Compressed datastreams are represented as arrays of JOCTET. 115 | * These must be EXACTLY 8 bits wide, at least once they are written to 116 | * external storage. Note that when using the stdio data source/destination 117 | * managers, this is also the data type passed to fread/fwrite. 118 | */ 119 | 120 | #ifdef HAVE_UNSIGNED_CHAR 121 | 122 | typedef unsigned char JOCTET; 123 | #define GETJOCTET(value) (value) 124 | 125 | #else /* not HAVE_UNSIGNED_CHAR */ 126 | 127 | typedef char JOCTET; 128 | #ifdef __CHAR_UNSIGNED__ 129 | #define GETJOCTET(value) (value) 130 | #else 131 | #define GETJOCTET(value) ((value) & 0xFF) 132 | #endif /* __CHAR_UNSIGNED__ */ 133 | 134 | #endif /* HAVE_UNSIGNED_CHAR */ 135 | 136 | 137 | /* These typedefs are used for various table entries and so forth. 138 | * They must be at least as wide as specified; but making them too big 139 | * won't cost a huge amount of memory, so we don't provide special 140 | * extraction code like we did for JSAMPLE. (In other words, these 141 | * typedefs live at a different point on the speed/space tradeoff curve.) 142 | */ 143 | 144 | /* UINT8 must hold at least the values 0..255. */ 145 | 146 | #ifdef HAVE_UNSIGNED_CHAR 147 | typedef unsigned char UINT8; 148 | #else /* not HAVE_UNSIGNED_CHAR */ 149 | #ifdef __CHAR_UNSIGNED__ 150 | typedef char UINT8; 151 | #else /* not __CHAR_UNSIGNED__ */ 152 | typedef short UINT8; 153 | #endif /* __CHAR_UNSIGNED__ */ 154 | #endif /* HAVE_UNSIGNED_CHAR */ 155 | 156 | /* UINT16 must hold at least the values 0..65535. */ 157 | 158 | #ifdef HAVE_UNSIGNED_SHORT 159 | typedef unsigned short UINT16; 160 | #else /* not HAVE_UNSIGNED_SHORT */ 161 | typedef unsigned int UINT16; 162 | #endif /* HAVE_UNSIGNED_SHORT */ 163 | 164 | /* INT16 must hold at least the values -32768..32767. */ 165 | 166 | #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ 167 | typedef short INT16; 168 | #endif 169 | 170 | /* INT32 must hold at least signed 32-bit values. */ 171 | 172 | #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ 173 | typedef long INT32; 174 | #endif 175 | 176 | /* Datatype used for image dimensions. The JPEG standard only supports 177 | * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore 178 | * "unsigned int" is sufficient on all machines. However, if you need to 179 | * handle larger images and you don't mind deviating from the spec, you 180 | * can change this datatype. 181 | */ 182 | 183 | typedef unsigned int JDIMENSION; 184 | 185 | #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ 186 | 187 | 188 | /* These macros are used in all function definitions and extern declarations. 189 | * You could modify them if you need to change function linkage conventions; 190 | * in particular, you'll need to do that to make the library a Windows DLL. 191 | * Another application is to make all functions global for use with debuggers 192 | * or code profilers that require it. 193 | */ 194 | 195 | /* a function called through method pointers: */ 196 | #define METHODDEF(type) static type 197 | /* a function used only in its module: */ 198 | #define LOCAL(type) static type 199 | /* a function referenced thru EXTERNs: */ 200 | #define GLOBAL(type) type 201 | /* a reference to a GLOBAL function: */ 202 | #define EXTERN(type) extern type 203 | 204 | 205 | /* This macro is used to declare a "method", that is, a function pointer. 206 | * We want to supply prototype parameters if the compiler can cope. 207 | * Note that the arglist parameter must be parenthesized! 208 | * Again, you can customize this if you need special linkage keywords. 209 | */ 210 | 211 | #ifdef HAVE_PROTOTYPES 212 | #define JMETHOD(type,methodname,arglist) type (*methodname) arglist 213 | #else 214 | #define JMETHOD(type,methodname,arglist) type (*methodname) () 215 | #endif 216 | 217 | 218 | /* Here is the pseudo-keyword for declaring pointers that must be "far" 219 | * on 80x86 machines. Most of the specialized coding for 80x86 is handled 220 | * by just saying "FAR *" where such a pointer is needed. In a few places 221 | * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. 222 | */ 223 | 224 | #ifdef NEED_FAR_POINTERS 225 | #define FAR far 226 | #else 227 | #define FAR 228 | #endif 229 | 230 | 231 | /* 232 | * On a few systems, type boolean and/or its values FALSE, TRUE may appear 233 | * in standard header files. Or you may have conflicts with application- 234 | * specific header files that you want to include together with these files. 235 | * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. 236 | */ 237 | 238 | #ifndef HAVE_BOOLEAN 239 | typedef int boolean; 240 | #endif 241 | #ifndef FALSE /* in case these macros already exist */ 242 | #define FALSE 0 /* values of boolean */ 243 | #endif 244 | #ifndef TRUE 245 | #define TRUE 1 246 | #endif 247 | 248 | 249 | /* 250 | * The remaining options affect code selection within the JPEG library, 251 | * but they don't need to be visible to most applications using the library. 252 | * To minimize application namespace pollution, the symbols won't be 253 | * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. 254 | */ 255 | 256 | #ifdef JPEG_INTERNALS 257 | #define JPEG_INTERNAL_OPTIONS 258 | #endif 259 | 260 | #ifdef JPEG_INTERNAL_OPTIONS 261 | 262 | 263 | /* 264 | * These defines indicate whether to include various optional functions. 265 | * Undefining some of these symbols will produce a smaller but less capable 266 | * library. Note that you can leave certain source files out of the 267 | * compilation/linking process if you've #undef'd the corresponding symbols. 268 | * (You may HAVE to do that if your compiler doesn't like null source files.) 269 | */ 270 | 271 | /* Capability options common to encoder and decoder: */ 272 | 273 | #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ 274 | #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ 275 | #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ 276 | 277 | /* Encoder capability options: */ 278 | 279 | #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 280 | #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 281 | #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ 282 | /* Note: if you selected 12-bit data precision, it is dangerous to turn off 283 | * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit 284 | * precision, so jchuff.c normally uses entropy optimization to compute 285 | * usable tables for higher precision. If you don't want to do optimization, 286 | * you'll have to supply different default Huffman tables. 287 | * The exact same statements apply for progressive JPEG: the default tables 288 | * don't work for progressive mode. (This may get fixed, however.) 289 | */ 290 | #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ 291 | 292 | /* Decoder capability options: */ 293 | 294 | #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ 295 | #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ 296 | #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ 297 | #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ 298 | #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ 299 | #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ 300 | #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ 301 | #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ 302 | #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ 303 | 304 | /* more capability options later, no doubt */ 305 | 306 | 307 | /* 308 | * Ordering of RGB data in scanlines passed to or from the application. 309 | * If your application wants to deal with data in the order B,G,R, just 310 | * change these macros. You can also deal with formats such as R,G,B,X 311 | * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing 312 | * the offsets will also change the order in which colormap data is organized. 313 | * RESTRICTIONS: 314 | * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. 315 | * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not 316 | * useful if you are using JPEG color spaces other than YCbCr or grayscale. 317 | * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE 318 | * is not 3 (they don't understand about dummy color components!). So you 319 | * can't use color quantization if you change that value. 320 | */ 321 | 322 | #define RGB_RED 0 /* Offset of Red in an RGB scanline element */ 323 | #define RGB_GREEN 1 /* Offset of Green */ 324 | #define RGB_BLUE 2 /* Offset of Blue */ 325 | #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ 326 | 327 | #ifdef ANDROID_RGB 328 | #define RGB_ALPHA 3 /* Offset of Alpha */ 329 | #endif 330 | 331 | #define JPEG_NUMCS 16 332 | 333 | #define EXT_RGB_RED 0 334 | #define EXT_RGB_GREEN 1 335 | #define EXT_RGB_BLUE 2 336 | #define EXT_RGB_PIXELSIZE 3 337 | 338 | #define EXT_RGBX_RED 0 339 | #define EXT_RGBX_GREEN 1 340 | #define EXT_RGBX_BLUE 2 341 | #define EXT_RGBX_PIXELSIZE 4 342 | 343 | #define EXT_BGR_RED 2 344 | #define EXT_BGR_GREEN 1 345 | #define EXT_BGR_BLUE 0 346 | #define EXT_BGR_PIXELSIZE 3 347 | 348 | #define EXT_BGRX_RED 2 349 | #define EXT_BGRX_GREEN 1 350 | #define EXT_BGRX_BLUE 0 351 | #define EXT_BGRX_PIXELSIZE 4 352 | 353 | #define EXT_XBGR_RED 3 354 | #define EXT_XBGR_GREEN 2 355 | #define EXT_XBGR_BLUE 1 356 | #define EXT_XBGR_PIXELSIZE 4 357 | 358 | #define EXT_XRGB_RED 1 359 | #define EXT_XRGB_GREEN 2 360 | #define EXT_XRGB_BLUE 3 361 | #define EXT_XRGB_PIXELSIZE 4 362 | 363 | #ifdef ANDROID_RGB 364 | #define RGB_ALPHA 3 /* Offset of Alpha */ 365 | #endif 366 | 367 | static const int rgb_red[JPEG_NUMCS] = { 368 | -1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED, 369 | EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED, 370 | EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED 371 | }; 372 | 373 | static const int rgb_green[JPEG_NUMCS] = { 374 | -1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN, 375 | EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN, 376 | EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN 377 | }; 378 | 379 | static const int rgb_blue[JPEG_NUMCS] = { 380 | -1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE, 381 | EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE, 382 | EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE 383 | }; 384 | 385 | static const int rgb_pixelsize[JPEG_NUMCS] = { 386 | -1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE, 387 | EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE, 388 | EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE 389 | }; 390 | 391 | 392 | /* 393 | * Define ANDROID_RGB to enable specific optimizations for Android 394 | * JCS_RGBA_8888 support 395 | * JCS_RGB_565 support 396 | * 397 | */ 398 | 399 | #ifdef ANDROID_RGB 400 | #define PACK_SHORT_565(r,g,b) ((((r)<<8)&0xf800)|(((g)<<3)&0x7E0)|((b)>>3)) 401 | #define PACK_TWO_PIXELS(l,r) ((r<<16) | l) 402 | #define PACK_NEED_ALIGNMENT(ptr) (((int)(ptr))&3) 403 | #define WRITE_TWO_PIXELS(addr, pixels) do { \ 404 | ((INT16*)(addr))[0] = (pixels); \ 405 | ((INT16*)(addr))[1] = (pixels)>>16; \ 406 | } while(0) 407 | #define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(INT32*)(addr)) = pixels) 408 | #define DITHER_565_R(r, dither) ((r) + ((dither)&0xFF)) 409 | #define DITHER_565_G(g, dither) ((g) + (((dither)&0xFF)>>1)) 410 | #define DITHER_565_B(b, dither) ((b) + ((dither)&0xFF)) 411 | #endif 412 | 413 | 414 | /* Definitions for speed-related optimizations. */ 415 | 416 | /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying 417 | * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER 418 | * as short on such a machine. MULTIPLIER must be at least 16 bits wide. 419 | */ 420 | 421 | #ifndef MULTIPLIER 422 | #ifndef WITH_SIMD 423 | #define MULTIPLIER int /* type for fastest integer multiply */ 424 | #else 425 | #define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */ 426 | #endif 427 | #endif 428 | 429 | 430 | /* FAST_FLOAT should be either float or double, whichever is done faster 431 | * by your compiler. (Note that this type is only used in the floating point 432 | * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) 433 | * Typically, float is faster in ANSI C compilers, while double is faster in 434 | * pre-ANSI compilers (because they insist on converting to double anyway). 435 | * The code below therefore chooses float if we have ANSI-style prototypes. 436 | */ 437 | 438 | #ifndef FAST_FLOAT 439 | #ifdef HAVE_PROTOTYPES 440 | #define FAST_FLOAT float 441 | #else 442 | #define FAST_FLOAT double 443 | #endif 444 | #endif 445 | 446 | #endif /* JPEG_INTERNAL_OPTIONS */ 447 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding. 5 | * Copyright (C) 2010, D. R. Commander. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains software version identification. 10 | */ 11 | 12 | 13 | #if JPEG_LIB_VERSION >= 80 14 | 15 | #define JVERSION "8b 16-May-2010" 16 | 17 | #define JCOPYRIGHT "Copyright (C) 2010, Thomas G. Lane, Guido Vollbeding" 18 | 19 | #elif JPEG_LIB_VERSION >= 70 20 | 21 | #define JVERSION "7 27-Jun-2009" 22 | 23 | #define JCOPYRIGHT "Copyright (C) 2009, Thomas G. Lane, Guido Vollbeding" 24 | 25 | #else 26 | 27 | #define JVERSION "6b 27-Mar-1998" 28 | 29 | #define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" 30 | 31 | #endif 32 | 33 | #define LJTCOPYRIGHT "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \ 34 | "Copyright (C) 2009 Pierre Ossman for Cendio AB\n" \ 35 | "Copyright (C) 2009-2011 D. R. Commander\n" \ 36 | "Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)" 37 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg-turbo/transupp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * transupp.h 3 | * 4 | * Copyright (C) 1997-2013, Thomas G. Lane, Guido Vollbeding. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains declarations for image transformation routines and 9 | * other utility code used by the jpegtran sample application. These are 10 | * NOT part of the core JPEG library. But we keep these routines separate 11 | * from jpegtran.c to ease the task of maintaining jpegtran-like programs 12 | * that have other user interfaces. 13 | * 14 | * NOTE: all the routines declared here have very specific requirements 15 | * about when they are to be executed during the reading and writing of the 16 | * source and destination files. See the comments in transupp.c, or see 17 | * jpegtran.c for an example of correct usage. 18 | */ 19 | 20 | /* If you happen not to want the image transform support, disable it here */ 21 | #ifndef TRANSFORMS_SUPPORTED 22 | #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ 23 | #endif 24 | 25 | /* 26 | * Although rotating and flipping data expressed as DCT coefficients is not 27 | * hard, there is an asymmetry in the JPEG format specification for images 28 | * whose dimensions aren't multiples of the iMCU size. The right and bottom 29 | * image edges are padded out to the next iMCU boundary with junk data; but 30 | * no padding is possible at the top and left edges. If we were to flip 31 | * the whole image including the pad data, then pad garbage would become 32 | * visible at the top and/or left, and real pixels would disappear into the 33 | * pad margins --- perhaps permanently, since encoders & decoders may not 34 | * bother to preserve DCT blocks that appear to be completely outside the 35 | * nominal image area. So, we have to exclude any partial iMCUs from the 36 | * basic transformation. 37 | * 38 | * Transpose is the only transformation that can handle partial iMCUs at the 39 | * right and bottom edges completely cleanly. flip_h can flip partial iMCUs 40 | * at the bottom, but leaves any partial iMCUs at the right edge untouched. 41 | * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched. 42 | * The other transforms are defined as combinations of these basic transforms 43 | * and process edge blocks in a way that preserves the equivalence. 44 | * 45 | * The "trim" option causes untransformable partial iMCUs to be dropped; 46 | * this is not strictly lossless, but it usually gives the best-looking 47 | * result for odd-size images. Note that when this option is active, 48 | * the expected mathematical equivalences between the transforms may not hold. 49 | * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim 50 | * followed by -rot 180 -trim trims both edges.) 51 | * 52 | * We also offer a lossless-crop option, which discards data outside a given 53 | * image region but losslessly preserves what is inside. Like the rotate and 54 | * flip transforms, lossless crop is restricted by the current JPEG format: the 55 | * upper left corner of the selected region must fall on an iMCU boundary. If 56 | * this does not hold for the given crop parameters, we silently move the upper 57 | * left corner up and/or left to make it so, simultaneously increasing the 58 | * region dimensions to keep the lower right crop corner unchanged. (Thus, the 59 | * output image covers at least the requested region, but may cover more.) 60 | * The adjustment of the region dimensions may be optionally disabled. 61 | * 62 | * A complementary lossless-wipe option is provided to discard (gray out) data 63 | * inside a given image region while losslessly preserving what is outside. 64 | * 65 | * We also provide a lossless-resize option, which is kind of a lossless-crop 66 | * operation in the DCT coefficient block domain - it discards higher-order 67 | * coefficients and losslessly preserves lower-order coefficients of a 68 | * sub-block. 69 | * 70 | * Rotate/flip transform, resize, and crop can be requested together in a 71 | * single invocation. The crop is applied last --- that is, the crop region 72 | * is specified in terms of the destination image after transform/resize. 73 | * 74 | * We also offer a "force to grayscale" option, which simply discards the 75 | * chrominance channels of a YCbCr image. This is lossless in the sense that 76 | * the luminance channel is preserved exactly. It's not the same kind of 77 | * thing as the rotate/flip transformations, but it's convenient to handle it 78 | * as part of this package, mainly because the transformation routines have to 79 | * be aware of the option to know how many components to work on. 80 | */ 81 | 82 | 83 | /* Short forms of external names for systems with brain-damaged linkers. */ 84 | 85 | #ifdef NEED_SHORT_EXTERNAL_NAMES 86 | #define jtransform_parse_crop_spec jTrParCrop 87 | #define jtransform_request_workspace jTrRequest 88 | #define jtransform_adjust_parameters jTrAdjust 89 | #define jtransform_execute_transform jTrExec 90 | #define jtransform_perfect_transform jTrPerfect 91 | #define jcopy_markers_setup jCMrkSetup 92 | #define jcopy_markers_execute jCMrkExec 93 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ 94 | 95 | 96 | /* 97 | * Codes for supported types of image transformations. 98 | */ 99 | 100 | typedef enum { 101 | JXFORM_NONE, /* no transformation */ 102 | JXFORM_FLIP_H, /* horizontal flip */ 103 | JXFORM_FLIP_V, /* vertical flip */ 104 | JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ 105 | JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ 106 | JXFORM_ROT_90, /* 90-degree clockwise rotation */ 107 | JXFORM_ROT_180, /* 180-degree rotation */ 108 | JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */ 109 | JXFORM_WIPE /* wipe */ 110 | } JXFORM_CODE; 111 | 112 | /* 113 | * Codes for crop parameters, which can individually be unspecified, 114 | * positive or negative for xoffset or yoffset, 115 | * positive or forced for width or height. 116 | */ 117 | 118 | typedef enum { 119 | JCROP_UNSET, 120 | JCROP_POS, 121 | JCROP_NEG, 122 | JCROP_FORCE 123 | } JCROP_CODE; 124 | 125 | /* 126 | * Transform parameters struct. 127 | * NB: application must not change any elements of this struct after 128 | * calling jtransform_request_workspace. 129 | */ 130 | 131 | typedef struct { 132 | /* Options: set by caller */ 133 | JXFORM_CODE transform; /* image transform operator */ 134 | boolean perfect; /* if TRUE, fail if partial MCUs are requested */ 135 | boolean trim; /* if TRUE, trim partial MCUs as needed */ 136 | boolean force_grayscale; /* if TRUE, convert color image to grayscale */ 137 | boolean crop; /* if TRUE, crop or wipe source image */ 138 | 139 | /* Crop parameters: application need not set these unless crop is TRUE. 140 | * These can be filled in by jtransform_parse_crop_spec(). 141 | */ 142 | JDIMENSION crop_width; /* Width of selected region */ 143 | JCROP_CODE crop_width_set; /* (forced disables adjustment) */ 144 | JDIMENSION crop_height; /* Height of selected region */ 145 | JCROP_CODE crop_height_set; /* (forced disables adjustment) */ 146 | JDIMENSION crop_xoffset; /* X offset of selected region */ 147 | JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */ 148 | JDIMENSION crop_yoffset; /* Y offset of selected region */ 149 | JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */ 150 | 151 | /* Internal workspace: caller should not touch these */ 152 | int num_components; /* # of components in workspace */ 153 | jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ 154 | JDIMENSION output_width; /* cropped destination dimensions */ 155 | JDIMENSION output_height; 156 | JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */ 157 | JDIMENSION y_crop_offset; 158 | JDIMENSION drop_width; /* drop/wipe dimensions measured in iMCUs */ 159 | JDIMENSION drop_height; 160 | int iMCU_sample_width; /* destination iMCU size */ 161 | int iMCU_sample_height; 162 | } jpeg_transform_info; 163 | 164 | 165 | #if TRANSFORMS_SUPPORTED 166 | 167 | /* Parse a crop specification (written in X11 geometry style) */ 168 | EXTERN(boolean) jtransform_parse_crop_spec 169 | JPP((jpeg_transform_info *info, const char *spec)); 170 | /* Request any required workspace */ 171 | EXTERN(boolean) jtransform_request_workspace 172 | JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); 173 | /* Adjust output image parameters */ 174 | EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters 175 | JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, 176 | jvirt_barray_ptr *src_coef_arrays, 177 | jpeg_transform_info *info)); 178 | /* Execute the actual transformation, if any */ 179 | EXTERN(void) jtransform_execute_transform 180 | JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, 181 | jvirt_barray_ptr *src_coef_arrays, 182 | jpeg_transform_info *info)); 183 | /* Determine whether lossless transformation is perfectly 184 | * possible for a specified image and transformation. 185 | */ 186 | EXTERN(boolean) jtransform_perfect_transform 187 | JPP((JDIMENSION image_width, JDIMENSION image_height, 188 | int MCU_width, int MCU_height, 189 | JXFORM_CODE transform)); 190 | 191 | /* jtransform_execute_transform used to be called 192 | * jtransform_execute_transformation, but some compilers complain about 193 | * routine names that long. This macro is here to avoid breaking any 194 | * old source code that uses the original name... 195 | */ 196 | #define jtransform_execute_transformation jtransform_execute_transform 197 | 198 | #endif /* TRANSFORMS_SUPPORTED */ 199 | 200 | 201 | /* 202 | * Support for copying optional markers from source to destination file. 203 | */ 204 | 205 | typedef enum { 206 | JCOPYOPT_NONE, /* copy no optional markers */ 207 | JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ 208 | JCOPYOPT_ALL /* copy all optional markers */ 209 | } JCOPY_OPTION; 210 | 211 | #define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ 212 | 213 | /* Setup decompression object to save desired markers in memory */ 214 | EXTERN(void) jcopy_markers_setup 215 | JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); 216 | /* Copy markers saved in the given source object to the destination object */ 217 | EXTERN(void) jcopy_markers_execute 218 | JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, 219 | JCOPY_OPTION option)); 220 | -------------------------------------------------------------------------------- /app/src/main/jni/libjpeg.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/jni/libjpeg.so -------------------------------------------------------------------------------- /app/src/main/jni/libpng/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := png 6 | LOCAL_SRC_FILES := png.c pngerror.c pngget.c pngmem.c pngpread.c pngread.c pngrio.c \ 7 | pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c \ 8 | pngwutil.c 9 | 10 | include $(BUILD_STATIC_LIBRARY) 11 | -------------------------------------------------------------------------------- /app/src/main/jni/libpng/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the header file. */ 5 | #define HAVE_DLFCN_H 1 6 | 7 | /* Define to 1 if you have the `feenableexcept' function. */ 8 | /* #undef HAVE_FEENABLEEXCEPT */ 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #define HAVE_INTTYPES_H 1 12 | 13 | /* Define to 1 if you have the `m' library (-lm). */ 14 | /* #undef HAVE_LIBM */ 15 | 16 | /* Define to 1 if you have the `z' library (-lz). */ 17 | #define HAVE_LIBZ 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | /* #undef HAVE_MALLOC_H */ 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_MEMORY_H 1 24 | 25 | /* Define to 1 if you have the `memset' function. */ 26 | #define HAVE_MEMSET 1 27 | 28 | /* Define to 1 if you have the `pow' function. */ 29 | #define HAVE_POW 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_STDINT_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_STDLIB_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_STRINGS_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_STRING_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_SYS_STAT_H 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_SYS_TYPES_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_UNISTD_H 1 51 | 52 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 53 | */ 54 | #define LT_OBJDIR ".libs/" 55 | 56 | /* Name of package */ 57 | #define PACKAGE "libpng" 58 | 59 | /* Define to the address where bug reports for this package should be sent. */ 60 | #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" 61 | 62 | /* Define to the full name of this package. */ 63 | #define PACKAGE_NAME "libpng" 64 | 65 | /* Define to the full name and version of this package. */ 66 | #define PACKAGE_STRING "libpng 1.5.12" 67 | 68 | /* Define to the one symbol short name of this package. */ 69 | #define PACKAGE_TARNAME "libpng" 70 | 71 | /* Define to the home page for this package. */ 72 | #define PACKAGE_URL "" 73 | 74 | //fix build x86 75 | #define PNG_ARM_NEON_OPT 0 76 | 77 | /* Define to the version of this package. */ 78 | #define PACKAGE_VERSION "1.5.12" 79 | 80 | /* Align row buffers */ 81 | /* #undef PNG_ALIGNED_MEMORY_SUPPORTED */ 82 | 83 | /* Enable ARM NEON optimizations */ 84 | /* #undef PNG_ARM_NEON */ 85 | 86 | /* Define to 1 if you have the ANSI C header files. */ 87 | #define STDC_HEADERS 1 88 | 89 | /* Define to 1 if your declares `struct tm'. */ 90 | /* #undef TM_IN_SYS_TIME */ 91 | 92 | /* Version number of package */ 93 | #define VERSION "1.5.12" 94 | 95 | /* Define to empty if `const' does not conform to ANSI C. */ 96 | /* #undef const */ 97 | 98 | /* Define to the equivalent of the C99 'restrict' keyword, or to 99 | nothing if this is not supported. Do not define if restrict is 100 | supported directly. */ 101 | #define restrict __restrict 102 | /* Work around a bug in Sun C++: it does not support _Restrict or 103 | __restrict__, even though the corresponding Sun C compiler ends up with 104 | "#define restrict _Restrict" or "#define restrict __restrict__" in the 105 | previous line. Perhaps some future version of Sun C++ will work with 106 | restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ 107 | #if defined __SUNPRO_CC && !defined __RESTRICT 108 | # define _Restrict 109 | # define __restrict__ 110 | #endif 111 | 112 | /* Define to `unsigned int' if does not define. */ 113 | /* #undef size_t */ 114 | -------------------------------------------------------------------------------- /app/src/main/jni/libpng/pngdebug.h: -------------------------------------------------------------------------------- 1 | 2 | /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c 3 | * 4 | * Copyright (c) 1998-2011 Glenn Randers-Pehrson 5 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 | * 8 | * Last changed in libpng 1.5.0 [January 6, 2011] 9 | * 10 | * This code is released under the libpng license. 11 | * For conditions of distribution and use, see the disclaimer 12 | * and license in png.h 13 | */ 14 | 15 | /* Define PNG_DEBUG at compile time for debugging information. Higher 16 | * numbers for PNG_DEBUG mean more debugging information. This has 17 | * only been added since version 0.95 so it is not implemented throughout 18 | * libpng yet, but more support will be added as needed. 19 | * 20 | * png_debug[1-2]?(level, message ,arg{0-2}) 21 | * Expands to a statement (either a simple expression or a compound 22 | * do..while(0) statement) that outputs a message with parameter 23 | * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG 24 | * is undefined, 0 or 1 every png_debug expands to a simple expression 25 | * (actually ((void)0)). 26 | * 27 | * level: level of detail of message, starting at 0. A level 'n' 28 | * message is preceded by 'n' tab characters (not implemented 29 | * on Microsoft compilers unless PNG_DEBUG_FILE is also 30 | * defined, to allow debug DLL compilation with no standard IO). 31 | * message: a printf(3) style text string. A trailing '\n' is added 32 | * to the message. 33 | * arg: 0 to 2 arguments for printf(3) style substitution in message. 34 | */ 35 | #ifndef PNGDEBUG_H 36 | #define PNGDEBUG_H 37 | /* These settings control the formatting of messages in png.c and pngerror.c */ 38 | /* Moved to pngdebug.h at 1.5.0 */ 39 | # ifndef PNG_LITERAL_SHARP 40 | # define PNG_LITERAL_SHARP 0x23 41 | # endif 42 | # ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET 43 | # define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b 44 | # endif 45 | # ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET 46 | # define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d 47 | # endif 48 | # ifndef PNG_STRING_NEWLINE 49 | # define PNG_STRING_NEWLINE "\n" 50 | # endif 51 | 52 | #ifdef PNG_DEBUG 53 | # if (PNG_DEBUG > 0) 54 | # if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) 55 | # include 56 | # if (PNG_DEBUG > 1) 57 | # ifndef _DEBUG 58 | # define _DEBUG 59 | # endif 60 | # ifndef png_debug 61 | # define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) 62 | # endif 63 | # ifndef png_debug1 64 | # define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) 65 | # endif 66 | # ifndef png_debug2 67 | # define png_debug2(l,m,p1,p2) \ 68 | _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) 69 | # endif 70 | # endif 71 | # else /* PNG_DEBUG_FILE || !_MSC_VER */ 72 | # ifndef PNG_STDIO_SUPPORTED 73 | # include /* not included yet */ 74 | # endif 75 | # ifndef PNG_DEBUG_FILE 76 | # define PNG_DEBUG_FILE stderr 77 | # endif /* PNG_DEBUG_FILE */ 78 | 79 | # if (PNG_DEBUG > 1) 80 | /* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on 81 | * non-ISO compilers 82 | */ 83 | # ifdef __STDC__ 84 | # ifndef png_debug 85 | # define png_debug(l,m) \ 86 | do { \ 87 | int num_tabs=l; \ 88 | fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ 89 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ 90 | } while (0) 91 | # endif 92 | # ifndef png_debug1 93 | # define png_debug1(l,m,p1) \ 94 | do { \ 95 | int num_tabs=l; \ 96 | fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ 97 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ 98 | } while (0) 99 | # endif 100 | # ifndef png_debug2 101 | # define png_debug2(l,m,p1,p2) \ 102 | do { \ 103 | int num_tabs=l; \ 104 | fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ 105 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ 106 | } while (0) 107 | # endif 108 | # else /* __STDC __ */ 109 | # ifndef png_debug 110 | # define png_debug(l,m) \ 111 | do { \ 112 | int num_tabs=l; \ 113 | char format[256]; \ 114 | snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ 115 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ 116 | m,PNG_STRING_NEWLINE); \ 117 | fprintf(PNG_DEBUG_FILE,format); \ 118 | } while (0) 119 | # endif 120 | # ifndef png_debug1 121 | # define png_debug1(l,m,p1) \ 122 | do { \ 123 | int num_tabs=l; \ 124 | char format[256]; \ 125 | snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ 126 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ 127 | m,PNG_STRING_NEWLINE); \ 128 | fprintf(PNG_DEBUG_FILE,format,p1); \ 129 | } while (0) 130 | # endif 131 | # ifndef png_debug2 132 | # define png_debug2(l,m,p1,p2) \ 133 | do { \ 134 | int num_tabs=l; \ 135 | char format[256]; \ 136 | snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ 137 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ 138 | m,PNG_STRING_NEWLINE); \ 139 | fprintf(PNG_DEBUG_FILE,format,p1,p2); \ 140 | } while (0) 141 | # endif 142 | # endif /* __STDC __ */ 143 | # endif /* (PNG_DEBUG > 1) */ 144 | 145 | # endif /* _MSC_VER */ 146 | # endif /* (PNG_DEBUG > 0) */ 147 | #endif /* PNG_DEBUG */ 148 | #ifndef png_debug 149 | # define png_debug(l, m) ((void)0) 150 | #endif 151 | #ifndef png_debug1 152 | # define png_debug1(l, m, p1) ((void)0) 153 | #endif 154 | #ifndef png_debug2 155 | # define png_debug2(l, m, p1, p2) ((void)0) 156 | #endif 157 | #endif /* PNGDEBUG_H */ 158 | -------------------------------------------------------------------------------- /app/src/main/jni/libpng/pnginfo.h: -------------------------------------------------------------------------------- 1 | 2 | /* pnginfo.h - header file for PNG reference library 3 | * 4 | * Copyright (c) 1998-2011 Glenn Randers-Pehrson 5 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 | * 8 | * Last changed in libpng 1.5.0 [January 6, 2011] 9 | * 10 | * This code is released under the libpng license. 11 | * For conditions of distribution and use, see the disclaimer 12 | * and license in png.h 13 | */ 14 | 15 | /* png_info is a structure that holds the information in a PNG file so 16 | * that the application can find out the characteristics of the image. 17 | * If you are reading the file, this structure will tell you what is 18 | * in the PNG file. If you are writing the file, fill in the information 19 | * you want to put into the PNG file, using png_set_*() functions, then 20 | * call png_write_info(). 21 | * 22 | * The names chosen should be very close to the PNG specification, so 23 | * consult that document for information about the meaning of each field. 24 | * 25 | * With libpng < 0.95, it was only possible to directly set and read the 26 | * the values in the png_info_struct, which meant that the contents and 27 | * order of the values had to remain fixed. With libpng 0.95 and later, 28 | * however, there are now functions that abstract the contents of 29 | * png_info_struct from the application, so this makes it easier to use 30 | * libpng with dynamic libraries, and even makes it possible to use 31 | * libraries that don't have all of the libpng ancillary chunk-handing 32 | * functionality. In libpng-1.5.0 this was moved into a separate private 33 | * file that is not visible to applications. 34 | * 35 | * The following members may have allocated storage attached that should be 36 | * cleaned up before the structure is discarded: palette, trans, text, 37 | * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, 38 | * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these 39 | * are automatically freed when the info structure is deallocated, if they were 40 | * allocated internally by libpng. This behavior can be changed by means 41 | * of the png_data_freer() function. 42 | * 43 | * More allocation details: all the chunk-reading functions that 44 | * change these members go through the corresponding png_set_* 45 | * functions. A function to clear these members is available: see 46 | * png_free_data(). The png_set_* functions do not depend on being 47 | * able to point info structure members to any of the storage they are 48 | * passed (they make their own copies), EXCEPT that the png_set_text 49 | * functions use the same storage passed to them in the text_ptr or 50 | * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns 51 | * functions do not make their own copies. 52 | */ 53 | #ifndef PNGINFO_H 54 | #define PNGINFO_H 55 | 56 | struct png_info_def 57 | { 58 | /* the following are necessary for every PNG file */ 59 | png_uint_32 width; /* width of image in pixels (from IHDR) */ 60 | png_uint_32 height; /* height of image in pixels (from IHDR) */ 61 | png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ 62 | png_size_t rowbytes; /* bytes needed to hold an untransformed row */ 63 | png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ 64 | png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ 65 | png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ 66 | png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ 67 | png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ 68 | /* The following three should have been named *_method not *_type */ 69 | png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ 70 | png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ 71 | png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ 72 | 73 | /* The following is informational only on read, and not used on writes. */ 74 | png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ 75 | png_byte pixel_depth; /* number of bits per pixel */ 76 | png_byte spare_byte; /* to align the data, and for future use */ 77 | png_byte signature[8]; /* magic bytes read by libpng from start of file */ 78 | 79 | /* The rest of the data is optional. If you are reading, check the 80 | * valid field to see if the information in these are valid. If you 81 | * are writing, set the valid field to those chunks you want written, 82 | * and initialize the appropriate fields below. 83 | */ 84 | 85 | #if defined(PNG_gAMA_SUPPORTED) 86 | /* The gAMA chunk describes the gamma characteristics of the system 87 | * on which the image was created, normally in the range [1.0, 2.5]. 88 | * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. 89 | */ 90 | png_fixed_point gamma; 91 | #endif 92 | 93 | #ifdef PNG_sRGB_SUPPORTED 94 | /* GR-P, 0.96a */ 95 | /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ 96 | png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ 97 | #endif 98 | 99 | #ifdef PNG_TEXT_SUPPORTED 100 | /* The tEXt, and zTXt chunks contain human-readable textual data in 101 | * uncompressed, compressed, and optionally compressed forms, respectively. 102 | * The data in "text" is an array of pointers to uncompressed, 103 | * null-terminated C strings. Each chunk has a keyword that describes the 104 | * textual data contained in that chunk. Keywords are not required to be 105 | * unique, and the text string may be empty. Any number of text chunks may 106 | * be in an image. 107 | */ 108 | int num_text; /* number of comments read or comments to write */ 109 | int max_text; /* current size of text array */ 110 | png_textp text; /* array of comments read or comments to write */ 111 | #endif /* PNG_TEXT_SUPPORTED */ 112 | 113 | #ifdef PNG_tIME_SUPPORTED 114 | /* The tIME chunk holds the last time the displayed image data was 115 | * modified. See the png_time struct for the contents of this struct. 116 | */ 117 | png_time mod_time; 118 | #endif 119 | 120 | #ifdef PNG_sBIT_SUPPORTED 121 | /* The sBIT chunk specifies the number of significant high-order bits 122 | * in the pixel data. Values are in the range [1, bit_depth], and are 123 | * only specified for the channels in the pixel data. The contents of 124 | * the low-order bits is not specified. Data is valid if 125 | * (valid & PNG_INFO_sBIT) is non-zero. 126 | */ 127 | png_color_8 sig_bit; /* significant bits in color channels */ 128 | #endif 129 | 130 | #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ 131 | defined(PNG_READ_BACKGROUND_SUPPORTED) 132 | /* The tRNS chunk supplies transparency data for paletted images and 133 | * other image types that don't need a full alpha channel. There are 134 | * "num_trans" transparency values for a paletted image, stored in the 135 | * same order as the palette colors, starting from index 0. Values 136 | * for the data are in the range [0, 255], ranging from fully transparent 137 | * to fully opaque, respectively. For non-paletted images, there is a 138 | * single color specified that should be treated as fully transparent. 139 | * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. 140 | */ 141 | png_bytep trans_alpha; /* alpha values for paletted image */ 142 | png_color_16 trans_color; /* transparent color for non-palette image */ 143 | #endif 144 | 145 | #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 146 | /* The bKGD chunk gives the suggested image background color if the 147 | * display program does not have its own background color and the image 148 | * is needs to composited onto a background before display. The colors 149 | * in "background" are normally in the same color space/depth as the 150 | * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. 151 | */ 152 | png_color_16 background; 153 | #endif 154 | 155 | #ifdef PNG_oFFs_SUPPORTED 156 | /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards 157 | * and downwards from the top-left corner of the display, page, or other 158 | * application-specific co-ordinate space. See the PNG_OFFSET_ defines 159 | * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. 160 | */ 161 | png_int_32 x_offset; /* x offset on page */ 162 | png_int_32 y_offset; /* y offset on page */ 163 | png_byte offset_unit_type; /* offset units type */ 164 | #endif 165 | 166 | #ifdef PNG_pHYs_SUPPORTED 167 | /* The pHYs chunk gives the physical pixel density of the image for 168 | * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ 169 | * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. 170 | */ 171 | png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ 172 | png_uint_32 y_pixels_per_unit; /* vertical pixel density */ 173 | png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ 174 | #endif 175 | 176 | #ifdef PNG_hIST_SUPPORTED 177 | /* The hIST chunk contains the relative frequency or importance of the 178 | * various palette entries, so that a viewer can intelligently select a 179 | * reduced-color palette, if required. Data is an array of "num_palette" 180 | * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) 181 | * is non-zero. 182 | */ 183 | png_uint_16p hist; 184 | #endif 185 | 186 | #ifdef PNG_cHRM_SUPPORTED 187 | /* The cHRM chunk describes the CIE color characteristics of the monitor 188 | * on which the PNG was created. This data allows the viewer to do gamut 189 | * mapping of the input image to ensure that the viewer sees the same 190 | * colors in the image as the creator. Values are in the range 191 | * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. 192 | */ 193 | png_fixed_point x_white; 194 | png_fixed_point y_white; 195 | png_fixed_point x_red; 196 | png_fixed_point y_red; 197 | png_fixed_point x_green; 198 | png_fixed_point y_green; 199 | png_fixed_point x_blue; 200 | png_fixed_point y_blue; 201 | #endif 202 | 203 | #ifdef PNG_pCAL_SUPPORTED 204 | /* The pCAL chunk describes a transformation between the stored pixel 205 | * values and original physical data values used to create the image. 206 | * The integer range [0, 2^bit_depth - 1] maps to the floating-point 207 | * range given by [pcal_X0, pcal_X1], and are further transformed by a 208 | * (possibly non-linear) transformation function given by "pcal_type" 209 | * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ 210 | * defines below, and the PNG-Group's PNG extensions document for a 211 | * complete description of the transformations and how they should be 212 | * implemented, and for a description of the ASCII parameter strings. 213 | * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. 214 | */ 215 | png_charp pcal_purpose; /* pCAL chunk description string */ 216 | png_int_32 pcal_X0; /* minimum value */ 217 | png_int_32 pcal_X1; /* maximum value */ 218 | png_charp pcal_units; /* Latin-1 string giving physical units */ 219 | png_charpp pcal_params; /* ASCII strings containing parameter values */ 220 | png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ 221 | png_byte pcal_nparams; /* number of parameters given in pcal_params */ 222 | #endif 223 | 224 | /* New members added in libpng-1.0.6 */ 225 | png_uint_32 free_me; /* flags items libpng is responsible for freeing */ 226 | 227 | #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ 228 | defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) 229 | /* Storage for unknown chunks that the library doesn't recognize. */ 230 | png_unknown_chunkp unknown_chunks; 231 | int unknown_chunks_num; 232 | #endif 233 | 234 | #ifdef PNG_iCCP_SUPPORTED 235 | /* iCCP chunk data. */ 236 | png_charp iccp_name; /* profile name */ 237 | png_bytep iccp_profile; /* International Color Consortium profile data */ 238 | png_uint_32 iccp_proflen; /* ICC profile data length */ 239 | png_byte iccp_compression; /* Always zero */ 240 | #endif 241 | 242 | #ifdef PNG_sPLT_SUPPORTED 243 | /* Data on sPLT chunks (there may be more than one). */ 244 | png_sPLT_tp splt_palettes; 245 | png_uint_32 splt_palettes_num; 246 | #endif 247 | 248 | #ifdef PNG_sCAL_SUPPORTED 249 | /* The sCAL chunk describes the actual physical dimensions of the 250 | * subject matter of the graphic. The chunk contains a unit specification 251 | * a byte value, and two ASCII strings representing floating-point 252 | * values. The values are width and height corresponsing to one pixel 253 | * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is 254 | * non-zero. 255 | */ 256 | png_byte scal_unit; /* unit of physical scale */ 257 | png_charp scal_s_width; /* string containing height */ 258 | png_charp scal_s_height; /* string containing width */ 259 | #endif 260 | 261 | #ifdef PNG_INFO_IMAGE_SUPPORTED 262 | /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) 263 | non-zero */ 264 | /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ 265 | png_bytepp row_pointers; /* the image bits */ 266 | #endif 267 | 268 | }; 269 | #endif /* PNGINFO_H */ 270 | -------------------------------------------------------------------------------- /app/src/main/jni/libpng/pnglibconf.h: -------------------------------------------------------------------------------- 1 | /* pnglibconf.h - library build configuration */ 2 | 3 | /* libpng version 1.5.12 - July 11, 2012 */ 4 | 5 | /* Copyright (c) 1998-2011 Glenn Randers-Pehrson */ 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 | /* pnglibconf.h */ 12 | /* Machine generated file: DO NOT EDIT */ 13 | /* Derived from: scripts/pnglibconf.dfa */ 14 | #ifndef PNGLCONF_H 15 | #define PNGLCONF_H 16 | /* settings */ 17 | #define PNG_COST_SHIFT 3 18 | #define PNG_GAMMA_THRESHOLD_FIXED 5000 19 | #define PNG_QUANTIZE_BLUE_BITS 5 20 | #define PNG_WEIGHT_SHIFT 8 21 | #define PNG_API_RULE 0 22 | #define PNG_CALLOC_SUPPORTED 23 | #define PNG_ZBUF_SIZE 8192 24 | #define PNG_QUANTIZE_GREEN_BITS 5 25 | #define PNG_sCAL_PRECISION 5 26 | #define PNG_QUANTIZE_RED_BITS 5 27 | #define PNG_DEFAULT_READ_MACROS 1 28 | #define PNG_MAX_GAMMA_8 11 29 | /* end of settings */ 30 | /* options */ 31 | #define PNG_IO_STATE_SUPPORTED 1 32 | #define PNG_BENIGN_ERRORS_SUPPORTED 1 33 | #define PNG_WRITE_SUPPORTED 1 34 | #define PNG_EASY_ACCESS_SUPPORTED 1 35 | #define PNG_INFO_IMAGE_SUPPORTED 1 36 | #define PNG_TIME_RFC1123_SUPPORTED 1 37 | #define PNG_WRITE_FILTER_SUPPORTED 1 38 | #define PNG_FIXED_POINT_SUPPORTED 1 39 | #define PNG_READ_SUPPORTED 1 40 | #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED 1 41 | #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 1 42 | #define PNG_WRITE_FLUSH_SUPPORTED 1 43 | #define PNG_WRITE_INTERLACING_SUPPORTED 1 44 | #define PNG_WRITE_TRANSFORMS_SUPPORTED 1 45 | #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 1 46 | #define PNG_INCH_CONVERSIONS_SUPPORTED 1 47 | #define PNG_USER_MEM_SUPPORTED 1 48 | #define PNG_SETJMP_SUPPORTED 1 49 | #define PNG_WARNINGS_SUPPORTED 1 50 | #define PNG_FLOATING_POINT_SUPPORTED 1 51 | #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED 1 52 | #define PNG_READ_QUANTIZE_SUPPORTED 1 53 | #define PNG_READ_16BIT_SUPPORTED 1 54 | #define PNG_ALIGN_MEMORY_SUPPORTED 1 55 | /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ 56 | #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 1 57 | #define PNG_SEQUENTIAL_READ_SUPPORTED 1 58 | #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED 1 59 | #define PNG_WRITE_SHIFT_SUPPORTED 1 60 | #define PNG_ERROR_TEXT_SUPPORTED 1 61 | #define PNG_WRITE_FILLER_SUPPORTED 1 62 | #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 1 63 | /*#undef PNG_SAFE_LIMITS_SUPPORTED*/ 64 | #define PNG_WRITE_16BIT_SUPPORTED 1 65 | #define PNG_WRITE_SWAP_ALPHA_SUPPORTED 1 66 | #define PNG_POINTER_INDEXING_SUPPORTED 1 67 | #define PNG_FLOATING_ARITHMETIC_SUPPORTED 1 68 | #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED 1 69 | #define PNG_MNG_FEATURES_SUPPORTED 1 70 | #define PNG_STDIO_SUPPORTED 1 71 | #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED 1 72 | #define PNG_WRITE_PACKSWAP_SUPPORTED 1 73 | #define PNG_READ_INTERLACING_SUPPORTED 1 74 | #define PNG_READ_COMPOSITE_NODIV_SUPPORTED 1 75 | #define PNG_PROGRESSIVE_READ_SUPPORTED 1 76 | #define PNG_READ_INT_FUNCTIONS_SUPPORTED 1 77 | #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED 1 78 | #define PNG_WRITE_INVERT_SUPPORTED 1 79 | #define PNG_WRITE_PACK_SUPPORTED 1 80 | #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED 1 81 | #define PNG_16BIT_SUPPORTED 1 82 | #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED 1 83 | #define PNG_WRITE_cHRM_SUPPORTED 1 84 | #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED 1 85 | #define PNG_WRITE_BGR_SUPPORTED 1 86 | #define PNG_WRITE_sBIT_SUPPORTED 1 87 | #define PNG_READ_sBIT_SUPPORTED 1 88 | #define PNG_READ_TRANSFORMS_SUPPORTED 1 89 | #define PNG_READ_EXPAND_16_SUPPORTED 1 90 | #define PNG_WRITE_SWAP_SUPPORTED 1 91 | #define PNG_READ_SWAP_SUPPORTED 1 92 | #define PNG_WRITE_oFFs_SUPPORTED 1 93 | #define PNG_READ_oFFs_SUPPORTED 1 94 | #define PNG_WRITE_USER_TRANSFORM_SUPPORTED 1 95 | #define PNG_WRITE_tIME_SUPPORTED 1 96 | #define PNG_WRITE_INVERT_ALPHA_SUPPORTED 1 97 | #define PNG_READ_tIME_SUPPORTED 1 98 | #define PNG_READ_PACKSWAP_SUPPORTED 1 99 | #define PNG_USER_LIMITS_SUPPORTED 1 100 | #define PNG_READ_GRAY_TO_RGB_SUPPORTED 1 101 | #define PNG_READ_STRIP_16_TO_8_SUPPORTED 1 102 | #define PNG_READ_SCALE_16_TO_8_SUPPORTED 1 103 | #define PNG_READ_USER_CHUNKS_SUPPORTED 1 104 | #define PNG_READ_OPT_PLTE_SUPPORTED 1 105 | #define PNG_UNKNOWN_CHUNKS_SUPPORTED 1 106 | #define PNG_WRITE_gAMA_SUPPORTED 1 107 | #define PNG_SET_USER_LIMITS_SUPPORTED 1 108 | #define PNG_WRITE_iCCP_SUPPORTED 1 109 | #define PNG_READ_iCCP_SUPPORTED 1 110 | #define PNG_READ_SHIFT_SUPPORTED 1 111 | #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED 1 112 | #define PNG_READ_EXPAND_SUPPORTED 1 113 | #define PNG_WRITE_iTXt_SUPPORTED 1 114 | #define PNG_READ_iTXt_SUPPORTED 1 115 | #define PNG_READ_SWAP_ALPHA_SUPPORTED 1 116 | #define PNG_CONSOLE_IO_SUPPORTED 1 117 | #define PNG_sBIT_SUPPORTED 1 118 | #define PNG_WRITE_sRGB_SUPPORTED 1 119 | #define PNG_READ_sRGB_SUPPORTED 1 120 | #define PNG_READ_ALPHA_MODE_SUPPORTED 1 121 | #define PNG_WRITE_sCAL_SUPPORTED 1 122 | #define PNG_READ_sCAL_SUPPORTED 1 123 | #define PNG_USER_CHUNKS_SUPPORTED 1 124 | #define PNG_oFFs_SUPPORTED 1 125 | #define PNG_READ_GAMMA_SUPPORTED 1 126 | #define PNG_WRITE_pHYs_SUPPORTED 1 127 | #define PNG_WRITE_tRNS_SUPPORTED 1 128 | #define PNG_READ_pHYs_SUPPORTED 1 129 | #define PNG_READ_tRNS_SUPPORTED 1 130 | #define PNG_READ_RGB_TO_GRAY_SUPPORTED 1 131 | #define PNG_tIME_SUPPORTED 1 132 | #define PNG_WRITE_bKGD_SUPPORTED 1 133 | #define PNG_READ_bKGD_SUPPORTED 1 134 | #define PNG_WRITE_zTXt_SUPPORTED 1 135 | #define PNG_WRITE_pCAL_SUPPORTED 1 136 | #define PNG_READ_zTXt_SUPPORTED 1 137 | #define PNG_READ_pCAL_SUPPORTED 1 138 | #define PNG_WRITE_hIST_SUPPORTED 1 139 | #define PNG_READ_hIST_SUPPORTED 1 140 | #define PNG_WRITE_sPLT_SUPPORTED 1 141 | #define PNG_READ_sPLT_SUPPORTED 1 142 | #define PNG_READ_INVERT_ALPHA_SUPPORTED 1 143 | #define PNG_iCCP_SUPPORTED 1 144 | #define PNG_CONVERT_tIME_SUPPORTED 1 145 | #define PNG_READ_FILLER_SUPPORTED 1 146 | #define PNG_READ_USER_TRANSFORM_SUPPORTED 1 147 | #define PNG_READ_PACK_SUPPORTED 1 148 | #define PNG_READ_BACKGROUND_SUPPORTED 1 149 | #define PNG_iTXt_SUPPORTED 1 150 | #define PNG_READ_cHRM_SUPPORTED 1 151 | #define PNG_USER_TRANSFORM_INFO_SUPPORTED 1 152 | #define PNG_sRGB_SUPPORTED 1 153 | #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED 1 154 | #define PNG_USER_TRANSFORM_PTR_SUPPORTED 1 155 | #define PNG_sCAL_SUPPORTED 1 156 | #define PNG_READ_BGR_SUPPORTED 1 157 | #define PNG_READ_INVERT_SUPPORTED 1 158 | #define PNG_READ_COMPRESSED_TEXT_SUPPORTED 1 159 | #define PNG_pHYs_SUPPORTED 1 160 | #define PNG_tRNS_SUPPORTED 1 161 | #define PNG_bKGD_SUPPORTED 1 162 | #define PNG_pCAL_SUPPORTED 1 163 | #define PNG_zTXt_SUPPORTED 1 164 | #define PNG_READ_TEXT_SUPPORTED 1 165 | #define PNG_hIST_SUPPORTED 1 166 | #define PNG_READ_STRIP_ALPHA_SUPPORTED 1 167 | #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED 1 168 | #define PNG_sPLT_SUPPORTED 1 169 | #define PNG_READ_gAMA_SUPPORTED 1 170 | #define PNG_SAVE_INT_32_SUPPORTED 1 171 | #define PNG_cHRM_SUPPORTED 1 172 | #define PNG_CHECK_cHRM_SUPPORTED 1 173 | #define PNG_gAMA_SUPPORTED 1 174 | #define PNG_READ_tEXt_SUPPORTED 1 175 | #define PNG_WRITE_TEXT_SUPPORTED 1 176 | #define PNG_TEXT_SUPPORTED 1 177 | #define PNG_WRITE_tEXt_SUPPORTED 1 178 | #define PNG_tEXt_SUPPORTED 1 179 | /* end of options */ 180 | #endif /* PNGLCONF_H */ 181 | -------------------------------------------------------------------------------- /app/src/main/jni/libpng/pngrio.c: -------------------------------------------------------------------------------- 1 | 2 | /* pngrio.c - functions for data input 3 | * 4 | * Last changed in libpng 1.5.0 [January 6, 2011] 5 | * Copyright (c) 1998-2011 Glenn Randers-Pehrson 6 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 | * 9 | * This code is released under the libpng license. 10 | * For conditions of distribution and use, see the disclaimer 11 | * and license in png.h 12 | * 13 | * This file provides a location for all input. Users who need 14 | * special handling are expected to write a function that has the same 15 | * arguments as this and performs a similar function, but that possibly 16 | * has a different input method. Note that you shouldn't change this 17 | * function, but rather write a replacement function and then make 18 | * libpng use it at run time with png_set_read_fn(...). 19 | */ 20 | 21 | #include "pngpriv.h" 22 | 23 | #ifdef PNG_READ_SUPPORTED 24 | 25 | /* Read the data from whatever input you are using. The default routine 26 | * reads from a file pointer. Note that this routine sometimes gets called 27 | * with very small lengths, so you should implement some kind of simple 28 | * buffering if you are using unbuffered reads. This should never be asked 29 | * to read more then 64K on a 16 bit machine. 30 | */ 31 | void /* PRIVATE */ 32 | png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 33 | { 34 | png_debug1(4, "reading %d bytes", (int)length); 35 | 36 | if (png_ptr->read_data_fn != NULL) 37 | (*(png_ptr->read_data_fn))(png_ptr, data, length); 38 | 39 | else 40 | png_error(png_ptr, "Call to NULL read function"); 41 | } 42 | 43 | #ifdef PNG_STDIO_SUPPORTED 44 | /* This is the function that does the actual reading of data. If you are 45 | * not reading from a standard C stream, you should create a replacement 46 | * read_data function and use it at run time with png_set_read_fn(), rather 47 | * than changing the library. 48 | */ 49 | # ifndef USE_FAR_KEYWORD 50 | void PNGCBAPI 51 | png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 52 | { 53 | png_size_t check; 54 | 55 | if (png_ptr == NULL) 56 | return; 57 | 58 | /* fread() returns 0 on error, so it is OK to store this in a png_size_t 59 | * instead of an int, which is what fread() actually returns. 60 | */ 61 | check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr); 62 | 63 | if (check != length) 64 | png_error(png_ptr, "Read Error"); 65 | } 66 | # else 67 | /* This is the model-independent version. Since the standard I/O library 68 | can't handle far buffers in the medium and small models, we have to copy 69 | the data. 70 | */ 71 | 72 | #define NEAR_BUF_SIZE 1024 73 | #define MIN(a,b) (a <= b ? a : b) 74 | 75 | static void PNGCBAPI 76 | png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 77 | { 78 | png_size_t check; 79 | png_byte *n_data; 80 | png_FILE_p io_ptr; 81 | 82 | if (png_ptr == NULL) 83 | return; 84 | 85 | /* Check if data really is near. If so, use usual code. */ 86 | n_data = (png_byte *)CVT_PTR_NOCHECK(data); 87 | io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); 88 | 89 | if ((png_bytep)n_data == data) 90 | { 91 | check = fread(n_data, 1, length, io_ptr); 92 | } 93 | 94 | else 95 | { 96 | png_byte buf[NEAR_BUF_SIZE]; 97 | png_size_t read, remaining, err; 98 | check = 0; 99 | remaining = length; 100 | 101 | do 102 | { 103 | read = MIN(NEAR_BUF_SIZE, remaining); 104 | err = fread(buf, 1, read, io_ptr); 105 | png_memcpy(data, buf, read); /* copy far buffer to near buffer */ 106 | 107 | if (err != read) 108 | break; 109 | 110 | else 111 | check += err; 112 | 113 | data += read; 114 | remaining -= read; 115 | } 116 | while (remaining != 0); 117 | } 118 | 119 | if ((png_uint_32)check != (png_uint_32)length) 120 | png_error(png_ptr, "read Error"); 121 | } 122 | # endif 123 | #endif 124 | 125 | /* This function allows the application to supply a new input function 126 | * for libpng if standard C streams aren't being used. 127 | * 128 | * This function takes as its arguments: 129 | * 130 | * png_ptr - pointer to a png input data structure 131 | * 132 | * io_ptr - pointer to user supplied structure containing info about 133 | * the input functions. May be NULL. 134 | * 135 | * read_data_fn - pointer to a new input function that takes as its 136 | * arguments a pointer to a png_struct, a pointer to 137 | * a location where input data can be stored, and a 32-bit 138 | * unsigned int that is the number of bytes to be read. 139 | * To exit and output any fatal error messages the new write 140 | * function should call png_error(png_ptr, "Error msg"). 141 | * May be NULL, in which case libpng's default function will 142 | * be used. 143 | */ 144 | void PNGAPI 145 | png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, 146 | png_rw_ptr read_data_fn) 147 | { 148 | if (png_ptr == NULL) 149 | return; 150 | 151 | png_ptr->io_ptr = io_ptr; 152 | 153 | #ifdef PNG_STDIO_SUPPORTED 154 | if (read_data_fn != NULL) 155 | png_ptr->read_data_fn = read_data_fn; 156 | 157 | else 158 | png_ptr->read_data_fn = png_default_read_data; 159 | #else 160 | png_ptr->read_data_fn = read_data_fn; 161 | #endif 162 | 163 | /* It is an error to write to a read device */ 164 | if (png_ptr->write_data_fn != NULL) 165 | { 166 | png_ptr->write_data_fn = NULL; 167 | png_warning(png_ptr, 168 | "Can't set both read_data_fn and write_data_fn in the" 169 | " same structure"); 170 | } 171 | 172 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 173 | png_ptr->output_flush_fn = NULL; 174 | #endif 175 | } 176 | #endif /* PNG_READ_SUPPORTED */ 177 | -------------------------------------------------------------------------------- /app/src/main/jni/libpng/pngstruct.h: -------------------------------------------------------------------------------- 1 | 2 | /* pngstruct.h - header file for PNG reference library 3 | * 4 | * Copyright (c) 1998-2012 Glenn Randers-Pehrson 5 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 | * 8 | * Last changed in libpng 1.5.9 [February 18, 2012] 9 | * 10 | * This code is released under the libpng license. 11 | * For conditions of distribution and use, see the disclaimer 12 | * and license in png.h 13 | */ 14 | 15 | /* The structure that holds the information to read and write PNG files. 16 | * The only people who need to care about what is inside of this are the 17 | * people who will be modifying the library for their own special needs. 18 | * It should NOT be accessed directly by an application. 19 | */ 20 | 21 | #ifndef PNGSTRUCT_H 22 | #define PNGSTRUCT_H 23 | /* zlib.h defines the structure z_stream, an instance of which is included 24 | * in this structure and is required for decompressing the LZ compressed 25 | * data in PNG files. 26 | */ 27 | #include "zlib.h" 28 | 29 | struct png_struct_def 30 | { 31 | #ifdef PNG_SETJMP_SUPPORTED 32 | jmp_buf longjmp_buffer; /* used in png_error */ 33 | png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */ 34 | #endif 35 | png_error_ptr error_fn; /* function for printing errors and aborting */ 36 | #ifdef PNG_WARNINGS_SUPPORTED 37 | png_error_ptr warning_fn; /* function for printing warnings */ 38 | #endif 39 | png_voidp error_ptr; /* user supplied struct for error functions */ 40 | png_rw_ptr write_data_fn; /* function for writing output data */ 41 | png_rw_ptr read_data_fn; /* function for reading input data */ 42 | png_voidp io_ptr; /* ptr to application struct for I/O functions */ 43 | 44 | #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 45 | png_user_transform_ptr read_user_transform_fn; /* user read transform */ 46 | #endif 47 | 48 | #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED 49 | png_user_transform_ptr write_user_transform_fn; /* user write transform */ 50 | #endif 51 | 52 | /* These were added in libpng-1.0.2 */ 53 | #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED 54 | #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 55 | defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 56 | png_voidp user_transform_ptr; /* user supplied struct for user transform */ 57 | png_byte user_transform_depth; /* bit depth of user transformed pixels */ 58 | png_byte user_transform_channels; /* channels in user transformed pixels */ 59 | #endif 60 | #endif 61 | 62 | png_uint_32 mode; /* tells us where we are in the PNG file */ 63 | png_uint_32 flags; /* flags indicating various things to libpng */ 64 | png_uint_32 transformations; /* which transformations to perform */ 65 | 66 | z_stream zstream; /* pointer to decompression structure (below) */ 67 | png_bytep zbuf; /* buffer for zlib */ 68 | uInt zbuf_size; /* size of zbuf (typically 65536) */ 69 | #ifdef PNG_WRITE_SUPPORTED 70 | 71 | /* Added in 1.5.4: state to keep track of whether the zstream has been 72 | * initialized and if so whether it is for IDAT or some other chunk. 73 | */ 74 | #define PNG_ZLIB_UNINITIALIZED 0 75 | #define PNG_ZLIB_FOR_IDAT 1 76 | #define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */ 77 | #define PNG_ZLIB_USE_MASK 3 /* bottom two bits */ 78 | #define PNG_ZLIB_IN_USE 4 /* a flag value */ 79 | 80 | png_uint_32 zlib_state; /* State of zlib initialization */ 81 | /* End of material added at libpng 1.5.4 */ 82 | 83 | int zlib_level; /* holds zlib compression level */ 84 | int zlib_method; /* holds zlib compression method */ 85 | int zlib_window_bits; /* holds zlib compression window bits */ 86 | int zlib_mem_level; /* holds zlib compression memory level */ 87 | int zlib_strategy; /* holds zlib compression strategy */ 88 | #endif 89 | /* Added at libpng 1.5.4 */ 90 | #if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \ 91 | defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED) 92 | int zlib_text_level; /* holds zlib compression level */ 93 | int zlib_text_method; /* holds zlib compression method */ 94 | int zlib_text_window_bits; /* holds zlib compression window bits */ 95 | int zlib_text_mem_level; /* holds zlib compression memory level */ 96 | int zlib_text_strategy; /* holds zlib compression strategy */ 97 | #endif 98 | /* End of material added at libpng 1.5.4 */ 99 | 100 | png_uint_32 width; /* width of image in pixels */ 101 | png_uint_32 height; /* height of image in pixels */ 102 | png_uint_32 num_rows; /* number of rows in current pass */ 103 | png_uint_32 usr_width; /* width of row at start of write */ 104 | png_size_t rowbytes; /* size of row in bytes */ 105 | png_uint_32 iwidth; /* width of current interlaced row in pixels */ 106 | png_uint_32 row_number; /* current row in interlace pass */ 107 | png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */ 108 | png_bytep prev_row; /* buffer to save previous (unfiltered) row. 109 | * This is a pointer into big_prev_row 110 | */ 111 | png_bytep row_buf; /* buffer to save current (unfiltered) row. 112 | * This is a pointer into big_row_buf 113 | */ 114 | png_bytep sub_row; /* buffer to save "sub" row when filtering */ 115 | png_bytep up_row; /* buffer to save "up" row when filtering */ 116 | png_bytep avg_row; /* buffer to save "avg" row when filtering */ 117 | png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ 118 | png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */ 119 | 120 | png_uint_32 idat_size; /* current IDAT size for read */ 121 | png_uint_32 crc; /* current chunk CRC value */ 122 | png_colorp palette; /* palette from the input file */ 123 | png_uint_16 num_palette; /* number of color entries in palette */ 124 | 125 | /* Added at libpng-1.5.10 */ 126 | #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 127 | int num_palette_max; /* maximum palette index found in IDAT */ 128 | #endif 129 | 130 | png_uint_16 num_trans; /* number of transparency values */ 131 | png_byte compression; /* file compression type (always 0) */ 132 | png_byte filter; /* file filter type (always 0) */ 133 | png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ 134 | png_byte pass; /* current interlace pass (0 - 6) */ 135 | png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ 136 | png_byte color_type; /* color type of file */ 137 | png_byte bit_depth; /* bit depth of file */ 138 | png_byte usr_bit_depth; /* bit depth of users row: write only */ 139 | png_byte pixel_depth; /* number of bits per pixel */ 140 | png_byte channels; /* number of channels in file */ 141 | png_byte usr_channels; /* channels at start of write: write only */ 142 | png_byte sig_bytes; /* magic bytes read/written from start of file */ 143 | png_byte maximum_pixel_depth; 144 | /* pixel depth used for the row buffers */ 145 | png_byte transformed_pixel_depth; 146 | /* pixel depth after read/write transforms */ 147 | png_byte io_chunk_string[5]; 148 | /* string name of chunk */ 149 | 150 | #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) 151 | png_uint_16 filler; /* filler bytes for pixel expansion */ 152 | #endif 153 | 154 | #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ 155 | defined(PNG_READ_ALPHA_MODE_SUPPORTED) 156 | png_byte background_gamma_type; 157 | png_fixed_point background_gamma; 158 | png_color_16 background; /* background color in screen gamma space */ 159 | #ifdef PNG_READ_GAMMA_SUPPORTED 160 | png_color_16 background_1; /* background normalized to gamma 1.0 */ 161 | #endif 162 | #endif /* PNG_bKGD_SUPPORTED */ 163 | 164 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 165 | png_flush_ptr output_flush_fn; /* Function for flushing output */ 166 | png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ 167 | png_uint_32 flush_rows; /* number of rows written since last flush */ 168 | #endif 169 | 170 | #ifdef PNG_READ_GAMMA_SUPPORTED 171 | int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */ 172 | png_fixed_point gamma; /* file gamma value */ 173 | png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */ 174 | 175 | png_bytep gamma_table; /* gamma table for 8-bit depth files */ 176 | png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ 177 | #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ 178 | defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ 179 | defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 180 | png_bytep gamma_from_1; /* converts from 1.0 to screen */ 181 | png_bytep gamma_to_1; /* converts from file to 1.0 */ 182 | png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ 183 | png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ 184 | #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ 185 | #endif 186 | 187 | #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) 188 | png_color_8 sig_bit; /* significant bits in each available channel */ 189 | #endif 190 | 191 | #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) 192 | png_color_8 shift; /* shift for significant bit tranformation */ 193 | #endif 194 | 195 | #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ 196 | || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 197 | png_bytep trans_alpha; /* alpha values for paletted files */ 198 | png_color_16 trans_color; /* transparent color for non-paletted files */ 199 | #endif 200 | 201 | png_read_status_ptr read_row_fn; /* called after each row is decoded */ 202 | png_write_status_ptr write_row_fn; /* called after each row is encoded */ 203 | #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 204 | png_progressive_info_ptr info_fn; /* called after header data fully read */ 205 | png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */ 206 | png_progressive_end_ptr end_fn; /* called after image is complete */ 207 | png_bytep save_buffer_ptr; /* current location in save_buffer */ 208 | png_bytep save_buffer; /* buffer for previously read data */ 209 | png_bytep current_buffer_ptr; /* current location in current_buffer */ 210 | png_bytep current_buffer; /* buffer for recently used data */ 211 | png_uint_32 push_length; /* size of current input chunk */ 212 | png_uint_32 skip_length; /* bytes to skip in input data */ 213 | png_size_t save_buffer_size; /* amount of data now in save_buffer */ 214 | png_size_t save_buffer_max; /* total size of save_buffer */ 215 | png_size_t buffer_size; /* total amount of available input data */ 216 | png_size_t current_buffer_size; /* amount of data now in current_buffer */ 217 | int process_mode; /* what push library is currently doing */ 218 | int cur_palette; /* current push library palette index */ 219 | 220 | #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 221 | 222 | #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) 223 | /* For the Borland special 64K segment handler */ 224 | png_bytepp offset_table_ptr; 225 | png_bytep offset_table; 226 | png_uint_16 offset_table_number; 227 | png_uint_16 offset_table_count; 228 | png_uint_16 offset_table_count_free; 229 | #endif 230 | 231 | #ifdef PNG_READ_QUANTIZE_SUPPORTED 232 | png_bytep palette_lookup; /* lookup table for quantizing */ 233 | png_bytep quantize_index; /* index translation for palette files */ 234 | #endif 235 | 236 | #if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED) 237 | png_uint_16p hist; /* histogram */ 238 | #endif 239 | 240 | #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 241 | png_byte heuristic_method; /* heuristic for row filter selection */ 242 | png_byte num_prev_filters; /* number of weights for previous rows */ 243 | png_bytep prev_filters; /* filter type(s) of previous row(s) */ 244 | png_uint_16p filter_weights; /* weight(s) for previous line(s) */ 245 | png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ 246 | png_uint_16p filter_costs; /* relative filter calculation cost */ 247 | png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ 248 | #endif 249 | 250 | #ifdef PNG_TIME_RFC1123_SUPPORTED 251 | /* This is going to be unused in libpng16 and removed from libpng17 */ 252 | char time_buffer[29]; /* String to hold RFC 1123 time text */ 253 | #endif 254 | 255 | /* New members added in libpng-1.0.6 */ 256 | 257 | png_uint_32 free_me; /* flags items libpng is responsible for freeing */ 258 | 259 | #ifdef PNG_USER_CHUNKS_SUPPORTED 260 | png_voidp user_chunk_ptr; 261 | png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ 262 | #endif 263 | 264 | #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 265 | int num_chunk_list; 266 | png_bytep chunk_list; 267 | #endif 268 | 269 | #ifdef PNG_READ_sRGB_SUPPORTED 270 | /* Added in 1.5.5 to record an sRGB chunk in the png. */ 271 | png_byte is_sRGB; 272 | #endif 273 | 274 | /* New members added in libpng-1.0.3 */ 275 | #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 276 | png_byte rgb_to_gray_status; 277 | /* Added in libpng 1.5.5 to record setting of coefficients: */ 278 | png_byte rgb_to_gray_coefficients_set; 279 | /* These were changed from png_byte in libpng-1.0.6 */ 280 | png_uint_16 rgb_to_gray_red_coeff; 281 | png_uint_16 rgb_to_gray_green_coeff; 282 | /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */ 283 | #endif 284 | 285 | /* New member added in libpng-1.0.4 (renamed in 1.0.9) */ 286 | #if defined(PNG_MNG_FEATURES_SUPPORTED) 287 | /* Changed from png_byte to png_uint_32 at version 1.2.0 */ 288 | png_uint_32 mng_features_permitted; 289 | #endif 290 | 291 | /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ 292 | #ifdef PNG_MNG_FEATURES_SUPPORTED 293 | png_byte filter_type; 294 | #endif 295 | 296 | /* New members added in libpng-1.2.0 */ 297 | 298 | /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ 299 | #ifdef PNG_USER_MEM_SUPPORTED 300 | png_voidp mem_ptr; /* user supplied struct for mem functions */ 301 | png_malloc_ptr malloc_fn; /* function for allocating memory */ 302 | png_free_ptr free_fn; /* function for freeing memory */ 303 | #endif 304 | 305 | /* New member added in libpng-1.0.13 and 1.2.0 */ 306 | png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ 307 | 308 | #ifdef PNG_READ_QUANTIZE_SUPPORTED 309 | /* The following three members were added at version 1.0.14 and 1.2.4 */ 310 | png_bytep quantize_sort; /* working sort array */ 311 | png_bytep index_to_palette; /* where the original index currently is 312 | in the palette */ 313 | png_bytep palette_to_index; /* which original index points to this 314 | palette color */ 315 | #endif 316 | 317 | /* New members added in libpng-1.0.16 and 1.2.6 */ 318 | png_byte compression_type; 319 | 320 | #ifdef PNG_USER_LIMITS_SUPPORTED 321 | png_uint_32 user_width_max; 322 | png_uint_32 user_height_max; 323 | 324 | /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown 325 | * chunks that can be stored (0 means unlimited). 326 | */ 327 | png_uint_32 user_chunk_cache_max; 328 | 329 | /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk 330 | * can occupy when decompressed. 0 means unlimited. 331 | */ 332 | png_alloc_size_t user_chunk_malloc_max; 333 | #endif 334 | 335 | /* New member added in libpng-1.0.25 and 1.2.17 */ 336 | #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 337 | /* Storage for unknown chunk that the library doesn't recognize. */ 338 | png_unknown_chunk unknown_chunk; 339 | #endif 340 | 341 | /* New member added in libpng-1.2.26 */ 342 | png_size_t old_big_row_buf_size; 343 | 344 | /* New member added in libpng-1.2.30 */ 345 | png_charp chunkdata; /* buffer for reading chunk data */ 346 | 347 | #ifdef PNG_IO_STATE_SUPPORTED 348 | /* New member added in libpng-1.4.0 */ 349 | png_uint_32 io_state; 350 | #endif 351 | 352 | /* New member added in libpng-1.5.6 */ 353 | png_bytep big_prev_row; 354 | 355 | void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info, 356 | png_bytep row, png_const_bytep prev_row); 357 | }; 358 | #endif /* PNGSTRUCT_H */ 359 | -------------------------------------------------------------------------------- /app/src/main/jni/libpng/pngwio.c: -------------------------------------------------------------------------------- 1 | 2 | /* pngwio.c - functions for data output 3 | * 4 | * Last changed in libpng 1.5.0 [January 6, 2011] 5 | * Copyright (c) 1998-2011 Glenn Randers-Pehrson 6 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 | * 9 | * This code is released under the libpng license. 10 | * For conditions of distribution and use, see the disclaimer 11 | * and license in png.h 12 | * 13 | * This file provides a location for all output. Users who need 14 | * special handling are expected to write functions that have the same 15 | * arguments as these and perform similar functions, but that possibly 16 | * use different output methods. Note that you shouldn't change these 17 | * functions, but rather write replacement functions and then change 18 | * them at run time with png_set_write_fn(...). 19 | */ 20 | 21 | #include "pngpriv.h" 22 | 23 | #ifdef PNG_WRITE_SUPPORTED 24 | 25 | /* Write the data to whatever output you are using. The default routine 26 | * writes to a file pointer. Note that this routine sometimes gets called 27 | * with very small lengths, so you should implement some kind of simple 28 | * buffering if you are using unbuffered writes. This should never be asked 29 | * to write more than 64K on a 16 bit machine. 30 | */ 31 | 32 | void /* PRIVATE */ 33 | png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length) 34 | { 35 | /* NOTE: write_data_fn must not change the buffer! */ 36 | if (png_ptr->write_data_fn != NULL ) 37 | (*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length); 38 | 39 | else 40 | png_error(png_ptr, "Call to NULL write function"); 41 | } 42 | 43 | #ifdef PNG_STDIO_SUPPORTED 44 | /* This is the function that does the actual writing of data. If you are 45 | * not writing to a standard C stream, you should create a replacement 46 | * write_data function and use it at run time with png_set_write_fn(), rather 47 | * than changing the library. 48 | */ 49 | #ifndef USE_FAR_KEYWORD 50 | void PNGCBAPI 51 | png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 52 | { 53 | png_size_t check; 54 | 55 | if (png_ptr == NULL) 56 | return; 57 | 58 | check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); 59 | 60 | if (check != length) 61 | png_error(png_ptr, "Write Error"); 62 | } 63 | #else 64 | /* This is the model-independent version. Since the standard I/O library 65 | * can't handle far buffers in the medium and small models, we have to copy 66 | * the data. 67 | */ 68 | 69 | #define NEAR_BUF_SIZE 1024 70 | #define MIN(a,b) (a <= b ? a : b) 71 | 72 | void PNGCBAPI 73 | png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 74 | { 75 | png_uint_32 check; 76 | png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ 77 | png_FILE_p io_ptr; 78 | 79 | if (png_ptr == NULL) 80 | return; 81 | 82 | /* Check if data really is near. If so, use usual code. */ 83 | near_data = (png_byte *)CVT_PTR_NOCHECK(data); 84 | io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); 85 | 86 | if ((png_bytep)near_data == data) 87 | { 88 | check = fwrite(near_data, 1, length, io_ptr); 89 | } 90 | 91 | else 92 | { 93 | png_byte buf[NEAR_BUF_SIZE]; 94 | png_size_t written, remaining, err; 95 | check = 0; 96 | remaining = length; 97 | 98 | do 99 | { 100 | written = MIN(NEAR_BUF_SIZE, remaining); 101 | png_memcpy(buf, data, written); /* Copy far buffer to near buffer */ 102 | err = fwrite(buf, 1, written, io_ptr); 103 | 104 | if (err != written) 105 | break; 106 | 107 | else 108 | check += err; 109 | 110 | data += written; 111 | remaining -= written; 112 | } 113 | while (remaining != 0); 114 | } 115 | 116 | if (check != length) 117 | png_error(png_ptr, "Write Error"); 118 | } 119 | 120 | #endif 121 | #endif 122 | 123 | /* This function is called to output any data pending writing (normally 124 | * to disk). After png_flush is called, there should be no data pending 125 | * writing in any buffers. 126 | */ 127 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 128 | void /* PRIVATE */ 129 | png_flush(png_structp png_ptr) 130 | { 131 | if (png_ptr->output_flush_fn != NULL) 132 | (*(png_ptr->output_flush_fn))(png_ptr); 133 | } 134 | 135 | # ifdef PNG_STDIO_SUPPORTED 136 | void PNGCBAPI 137 | png_default_flush(png_structp png_ptr) 138 | { 139 | png_FILE_p io_ptr; 140 | 141 | if (png_ptr == NULL) 142 | return; 143 | 144 | io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); 145 | fflush(io_ptr); 146 | } 147 | # endif 148 | #endif 149 | 150 | /* This function allows the application to supply new output functions for 151 | * libpng if standard C streams aren't being used. 152 | * 153 | * This function takes as its arguments: 154 | * png_ptr - pointer to a png output data structure 155 | * io_ptr - pointer to user supplied structure containing info about 156 | * the output functions. May be NULL. 157 | * write_data_fn - pointer to a new output function that takes as its 158 | * arguments a pointer to a png_struct, a pointer to 159 | * data to be written, and a 32-bit unsigned int that is 160 | * the number of bytes to be written. The new write 161 | * function should call png_error(png_ptr, "Error msg") 162 | * to exit and output any fatal error messages. May be 163 | * NULL, in which case libpng's default function will 164 | * be used. 165 | * flush_data_fn - pointer to a new flush function that takes as its 166 | * arguments a pointer to a png_struct. After a call to 167 | * the flush function, there should be no data in any buffers 168 | * or pending transmission. If the output method doesn't do 169 | * any buffering of output, a function prototype must still be 170 | * supplied although it doesn't have to do anything. If 171 | * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile 172 | * time, output_flush_fn will be ignored, although it must be 173 | * supplied for compatibility. May be NULL, in which case 174 | * libpng's default function will be used, if 175 | * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not 176 | * a good idea if io_ptr does not point to a standard 177 | * *FILE structure. 178 | */ 179 | void PNGAPI 180 | png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, 181 | png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) 182 | { 183 | if (png_ptr == NULL) 184 | return; 185 | 186 | png_ptr->io_ptr = io_ptr; 187 | 188 | #ifdef PNG_STDIO_SUPPORTED 189 | if (write_data_fn != NULL) 190 | png_ptr->write_data_fn = write_data_fn; 191 | 192 | else 193 | png_ptr->write_data_fn = png_default_write_data; 194 | #else 195 | png_ptr->write_data_fn = write_data_fn; 196 | #endif 197 | 198 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 199 | # ifdef PNG_STDIO_SUPPORTED 200 | 201 | if (output_flush_fn != NULL) 202 | png_ptr->output_flush_fn = output_flush_fn; 203 | 204 | else 205 | png_ptr->output_flush_fn = png_default_flush; 206 | 207 | # else 208 | png_ptr->output_flush_fn = output_flush_fn; 209 | # endif 210 | #endif /* PNG_WRITE_FLUSH_SUPPORTED */ 211 | 212 | /* It is an error to read while writing a png file */ 213 | if (png_ptr->read_data_fn != NULL) 214 | { 215 | png_ptr->read_data_fn = NULL; 216 | 217 | png_warning(png_ptr, 218 | "Can't set both read_data_fn and write_data_fn in the" 219 | " same structure"); 220 | } 221 | } 222 | 223 | #ifdef USE_FAR_KEYWORD 224 | # ifdef _MSC_VER 225 | void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 226 | { 227 | void *near_ptr; 228 | void FAR *far_ptr; 229 | FP_OFF(near_ptr) = FP_OFF(ptr); 230 | far_ptr = (void FAR *)near_ptr; 231 | 232 | if (check != 0) 233 | if (FP_SEG(ptr) != FP_SEG(far_ptr)) 234 | png_error(png_ptr, "segment lost in conversion"); 235 | 236 | return(near_ptr); 237 | } 238 | # else 239 | void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 240 | { 241 | void *near_ptr; 242 | void FAR *far_ptr; 243 | near_ptr = (void FAR *)ptr; 244 | far_ptr = (void FAR *)near_ptr; 245 | 246 | if (check != 0) 247 | if (far_ptr != ptr) 248 | png_error(png_ptr, "segment lost in conversion"); 249 | 250 | return(near_ptr); 251 | } 252 | # endif 253 | #endif 254 | #endif /* PNG_WRITE_SUPPORTED */ 255 | -------------------------------------------------------------------------------- /app/src/main/jni/logger.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by wei on 17-12-27. 3 | // 4 | 5 | #ifndef LOGGER 6 | #define LOGGER 7 | 8 | #include 9 | #define LOG_TAG "Native_LOG" 10 | 11 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) 12 | #define LOGW(...) __android_log_write(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__) 13 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) 14 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /app/src/main/jni/resize.c: -------------------------------------------------------------------------------- 1 | #include "logger.h" 2 | #include "resize.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | void swapJsampRow(unsigned char *src, unsigned char *dest) { 10 | unsigned char *temp; 11 | temp = dest; 12 | dest = src; 13 | src = temp; 14 | } 15 | 16 | /* 17 | * 18 | * factor : <1 && >0.5f 19 | */ 20 | int zoom_jpeg_file(char *inFileName, char *outFileName, float factor) { 21 | if (factor >= 1 || factor < 0.5f) { 22 | LOGE("the zoom factor is error, should between 0.5f and 1.0f. (0.5f<=factor<1.0f)"); 23 | return -1; 24 | } 25 | 26 | // init decompress struct 27 | struct jpeg_decompress_struct in; 28 | struct jpeg_error_mgr jInErr; 29 | 30 | JSAMPROW inRowPointer[1]; 31 | 32 | FILE *inFile = fopen(inFileName, "rb"); 33 | if (!inFile) { 34 | LOGE("Error opening jpeg file %s\n!", inFileName); 35 | return -1; 36 | } 37 | 38 | in.err = jpeg_std_error(&jInErr); 39 | jpeg_create_decompress(&in); 40 | jpeg_stdio_src(&in, inFile); 41 | jpeg_read_header(&in, TRUE); 42 | 43 | jpeg_start_decompress(&in); 44 | 45 | 46 | // init compress struct 47 | struct jpeg_compress_struct out; 48 | struct jpeg_error_mgr jOutErr; 49 | 50 | JSAMPROW outRowPointer[1]; 51 | 52 | FILE *outFile = fopen(outFileName, "wb"); 53 | if (!outFile) { 54 | LOGE("Error opening file %s\n", outFileName); 55 | return -1; 56 | } 57 | 58 | out.err = jpeg_std_error( &jOutErr); 59 | jpeg_create_compress(&out); 60 | jpeg_stdio_dest(&out, outFile); 61 | 62 | int width = in.output_width; 63 | int height = in.output_height; 64 | int bytesPerPixel = in.num_components; 65 | 66 | int destWidth = (int) (width * factor); 67 | int destHeight = (int) (height * factor); 68 | 69 | out.image_width = destWidth; 70 | out.image_height = destHeight; 71 | out.input_components = bytesPerPixel; 72 | out.in_color_space = JCS_RGB; 73 | 74 | jpeg_set_defaults(&out); 75 | jpeg_start_compress(&out, TRUE); 76 | 77 | 78 | // Process RGB data. 79 | int outRowStride = destWidth * bytesPerPixel; 80 | int inRowStride = width * bytesPerPixel; 81 | outRowPointer[0] = (unsigned char *) malloc(outRowStride); 82 | inRowPointer[0] = (unsigned char *) malloc(inRowStride); 83 | 84 | JSAMPROW baseInRowPointer[1]; 85 | baseInRowPointer[0] = (unsigned char *) malloc(inRowStride); 86 | 87 | unsigned char bUpLeft, bUpRight, bDownLeft, bDownRight; 88 | unsigned char gUpLeft, gUpRight, gDownLeft, gDownRight; 89 | unsigned char rUpLeft, rUpRight, rDownLeft, rDownRight; 90 | unsigned char b, g, r; 91 | 92 | float fX, fY; 93 | int iX, iY; 94 | int i, j; 95 | 96 | int currentBaseLocation = -1; 97 | 98 | int count = 0; 99 | 100 | // Process the first line. 101 | jpeg_read_scanlines(&in, inRowPointer, 1); 102 | for (j = 0; j < destWidth; j++) { 103 | fX = ((float) j) / factor; 104 | iX = (int) fX; 105 | 106 | bUpLeft = inRowPointer[0][iX * 3 + 0]; 107 | bUpRight = inRowPointer[0][(iX + 1) * 3 + 0]; 108 | 109 | gUpLeft = inRowPointer[0][iX * 3 + 1]; 110 | gUpRight = inRowPointer[0][(iX + 1) * 3 + 1]; 111 | 112 | rUpLeft = inRowPointer[0][iX * 3 + 2]; 113 | rUpRight = inRowPointer[0][(iX + 1) * 3 + 2]; 114 | 115 | b = bUpLeft * (iX + 1 - fX) + bUpRight * (fX - iX); 116 | g = gUpLeft * (iX + 1 - fX) + gUpRight * (fX - iX); 117 | r = rUpLeft * (iX + 1 - fX) + rUpRight * (fX - iX); 118 | 119 | outRowPointer[0][j * 3 + 0] = b; 120 | outRowPointer[0][j * 3 + 1] = g; 121 | outRowPointer[0][j * 3 + 2] = r; 122 | } 123 | jpeg_write_scanlines(&out, outRowPointer, 1); 124 | 125 | currentBaseLocation = 0; 126 | 127 | // Process the other lines between the first and last. 128 | for (i = 1; i < destHeight - 1; i++) { 129 | fY = ((float) i) / factor; 130 | iY = (int) fY; 131 | 132 | if (iY == currentBaseLocation) { 133 | in.output_scanline = iY; 134 | swapJsampRow(inRowPointer[0], baseInRowPointer[0]); 135 | jpeg_read_scanlines(&in, baseInRowPointer, 1); 136 | } else { 137 | in.output_scanline = iY - 1; 138 | jpeg_read_scanlines(&in, inRowPointer, 1); 139 | jpeg_read_scanlines(&in, baseInRowPointer, 1); 140 | } 141 | 142 | currentBaseLocation = iY + 1; 143 | 144 | for (j = 0; j < destWidth; j++) { 145 | fX = ((float) j) / factor; 146 | iX = (int) fX; 147 | 148 | bUpLeft = inRowPointer[0][iX * 3 + 0]; 149 | bUpRight = inRowPointer[0][(iX + 1) * 3 + 0]; 150 | bDownLeft = baseInRowPointer[0][iX * 3 + 0]; 151 | bDownRight = baseInRowPointer[0][(iX + 1) * 3 + 0]; 152 | 153 | gUpLeft = inRowPointer[0][iX * 3 + 1]; 154 | gUpRight = inRowPointer[0][(iX + 1) * 3 + 1]; 155 | gDownLeft = baseInRowPointer[0][iX * 3 + 1]; 156 | gDownRight = baseInRowPointer[0][(iX + 1) * 3 + 1]; 157 | 158 | rUpLeft = inRowPointer[0][iX * 3 + 2]; 159 | rUpRight = inRowPointer[0][(iX + 1) * 3 + 2]; 160 | rDownLeft = baseInRowPointer[0][iX * 3 + 2]; 161 | rDownRight = baseInRowPointer[0][(iX + 1) * 3 + 2]; 162 | 163 | b = bUpLeft * (iX + 1 - fX) * (iY + 1 - fY) + bUpRight * (fX - iX) * (iY + 1 - fY) + bDownLeft * (iX + 1 - fX) * (fY - iY) + bDownRight * (fX - iX) * (fY - iY); 164 | g = gUpLeft * (iX + 1 - fX) * (iY + 1 - fY) + gUpRight * (fX - iX) * (iY + 1 - fY) + gDownLeft * (iX + 1 - fX) * (fY - iY) + gDownRight * (fX - iX) * (fY - iY); 165 | r = rUpLeft * (iX + 1 - fX) * (iY + 1 - fY) + rUpRight * (fX - iX) * (iY + 1 - fY) + rDownLeft * (iX + 1 - fX) * (fY - iY) + rDownRight * (fX - iX) * (fY - iY); 166 | 167 | outRowPointer[0][j * 3 + 0] = b; 168 | outRowPointer[0][j * 3 + 1] = g; 169 | outRowPointer[0][j * 3 + 2] = r; 170 | } 171 | 172 | jpeg_write_scanlines(&out, outRowPointer, 1); 173 | } 174 | 175 | //Process the last line. 176 | in.output_scanline = height - 1; 177 | jpeg_read_scanlines(&in, inRowPointer, 1); 178 | for (j = 0; j < destWidth; j++) { 179 | fX = ((float) j) / factor; 180 | iX = (int) fX; 181 | 182 | bUpLeft = inRowPointer[0][iX * 3 + 0]; 183 | bUpRight = inRowPointer[0][(iX + 1) * 3 + 0]; 184 | 185 | gUpLeft = inRowPointer[0][iX * 3 + 1]; 186 | gUpRight = inRowPointer[0][(iX + 1) * 3 + 1]; 187 | 188 | rUpLeft = inRowPointer[0][iX * 3 + 2]; 189 | rUpRight = inRowPointer[0][(iX + 1) * 3 + 2]; 190 | 191 | b = bUpLeft * (iX + 1 - fX) + bUpRight * (fX - iX); 192 | g = gUpLeft * (iX + 1 - fX) + gUpRight * (fX - iX); 193 | r = rUpLeft * (iX + 1 - fX) + rUpRight * (fX - iX); 194 | 195 | outRowPointer[0][j * 3 + 0] = b; 196 | outRowPointer[0][j * 3 + 1] = g; 197 | outRowPointer[0][j * 3 + 2] = r; 198 | } 199 | jpeg_write_scanlines(&out, outRowPointer, 1); 200 | 201 | //free memory 202 | free(inRowPointer[0]); 203 | free(baseInRowPointer[0]); 204 | free(outRowPointer[0]); 205 | 206 | // close resource 207 | jpeg_finish_decompress(&in); 208 | jpeg_destroy_decompress(&in); 209 | fclose(inFile); 210 | 211 | jpeg_finish_compress(&out); 212 | jpeg_destroy_compress(&out); 213 | fclose(outFile); 214 | 215 | return 0; 216 | } -------------------------------------------------------------------------------- /app/src/main/jni/resize.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by wei on 17-12-29. 3 | // 4 | 5 | // factor : <1 && >0.5f 6 | int zoom_jpeg_file(char *inFileName, char *outFileName, float factor); -------------------------------------------------------------------------------- /app/src/main/jni/rotate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "transupp.h" /* Support routines for jpegtran */ 5 | 6 | 7 | /* various flags */ 8 | #define JFLAG_TRANSFORM_IMAGE 0x0001 9 | #define JFLAG_TRANSFORM_THUMBNAIL 0x0002 10 | #define JFLAG_TRANSFORM_TRIM 0x0004 11 | 12 | #define JFLAG_UPDATE_COMMENT 0x0010 13 | #define JFLAG_UPDATE_ORIENTATION 0x0020 14 | #define JFLAG_UPDATE_THUMBNAIL 0x0040 15 | 16 | #define JFLAG_FILE_BACKUP 0x0100 17 | #define JFLAG_FILE_KEEP_TIME 0x0200 18 | 19 | int rotate_jpeg(char *in,char *out,int degree) 20 | { 21 | 22 | JXFORM_CODE transform = JXFORM_ROT_90; 23 | 24 | switch(degree) 25 | { 26 | case 90: 27 | { 28 | transform = JXFORM_ROT_90; 29 | } 30 | break; 31 | 32 | case 180: 33 | { 34 | transform = JXFORM_ROT_180; 35 | } 36 | break; 37 | 38 | case 270: 39 | { 40 | transform = JXFORM_ROT_270; 41 | } 42 | break; 43 | default : return -1; 44 | } 45 | 46 | 47 | int tsize = 0; 48 | 49 | unsigned int flags = 50 | JFLAG_TRANSFORM_IMAGE | 51 | JFLAG_TRANSFORM_THUMBNAIL | 52 | JFLAG_TRANSFORM_TRIM | 53 | JFLAG_UPDATE_ORIENTATION; 54 | 55 | flags &= ~JFLAG_UPDATE_ORIENTATION; 56 | 57 | 58 | JCOPY_OPTION copyoption; 59 | jpeg_transform_info transformoption; 60 | 61 | struct jpeg_decompress_struct srcinfo; 62 | struct jpeg_compress_struct dstinfo; 63 | struct jpeg_error_mgr jsrcerr, jdsterr; 64 | jvirt_barray_ptr * src_coef_arrays; 65 | jvirt_barray_ptr * dst_coef_arrays; 66 | //int file_index; 67 | srcinfo.err = jpeg_std_error(&jsrcerr); 68 | jpeg_create_decompress(&srcinfo); 69 | dstinfo.err = jpeg_std_error(&jdsterr); 70 | jpeg_create_compress(&dstinfo); 71 | jsrcerr.trace_level = jdsterr.trace_level; 72 | srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; 73 | 74 | copyoption = JCOPYOPT_DEFAULT; 75 | transformoption.trim = FALSE; 76 | transformoption.crop = FALSE; 77 | transformoption.force_grayscale = FALSE; 78 | transformoption.transform = transform; 79 | 80 | 81 | FILE * infile = fopen(in, "rb"); 82 | 83 | jpeg_stdio_src(&srcinfo, infile); 84 | jcopy_markers_setup(&srcinfo, copyoption); 85 | (void) jpeg_read_header(&srcinfo, TRUE); 86 | 87 | jtransform_request_workspace(&srcinfo, &transformoption); 88 | 89 | src_coef_arrays = jpeg_read_coefficients(&srcinfo); 90 | jpeg_copy_critical_parameters(&srcinfo, &dstinfo); 91 | dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo,src_coef_arrays,&transformoption); 92 | 93 | 94 | FILE * outfile = fopen(out, "wb"); 95 | jpeg_stdio_dest(&dstinfo, outfile); 96 | jpeg_write_coefficients(&dstinfo, dst_coef_arrays); 97 | jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); 98 | jtransform_execute_transformation( 99 | &srcinfo, 100 | &dstinfo, 101 | src_coef_arrays, 102 | &transformoption); 103 | 104 | jpeg_finish_compress(&dstinfo); 105 | jpeg_destroy_compress(&dstinfo); 106 | (void) jpeg_finish_decompress(&srcinfo); 107 | jpeg_destroy_decompress(&srcinfo); 108 | // 109 | if (infile!= stdin) 110 | fclose(infile); 111 | if (outfile!= stdout) 112 | fclose(outfile); 113 | 114 | 115 | return 0; 116 | } 117 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BypassDalvikOPTImage 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/androidyuan/jpg_rotate/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.androidyuan.jpg_rotate; 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 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | maven { url "http://maven.aliyun.com/nexus/content/groups/public/" } 7 | maven { url "https://jitpack.io" } 8 | jcenter() 9 | google() 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.0.0' 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | maven { url "http://maven.aliyun.com/nexus/content/groups/public/" } 19 | maven { url "https://jitpack.io" } 20 | jcenter() 21 | google() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /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/BruceWind/OperatingImageBypassJavaHeap/5c284e277b28fb232f5c2dcda3bd6d03e407d8db/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 07 16:36:29 CST 2017 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: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------