├── .gitignore ├── LICENSE ├── README.md ├── app ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── sabirjan │ │ ├── reader │ │ └── tools │ │ │ ├── HexUtil.java │ │ │ ├── Tool.java │ │ │ └── WltDecodeUtil.java │ │ └── wlt2bmpdemo │ │ ├── MainActivity.java │ │ └── TempGlobal.java │ ├── jni │ ├── Android.mk │ ├── Application.mk │ ├── common │ │ ├── Android_Log.h │ │ └── BitmapFile.h │ ├── decode │ │ ├── Android.mk │ │ ├── Wlt2BmpUtils.cpp │ │ └── Wlt2BmpUtils.h │ ├── decodetools │ │ ├── Android.mk │ │ ├── DecodePhoto.cpp │ │ └── DecodePhoto.h │ └── prebuild │ │ ├── Android.mk │ │ └── wlttobmp.a │ ├── libs │ ├── armeabi-v7a │ │ └── libWlt2Bmp.so │ └── armeabi │ │ └── libWlt2Bmp.so │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ ├── menu │ └── main.xml │ ├── values-v11 │ └── styles.xml │ ├── values-v14 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── import-summary.txt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | 43 | # Keystore files 44 | *.jks 45 | 46 | # External native build folder generated in Android Studio 2.2 and later 47 | .externalNativeBuild 48 | 49 | # Google Services (e.g. APIs or Firebase) 50 | google-services.json 51 | 52 | # Freeline 53 | freeline.py 54 | freeline/ 55 | freeline_project_description.json 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sabirjan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WLT2Bmp_Android 2 | ### WLT2Bmp,WLT图片解码,身份证照相解码,身份证图片解码 3 | ### 暂不支持64位手机,我看了市场上比较流行的卡尔和其他阅读器,都暂不支持64位手机解码 4 | ### 继续研究中.... 5 | ### 《Star》 一下吧! 6 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.sabirjan.wlt2bmpdemo" 9 | minSdkVersion 18 10 | targetSdkVersion 26 11 | versionCode 1 12 | versionName "1.0" 13 | externalNativeBuild { 14 | cmake { 15 | cppFlags "" 16 | } 17 | } 18 | } 19 | sourceSets { 20 | main { 21 | jni.srcDirs = ["armeabi-v7a","armeabi"] 22 | } 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled false 28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | sourceSets { 32 | main { 33 | jni.srcDirs=[] 34 | jniLibs.srcDirs 'src/main/libs' 35 | } 36 | } 37 | 38 | task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') { 39 | commandLine getNdkBuildCmd(), 40 | 'NDK_PROJECT_PATH=build/intermediates/ndk', 41 | 'NDK_LIBS_OUT=src/main/libs', 42 | 'APP_BUILD_SCRIPT=src/main/jni/Android.mk', 43 | 'NDK_APPLICATION_MK=src/main/jni/Application.mk' 44 | } 45 | tasks.withType(JavaCompile) { 46 | compileTask -> compileTask.dependsOn ndkBuild 47 | } 48 | 49 | } 50 | def getNdkDir() { 51 | if (System.env.ANDROID_NDK_ROOT != null) 52 | return System.env.ANDROID_NDK_ROOT 53 | Properties properties = new Properties() 54 | properties.load(project.rootProject.file('local.properties') 55 | .newDataInputStream()) 56 | def ndkdir = properties.getProperty('ndk.dir', null) 57 | if (ndkdir == null) 58 | throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.") 59 | 60 | return ndkdir 61 | } 62 | 63 | def getNdkBuildCmd() { 64 | def ndkbuild = getNdkDir() + "/ndk-build" 65 | ndkbuild += ".cmd" 66 | return ndkbuild 67 | } 68 | dependencies { 69 | // compile fileTree(dir: 'libs', include: ['*.jar']) 70 | // androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 71 | // exclude group: 'com.android.support', module: 'support-annotations' 72 | // }) 73 | //ompile 'com.android.support:appcompat-v7:26.+' 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/sabirjan/reader/tools/HexUtil.java: -------------------------------------------------------------------------------- 1 | package com.sabirjan.reader.tools; 2 | 3 | /** 4 | * Created by Sabirjan on 2017/11/6. 5 | * HexUtil. 6 | * 新疆精灵通电子科技有限公司 7 | */ 8 | public class HexUtil { 9 | public static String bytesToHexString(byte[] src) { 10 | StringBuilder stringBuilder = new StringBuilder(""); 11 | if (src == null) { 12 | return null; 13 | } 14 | for (int i = 0; i < src.length; i++) { 15 | int v = src[i] & 0xFF; 16 | String hv = Integer.toHexString(v).toUpperCase(); 17 | if (hv.length() < 2) { 18 | stringBuilder.append(0); 19 | } 20 | stringBuilder.append(hv); 21 | } 22 | return stringBuilder.toString(); 23 | 24 | } 25 | private static String hexStr = "0123456789ABCDEF"; 26 | public static String bin2HexStr(byte[] bytes){ 27 | 28 | String result = ""; 29 | String hex = ""; 30 | for(int i=0;i>4)); 33 | //字节低4位 34 | hex += String.valueOf(hexStr.charAt(bytes[i]&0x0F)); 35 | result +=hex; //+" " 36 | } 37 | return result; 38 | } 39 | public static String bytesToHexString(byte[] src, int nLen) { 40 | StringBuilder stringBuilder = new StringBuilder(""); 41 | if (src == null || src.length < 0 || nLen < 0) { 42 | return null; 43 | } 44 | for (int i = 0; i < src.length && i < nLen; i++) { 45 | int v = src[i] & 0xFF; 46 | String hv = Integer.toHexString(v).toUpperCase(); 47 | if (hv.length() < 2) { 48 | stringBuilder.append(0); 49 | } 50 | stringBuilder.append(hv); 51 | } 52 | return stringBuilder.toString(); 53 | } 54 | 55 | /** 56 | * Convert hex string to byte[] 57 | * 58 | * @param hexString the hex string 59 | * @return byte[] 60 | */ 61 | public static byte[] hexStringToBytes(String hexString) { 62 | if (hexString == null) { 63 | return null; 64 | } 65 | hexString = hexString.toUpperCase(); 66 | int length = hexString.length() / 2; 67 | char[] hexChars = hexString.toCharArray(); 68 | byte[] d = new byte[length]; 69 | for (int i = 0; i < length; i++) { 70 | int pos = i * 2; 71 | d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); 72 | } 73 | return d; 74 | 75 | } 76 | 77 | /** 78 | * Convert char to byte 79 | * 80 | * @param c char 81 | * @return byte 82 | */ 83 | private static byte charToByte(char c) { 84 | return (byte) "0123456789ABCDEF".indexOf(c); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/sabirjan/reader/tools/Tool.java: -------------------------------------------------------------------------------- 1 | package com.sabirjan.reader.tools; 2 | 3 | /** 4 | * Created by Sabirjan on 2017/11/6. 5 | * Wlt2BmpDemo1. 6 | * 新疆精灵通电子科技有限公司 7 | */ 8 | 9 | import android.graphics.Bitmap; 10 | import android.util.Log; 11 | 12 | public class Tool 13 | { 14 | public static Bitmap getBitmap(byte []data) { 15 | byte[] arrayOfByte1 = new byte[40960]; 16 | try { 17 | if(data==null) return null; 18 | int k = new WltDecodeUtil().Wlt2Bmp(data, arrayOfByte1); 19 | 20 | Log.i("解码", "getBitmap: 解码结果:"+k); 21 | if (k != 1) { 22 | return null; 23 | } 24 | byte[] arrayOfByte2 = new byte[38556]; 25 | System.arraycopy(arrayOfByte1, 0, arrayOfByte2, 0, 38556); 26 | 27 | return Tool.createRgbBitmap(arrayOfByte2, 102, 126); 28 | 29 | 30 | } catch (Exception localException) { 31 | localException.printStackTrace(); 32 | } 33 | return null; 34 | } 35 | private static int convertByteToInt(byte paramByte) 36 | { 37 | int i = paramByte >> 4 & 0xF; 38 | int j = 0xF & paramByte; 39 | return i * 16 + j; 40 | } 41 | 42 | private static int[] convertByteToColor(byte[] paramArrayOfByte, int paramInt1, int paramInt2) 43 | { 44 | int i = paramArrayOfByte.length; 45 | if (i == 0) { 46 | return null; 47 | } 48 | int[] arrayOfInt = new int[i / 3]; 49 | for (int n = 0; n < paramInt2; n++) 50 | { 51 | int i1 = n * paramInt1; 52 | for (int i2 = 0; i2 < paramInt1; i2++) 53 | { 54 | int i3 = (i1 + i2) * 3; 55 | int j = convertByteToInt(paramArrayOfByte[i3]); 56 | int k = convertByteToInt(paramArrayOfByte[(i3 + 1)]); 57 | int m = convertByteToInt(paramArrayOfByte[(i3 + 2)]); 58 | arrayOfInt[((paramInt2 - n - 1) * paramInt1 + i2)] = (j << 16 | k << 8 | m | 0xFF000000); 59 | } 60 | } 61 | return arrayOfInt; 62 | } 63 | 64 | private static Bitmap createRgbBitmap(byte[] paramArrayOfByte, int paramInt1, int paramInt2) 65 | { 66 | int[] arrayOfInt = convertByteToColor(paramArrayOfByte, paramInt1, paramInt2); 67 | if (arrayOfInt == null) { 68 | return null; 69 | } 70 | Bitmap localBitmap = Bitmap.createBitmap(arrayOfInt, 0, paramInt1, paramInt1, paramInt2, Bitmap.Config.ARGB_8888); 71 | return localBitmap; 72 | } 73 | } -------------------------------------------------------------------------------- /app/src/main/java/com/sabirjan/reader/tools/WltDecodeUtil.java: -------------------------------------------------------------------------------- 1 | package com.sabirjan.reader.tools; 2 | /** 3 | * Created by Sabirjan on 2017/11/6. 4 | * WltDecodeUtil. 5 | * 新疆精灵通电子科技有限公司 6 | */ 7 | public class WltDecodeUtil { 8 | 9 | public native int Wlt2Bmp(byte[] wlt,byte[] bmp); 10 | static{ 11 | System.loadLibrary("Wlt2Bmp"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/sabirjan/wlt2bmpdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sabirjan.wlt2bmpdemo; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Bitmap; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.view.View; 8 | import android.widget.EditText; 9 | import android.widget.ImageView; 10 | import android.widget.Toast; 11 | 12 | import com.sabirjan.reader.tools.Tool; 13 | 14 | /** 15 | * 16 | * @author Administrator 17 | * wlt的图片解码库不支持64位的手机,如果放到64位手机上,解出来的图片可能是黑乎乎的 18 | */ 19 | public class MainActivity extends Activity { 20 | ImageView image; 21 | String TAG = "MainActivity"; 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_main); 27 | initView(); 28 | } 29 | 30 | public void initView() { 31 | image = (ImageView) findViewById(R.id.image); 32 | } 33 | 34 | //点击转换 35 | public void convert(View view) { 36 | Log.e(TAG, "------------------convert(View view)"); 37 | Bitmap ret2 = Tool.getBitmap(TempGlobal.GetWLTData());//获取模拟的身份证图片数据 38 | if (ret2 !=null) { 39 | image.setImageBitmap(ret2); 40 | } else { 41 | Toast.makeText(this, "解码图片失败!", Toast.LENGTH_SHORT).show(); 42 | } 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/sabirjan/wlt2bmpdemo/TempGlobal.java: -------------------------------------------------------------------------------- 1 | package com.sabirjan.wlt2bmpdemo; 2 | 3 | import com.sabirjan.reader.tools.HexUtil; 4 | 5 | import java.util.Arrays; 6 | 7 | /** 8 | * Created by Sabirjan on 2017/11/6. 9 | * Wlt2BmpDemo1. 10 | * 新疆精灵通电子科技有限公司 11 | */ 12 | 13 | public class TempGlobal { 14 | private static final int SEEK_SIZE = 14; 15 | //身份证安全模块返回的解码数据包 ,总 大小 14+256+1024(不带指纹)个字节,后面的1024是图片部分 16 | //下面的是只图片部分的数据 17 | private static final String CardData = "574C66007E00320000FF851F5151513E710DD564F350E2BB9B9F7A010E4233A8DD4F2C5EF190F54D85E60537686AABB46D4DC2F2FD58FD92BC4D4EB30647F0FAC53DB43D916360B2B1F4D642424251EBBCC69F04E8090CBA6919C6D1AED45251515A3E8B6246D19862CCDC7E754C344D0BFDD948FD76C99E69CAD984BAAAD09DB68E3773CAEA2B9F446289085D7CE7C795A95E60BDE9179AA191CBD15C53B5E6D68C1E0A8032837FA76E18E40ED4D1D7CDE63FB414F76DF79D079B012BBD5FA40EA20C7D2BBDA8EB0F27B4EA91C67938B3E1EF3CCC5EC369F11B3012FBF72780DCD2A8C270DC046FD9EE903E949ACD5566470F3A605C75827254C27AC8189775D09D9E4B35ABAA35400D8D29B153A95141DEFC38206529FFFCB6AE51893E3298A89364C366B74969E35E772ACA8264B68E50F3427DF7BC7521E34B59C38AAC2AE1D2D3C9FC3F11E4BED7C6633E01489A80012C2C7F986852F0954E4FDED8A4748F3DC5AF5618BB38E27E35455423E8F9726CD5D2345246B2E5DEA430A1B8EAAA80FBE1BD3590374369DA9B72EDA9AC9CDED0557C1F50C38AB3EA05C115EA139B185BC0665833F5C3FD302D1ED1C91B2EE70B562E591FCCC937BF1A23AD98F798D66FB0DDFFAB286B7D121FB3F14A268568B2741CD5F0980E96F0FC365058F810C1140A73085D2737DADCD4D8AA3ED4DF9C3CA4C12A8E347A7A0BFE122EE47DC986E51AE1EB043286F6FF184CE1A7D1D098A2635036ECC58533003916073832362B5B498724F57D3DED0EADC39B178BAC6DAA61F119FFAAF46E1E5D5F1D7CBF818692BC7AC79F8D5CB2A21830AF800A3A920B230BABF9FA2EAAB7A9168063D32180C473C55A44EA74F53238BDA18C883FECF25FF114DB64C2BC9509788023328E0E39F89A66AF999867FFD9CD1E6A56C32F39797E44281668D31304C5A8EB8A3E99FC22C1AAF73EC262EE488786C829988319DA551C12D0D6BAF5B6551C8360CB50CBF306B3680110991F38EA803275B313E5D6F22D4E87EB22E5E3C65D2A3818191A52F843CD1BD710F1B5B099531929DD3EE0A3F039ED9729A6EF0B9CD93C0A498E13395D0C4FCA1964D0A8705BDADCC7A2B6F813EAB2AE51C3F2E07A6DC06A30EB71D710F298AE51CF350A420F415669628BBF2ED2FC25D0D47FFD2F6D6FEB61D8767054D500F4DAAE518D9E0C5FCFACC7B6E3CBBA0BF1ABB3514968E7EC2B5AB0462BDE5A3E306D321C59D2FA7CE175DB31C74FB7B2F737B31C48EAA69EDCCF794106A06085626F1483615F318EE270384BEBEADCFDDF646A66331506145F88E4EB9028F93D45EF447105EF72A5F8EF42DD3853D65A3E8B12708FDB7253AA3CEF27F8CCECBE5B1E75941A70E683A05A72C3CBE2919B78D0777A9580B50CBE5B4DC4AAEAFB91FF682645F72027BB89A63690AD3A4FA093AAEF263D3FCFB66DE3"; 18 | public static byte[] GetWLTData() { 19 | try { 20 | byte[] data = HexUtil.hexStringToBytes(CardData); 21 | byte[] wltData = Arrays.copyOfRange(data, 0, 0 + 1024); 22 | return wltData; 23 | } catch (Exception ex) { 24 | ex.printStackTrace(); 25 | } 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) -------------------------------------------------------------------------------- /app/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_CFLAGS += -Wno-error=format-security 2 | # 'x86', 'x86_64', 'arm64-v8a' 3 | #APP_ABI := armeabi-v7a armeabi 4 | #APP_ABI := armeabi,armeabi-v7a 5 | ##all #x86_64 arm64-v8a 6 | #armeabi-v7a armeabi arm64-v8a 7 | #x86 #x86_64 arm64-v8a 8 | APP_ABI := armeabi armeabi-v7a -------------------------------------------------------------------------------- /app/src/main/jni/common/Android_Log.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef ANDROID_LOG_H_ 3 | #define ANDROID_LOG_H_ 4 | 5 | #include "android/log.h" 6 | #include 7 | #include 8 | #include 9 | 10 | static const char * TAG="Wlt2Bmp_native"; 11 | #define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##args) 12 | #define LOGW(fmt, args...) __android_log_print(ANDROID_LOG_WARN, TAG, fmt, ##args) 13 | #define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args) 14 | #define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args) 15 | 16 | void Logfile(const char* fmt,...); 17 | 18 | bool Read2WriteConfig(bool isRead,char *tag,char *result); 19 | 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/jni/common/BitmapFile.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITMAP_FILE_H 2 | #define _BITMAP_FILE_H 3 | typedef short WORD; 4 | typedef int DWORD; 5 | typedef int LONG; 6 | typedef char BYTE; 7 | /* 8 | 1:BMP文件组成 9 | BMP文件由文件头、位图信息头、颜色信息和图形数据四部分组成。 10 | */ 11 | /* 12 | 2:BMP文件头(14字节) 13 | BMP文件头数据结构含有BMP文件的类型、文件大小和位图起始位置等信息。 14 | */ 15 | 16 | typedef struct tagBITMAPFILEHEADER { 17 | WORD bfType; // 位图文件的类型,必须为BM(1-2字节) 18 | DWORD bfSize; // 位图文件的大小,以字节为单位(3-6字节) 19 | WORD bfReserved1; // 位图文件保留字,必须为0(7-8字节) 20 | WORD bfReserved2; // 位图文件保留字,必须为0(9-10字节) 21 | DWORD bfOffBits; // 位图数据的起始位置,以相对于位图(11-14字节) 22 | // 文件头的偏移量表示,以字节为单位 23 | } BITMAPFILEHEADER; 24 | /* 25 | * 26 | 3:位图信息头(40字节) 27 | BMP位图信息头数据用于说明位图的尺寸等信息 28 | */ 29 | typedef struct tagBITMAPINFOHEADER { 30 | DWORD biSize; // 本结构所占用字节数(15-18字节) 31 | LONG biWidth; // 位图的宽度,以像素为单位(19-22字节) 32 | LONG biHeight; // 位图的高度,以像素为单位(23-26字节) 33 | WORD biPlanes; // 目标设备的级别,必须为1(27-28字节) 34 | WORD biBitCount; // 每个像素所需的位数,必须是1(双色),(29-30字节) 35 | // 4(16色),8(256色)16(高彩色)或24(真彩色)之一 36 | DWORD biCompression; // 位图压缩类型,必须是 0(不压缩),(31-34字节) 37 | // 1(BI_RLE8压缩类型)或2(BI_RLE4压缩类型)之一 38 | DWORD biSizeImage; // 位图的大小(其中包含了为了补齐行数是4的倍数而添加的空字节),以字节为单位(35-38字节) 39 | LONG biXPelsPerMeter; // 位图水平分辨率,每米像素数(39-42字节) 40 | LONG biYPelsPerMeter; // 位图垂直分辨率,每米像素数(43-46字节) 41 | DWORD biClrUsed; // 位图实际使用的颜色表中的颜色数(47-50字节) 42 | DWORD biClrImportant; // 位图显示过程中重要的颜色数(51-54字节) 43 | } BITMAPINFOHEADER; 44 | /* 45 | 4:颜色表 46 | 颜色表用于说明位图中的颜色,它有若干个表项,每一个表项是一个RGBQUAD类型的结构,定义一种颜色。RGBQUAD结构的定义如下: 47 | */ 48 | typedef struct tagRGBQUAD { 49 | BYTE rgbBlue;// 蓝色的亮度(值范围为0-255) 50 | BYTE rgbGreen; // 绿色的亮度(值范围为0-255) 51 | BYTE rgbRed; // 红色的亮度(值范围为0-255) 52 | BYTE rgbReserved;// 保留,必须为0 53 | } RGBQUAD; 54 | /* 55 | 颜色表中RGBQUAD结构数据的个数有biBitCount来确定: 56 | 当biBitCount=1,4,8时,分别有2,16,256个表项; 57 | 当biBitCount=24时,没有颜色表项。 58 | 位图信息头和颜色表组成位图信息,BITMAPINFO结构定义如下: 59 | */ 60 | typedef struct tagBITMAPINFO { 61 | BITMAPINFOHEADER bmiHeader; // 位图信息头 62 | RGBQUAD bmiColors[1]; // 颜色表 63 | } BITMAPINFO; 64 | /* 65 | 5:位图数据 66 | 位图数据记录了位图的每一个像素值,记录顺序是在扫描行内是从左到右,扫描行之间是从下到上。位图的一个像素值所占的字节数: 67 | 当biBitCount=1时,8个像素占1个字节; 68 | 当biBitCount=4时,2个像素占1个字节; 69 | 当biBitCount=8时,1个像素占1个字节; 70 | 当biBitCount=24时,1个像素占3个字节,按顺序分别为B,G,R; 71 | Windows规定一个扫描行所占的字节数必须是 72 | 4的倍数(即以long为单位),不足的以0填充, 73 | biSizeImage = ((((bi.biWidth * bi.biBitCount) + 31) & ~31) / 8) * bi.biHeight; 74 | 具体数据举例: 75 | 如某BMP文件开头: 76 | 424D 46900000 0000 0000 4600 0000 2800 0000 8000 0000 9000 0000 0100*1000 0300 0000 0090 0000 A00F 0000 A00F0000 0000 00000000 0000*00F8 E007 1F00 0000*02F1 84F1 04F1 84F1 84F1 06F2 84F1 06F2 04F2 86F2 06F2 86F2 86F2 .... .... 77 | 读取方法 78 | */ 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /app/src/main/jni/decode/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | # define so output folder 5 | #NDK_APP_DST_DIR := libs/$(TARGET_ARCH_ABI)/usb 6 | 7 | LOCAL_MODULE := Wlt2Bmp 8 | LOCAL_SRC_FILES += \ 9 | ./Wlt2BmpUtils.cpp \ 10 | 11 | LOCAL_LDLIBS += -llog 12 | 13 | LOCAL_STATIC_LIBRARIES := \ 14 | usbidcard \ 15 | 16 | include $(BUILD_SHARED_LIBRARY) 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/jni/decode/Wlt2BmpUtils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Wlt2BmpUtils.h" 4 | #include "../common/Android_Log.h" 5 | #include "../decodetools/DecodePhoto.h" 6 | JavaVM *mVM; 7 | JNIEnv *m_Env; 8 | int unpack(char *src, char *dst, int bmpSave); 9 | JNIEXPORT jint JNICALL Java_com_sabirjan_reader_tools_WltDecodeUtil_Wlt2Bmp 10 | (JNIEnv *env, jobject object,jbyteArray wlt,jbyteArray bmpparam) 11 | { 12 | env->GetJavaVM(&mVM); 13 | jbyte *wlt_temp=env->GetByteArrayElements(wlt,0); 14 | char *wltchar=(char*)wlt_temp; 15 | jbyte *bmp=env->GetByteArrayElements(bmpparam,0); 16 | char *bmpchar=(char*)bmp; 17 | int ret = CallWlt2BmpBytes(wltchar,bmpchar); 18 | LOGE("------------------2---"); 19 | free(wltchar); 20 | //free(bmpchar); 21 | return ret; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/jni/decode/Wlt2BmpUtils.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_sabirjan_reader_tools_WltDecodeUtil_Wlt2Bmp */ 4 | 5 | #ifndef _Included_com_sabirjan_reader_tools_WltDecodeUtil_Wlt2Bmp 6 | #define _Included_com_sabirjan_reader_tools_WltDecodeUtil_Wlt2Bmp 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | JNIEXPORT jint JNICALL Java_com_sabirjan_reader_tools_WltDecodeUtil_Wlt2Bmp 12 | (JNIEnv *, jobject,jbyteArray,jbyteArray); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | #endif 18 | -------------------------------------------------------------------------------- /app/src/main/jni/decodetools/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | # define so output folder 5 | #NDK_APP_DST_DIR := libs/$(TARGET_ARCH_ABI)/usb 6 | 7 | LOCAL_MODULE := usbidcard 8 | LOCAL_SRC_FILES += \ 9 | DecodePhoto.cpp \ 10 | 11 | 12 | LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog 13 | 14 | LOCAL_STATIC_LIBRARIES := \ 15 | wlttobmp \ 16 | 17 | include $(BUILD_STATIC_LIBRARY) 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/jni/decodetools/DecodePhoto.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DecodePhoto.cpp 3 | * 4 | * Created on: 2017-11-05 5 | * Author: Sabirjan 6 | */ 7 | #include "DecodePhoto.h" 8 | #include "../common/Android_Log.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | HMODULE hModuleWltRS = NULL; 15 | Unpack unpackWltRS = 0; 16 | int unpack(char *src,char *dst,int bmpSave); 17 | 18 | int CallWlt2BmpBytes(char *wlt, char *bmp) { 19 | 20 | jint result; 21 | LOGE(">> ------CallWlt2BmpBytes"); 22 | result = unpack(wlt, bmp, 0); 23 | LOGE("CallWlt2BmpBytes(),unpack complete!unpack result = %d", result); 24 | return result; 25 | 26 | } -------------------------------------------------------------------------------- /app/src/main/jni/decodetools/DecodePhoto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DecodePhoto.h 3 | * 4 | * Created on: 2017-11-05 5 | * Author: Sabirjan 6 | */ 7 | 8 | #ifndef DECODEPHOTO_H_ 9 | #define DECODEPHOTO_H_ 10 | #include 11 | #include 12 | #include 13 | typedef int * HMODULE; 14 | typedef int (*Unpack)(const char*, const char*, int); 15 | int Loaddl(); 16 | int CallWlt2Bmp(char* wltPath, char* bmpPath); 17 | int CallWlt2BmpBytes(char *wlt, char *bmp); 18 | #endif 19 | -------------------------------------------------------------------------------- /app/src/main/jni/prebuild/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2009 Cedric Priscal 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 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE := wlttobmp 21 | LOCAL_SRC_FILES := wlttobmp.a 22 | LOCAL_LDLIBS := -ldl -llog 23 | include $(PREBUILT_STATIC_LIBRARY) 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/jni/prebuild/wlttobmp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BadDeveloper2022/WLT2Bmp_Android/793d2fe9d1d73196b80d7aefb304dd970fb694b0/app/src/main/jni/prebuild/wlttobmp.a -------------------------------------------------------------------------------- /app/src/main/libs/armeabi-v7a/libWlt2Bmp.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BadDeveloper2022/WLT2Bmp_Android/793d2fe9d1d73196b80d7aefb304dd970fb694b0/app/src/main/libs/armeabi-v7a/libWlt2Bmp.so -------------------------------------------------------------------------------- /app/src/main/libs/armeabi/libWlt2Bmp.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BadDeveloper2022/WLT2Bmp_Android/793d2fe9d1d73196b80d7aefb304dd970fb694b0/app/src/main/libs/armeabi/libWlt2Bmp.so -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BadDeveloper2022/WLT2Bmp_Android/793d2fe9d1d73196b80d7aefb304dd970fb694b0/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BadDeveloper2022/WLT2Bmp_Android/793d2fe9d1d73196b80d7aefb304dd970fb694b0/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BadDeveloper2022/WLT2Bmp_Android/793d2fe9d1d73196b80d7aefb304dd970fb694b0/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BadDeveloper2022/WLT2Bmp_Android/793d2fe9d1d73196b80d7aefb304dd970fb694b0/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 |