Giter VIP home page Giter VIP logo

idcard-compound's Introduction

IDcard-compound

中华人民共和国身份证合成工具
1. 支持根据基本信息合成身份证正反面
2. 支持身份证正反面合成在一页

效果图

demo下载app-debug.apk
加载中...

引用

##Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

##Step 2. Add the dependency

dependencies {
	        implementation 'com.github.kellysong:IDcard-compound:1.0.2'
	}

或者引用本地lib

implementation project(':IDcard-compound-library')

使用

方法列表

方法 描述
outSdCardFlag 合成图片是否输出SD卡
compound 合成,异步调用
syncCompound 合成,同步调用(耗时,方便结合rxjava)
release 释放内存

使用步骤

1.初始化

//构建身份证基本信息
//头像可以是Bitmap或者原始头像整形数组
IdentityCard identityCard = new IdentityCard(name, sex, nation, birthday, address, idCardNo,police, expiryDate, headImg);
//初始化合成实例
IdentityCardHandler identityCardHandler = IdentityCardHandler.getInstance(this);

2.合成调用

  1. 根据基本信息合成身份证正反面

     identityCardHandler.compound(identityCard, new CompoundListener() {
         @Override
         public void onStart() {
     		// TODO 合成开始前调用,可以启动 loading UI
         }
    
         @Override
         public void onSuccess(IdentityCard identityCard) {
     		// TODO 合成成功后调用,返回合成后的身份实体
              Bitmap frontBitmap = identityCard.getFrontBitmap();//正面
              Bitmap backBitmap = identityCard.getBackBitmap();//反面
     		 String frontImageBase64 = identityCard.getFrontImageBase64();//正面base64
              String backImageBase64 = identityCard.getBackImageBase64();//反面base64
    
         }
    
         @Override
         public void onFailed(Throwable t) {
            // TODO 合成失败调用,用于排除问题
         }
     });
    
  2. 身份证正反面合成在一页

     identityCardHandler.compound(true,identityCard, new CompoundListener() {
         @Override
         public void onStart() {
     		// TODO 合成开始前调用,可以启动 loading UI
         }
    
         @Override
         public void onSuccess(IdentityCard identityCard) {
     		// TODO 合成成功后调用,返回合成后的身份实体
            	Bitmap fullBitmap = identityCard.getFullBitmap();//正反合并页
             String fullBitmapBase64 = identityCard.getFullBitmapBase64();//正反base64
    
    
         }
    
         @Override
         public void onFailed(Throwable t) {
            // TODO 合成失败调用,用于排除问题
         }
     });
    

3.释放内存

identityCardHandler.release();

4.其它调用

//对身份证进行缩放调整
BitmapUtils.scaleBitmap(identityCard.getFrontBitmap(), 1.2f)

License

Copyright 2019 Song Jiali

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

idcard-compound's People

Contributors

kellysong avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.