├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ └── scan.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_capture.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── ic_capture.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── ic_capture.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_capture.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
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_capture.xml
│ │ │ │ ├── fragment_socket_server.xml
│ │ │ │ ├── activity_rtsplayer.xml
│ │ │ │ ├── activity_screen_record_by_codec.xml
│ │ │ │ ├── activity_camera_record.xml
│ │ │ │ ├── activity_socket.xml
│ │ │ │ ├── activity_record.xml
│ │ │ │ ├── activity_scanqr.xml
│ │ │ │ ├── dlg_scan_result.xml
│ │ │ │ ├── fragment_socket_client.xml
│ │ │ │ └── activity_main.xml
│ │ │ ├── values-zh-rCN
│ │ │ │ └── strings.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── softard
│ │ │ │ └── wow
│ │ │ │ └── screencapture
│ │ │ │ ├── Utils
│ │ │ │ ├── SocketUtils.java
│ │ │ │ ├── ScreenUtils.java
│ │ │ │ └── ImageUtils.java
│ │ │ │ ├── CodecTools
│ │ │ │ ├── Encoder.java
│ │ │ │ ├── AudioEncoder.java
│ │ │ │ ├── VideoEncoder.java
│ │ │ │ ├── AudioEncodeConfig.java
│ │ │ │ └── VideoEncodeConfig.java
│ │ │ │ ├── MainApplication.java
│ │ │ │ ├── View
│ │ │ │ ├── RTSPlayerActivity.java
│ │ │ │ └── SocketActivity.java
│ │ │ │ ├── QRCode
│ │ │ │ ├── Utils.java
│ │ │ │ └── ResultDialog.java
│ │ │ │ └── BaseActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── softard
│ │ │ └── wow
│ │ │ └── screencapture
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── softard
│ │ └── wow
│ │ └── screencapture
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── zxing
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── google
│ │ │ └── zxing
│ │ │ ├── ResultPointCallback.java
│ │ │ ├── common
│ │ │ ├── reedsolomon
│ │ │ │ ├── ReedSolomonException.java
│ │ │ │ └── ReedSolomonEncoder.java
│ │ │ ├── DetectorResult.java
│ │ │ ├── detector
│ │ │ │ └── MathUtils.java
│ │ │ └── BitSource.java
│ │ │ ├── qrcode
│ │ │ ├── encoder
│ │ │ │ ├── BlockPair.java
│ │ │ │ ├── ByteMatrix.java
│ │ │ │ └── QRCode.java
│ │ │ ├── detector
│ │ │ │ ├── FinderPatternInfo.java
│ │ │ │ ├── AlignmentPattern.java
│ │ │ │ └── FinderPattern.java
│ │ │ └── decoder
│ │ │ │ ├── ErrorCorrectionLevel.java
│ │ │ │ ├── QRCodeDecoderMetaData.java
│ │ │ │ └── Mode.java
│ │ │ ├── WriterException.java
│ │ │ ├── oned
│ │ │ ├── UPCEANWriter.java
│ │ │ ├── rss
│ │ │ │ ├── Pair.java
│ │ │ │ ├── expanded
│ │ │ │ │ ├── decoders
│ │ │ │ │ │ ├── DecodedObject.java
│ │ │ │ │ │ ├── AI013103decoder.java
│ │ │ │ │ │ ├── DecodedChar.java
│ │ │ │ │ │ ├── AI01320xDecoder.java
│ │ │ │ │ │ ├── BlockParsedResult.java
│ │ │ │ │ │ ├── AnyAIDecoder.java
│ │ │ │ │ │ ├── AI013x0xDecoder.java
│ │ │ │ │ │ ├── AI01weightDecoder.java
│ │ │ │ │ │ ├── DecodedInformation.java
│ │ │ │ │ │ ├── CurrentParsingState.java
│ │ │ │ │ │ ├── AI01AndOtherAIs.java
│ │ │ │ │ │ ├── DecodedNumeric.java
│ │ │ │ │ │ ├── AI01392xDecoder.java
│ │ │ │ │ │ ├── AI01decoder.java
│ │ │ │ │ │ ├── AI01393xDecoder.java
│ │ │ │ │ │ ├── AI013x0x1xDecoder.java
│ │ │ │ │ │ └── AbstractExpandedDecoder.java
│ │ │ │ │ ├── ExpandedRow.java
│ │ │ │ │ ├── BitArrayBuilder.java
│ │ │ │ │ └── ExpandedPair.java
│ │ │ │ ├── DataCharacter.java
│ │ │ │ └── FinderPattern.java
│ │ │ ├── UPCEANExtensionSupport.java
│ │ │ ├── UPCAWriter.java
│ │ │ ├── EAN8Reader.java
│ │ │ ├── ITFWriter.java
│ │ │ ├── UPCAReader.java
│ │ │ ├── Code39Writer.java
│ │ │ ├── EAN8Writer.java
│ │ │ └── UPCEWriter.java
│ │ │ ├── NotFoundException.java
│ │ │ ├── multi
│ │ │ ├── MultipleBarcodeReader.java
│ │ │ └── qrcode
│ │ │ │ └── detector
│ │ │ │ └── MultiDetector.java
│ │ │ ├── ChecksumException.java
│ │ │ ├── FormatException.java
│ │ │ ├── ReaderException.java
│ │ │ ├── Dimension.java
│ │ │ ├── BarcodeFormat.java
│ │ │ ├── Writer.java
│ │ │ ├── InvertedLuminanceSource.java
│ │ │ ├── Reader.java
│ │ │ ├── ResultMetadataType.java
│ │ │ └── Binarizer.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── google
│ │ │ └── zxing
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── google
│ │ └── zxing
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── README.md
├── .idea
├── caches
│ ├── gradle_models.ser
│ └── build_file_checksums.ser
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── .gitignore
├── LICENSE
└── gradlew.bat
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/zxing/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':zxing'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ScreenCapture
2 | Android capture screen to image or record screen to video.
3 |
--------------------------------------------------------------------------------
/zxing/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | zxing
3 |
4 |
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/app/src/main/res/drawable/scan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/drawable/scan.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/drawable-hdpi/ic_capture.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/drawable-mdpi/ic_capture.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/drawable-xhdpi/ic_capture.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/drawable-xxhdpi/ic_capture.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wossoneri/ScreenCapture/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #525c5e
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon May 20 12:57:41 CST 2019
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-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/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/java/com/softard/wow/screencapture/Utils/SocketUtils.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.Utils;
2 |
3 | /**
4 | * Created by wOw on 2019-05-21.
5 | * Email: wossoneri@163.com
6 | * Copyright (c) 2019 Softard. All rights reserved.
7 | */
8 | public class SocketUtils {
9 | public final static int PORT = 4321;
10 | }
11 |
--------------------------------------------------------------------------------
/zxing/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/CodecTools/Encoder.java:
--------------------------------------------------------------------------------
1 |
2 | package com.softard.wow.screencapture.CodecTools;
3 |
4 | import java.io.IOException;
5 |
6 | interface Encoder {
7 | void prepare() throws IOException;
8 |
9 | void stop();
10 |
11 | void release();
12 |
13 | void setCallback(Callback callback);
14 |
15 | interface Callback {
16 | void onError(Encoder encoder, Exception exception);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | /**
7 | * Created by wow on 5/8/18.
8 | */
9 |
10 | public class MainApplication extends Application {
11 | public static Context sAppContext;
12 |
13 | @Override
14 | public void onCreate() {
15 | super.onCreate();
16 | sAppContext = this;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/zxing/src/test/java/com/google/zxing/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.google.zxing;
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 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_capture.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/softard/wow/screencapture/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture;
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 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/CodecTools/AudioEncoder.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.CodecTools;
2 |
3 | import android.media.MediaFormat;
4 |
5 | /**
6 | * Created by wOw on 2019-08-19.
7 | * Email: wossoneri@163.com
8 | * Copyright (c) 2019 Softard. All rights reserved.
9 | */
10 | public class AudioEncoder extends BaseEncoder {
11 | private final AudioEncodeConfig mConfig;
12 |
13 | AudioEncoder(AudioEncodeConfig config) {
14 | super(config.codecName);
15 | this.mConfig = config;
16 | }
17 |
18 | @Override
19 | protected MediaFormat createMediaFormat() {
20 | return mConfig.toFormat();
21 | }
22 |
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 截屏
4 | 扫一扫
5 | Socket 服务器
6 | Socket 客户端
7 | 需要录音权限和存储权限进行录制
8 | 没有权限!
9 | 创建ScreenRecorder失败
10 | 停止录制
11 | 重新录制
12 | 没有SD权限保存文件
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ScreenCapture
3 | Scan
4 |
5 | Socket Server
6 | Socket Client
7 |
8 | Using your mic to record audio and your sd card to save video file
9 | No Permission!
10 | Create Screen Recorder failed
11 | Stop Recorder
12 | Restart recorder
13 | No permission to write sd card
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/Utils/ScreenUtils.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.Utils;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 | import android.util.DisplayMetrics;
6 |
7 | import com.softard.wow.screencapture.MainApplication;
8 |
9 | /**
10 | * Created by wow on 5/8/18.
11 | */
12 |
13 | public class ScreenUtils {
14 |
15 | public static final String VIDEO_PATH = Environment.getExternalStoragePublicDirectory(
16 | android.os.Environment.DIRECTORY_DOWNLOADS) + "/video.mp4";
17 |
18 | public static float getScreenDensity() {
19 | Context context = MainApplication.sAppContext;
20 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
21 | return dm.density;
22 | }
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/zxing/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 |
--------------------------------------------------------------------------------
/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 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/zxing/src/androidTest/java/com/google/zxing/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.google.zxing;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.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.google.zxing.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/softard/wow/screencapture/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.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.softard.wow.screencapture", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/zxing/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 |
30 | implementation 'androidx.appcompat:appcompat:1.0.0'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'androidx.test:runner:1.1.0'
33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/View/RTSPlayerActivity.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.View;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.widget.VideoView;
6 |
7 | import com.softard.wow.screencapture.R;
8 |
9 | import butterknife.BindView;
10 | import butterknife.ButterKnife;
11 |
12 | public class RTSPlayerActivity extends AppCompatActivity {
13 |
14 | @BindView(R.id.videoView) VideoView mVideoView;
15 |
16 | private String mURL = "rtsp://118.25.39.144/sample_h264_1mbit.mp4";
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_rtsplayer);
22 | ButterKnife.bind(this);
23 |
24 | mVideoView.setVideoPath(mURL);
25 | mVideoView.requestFocus();
26 | mVideoView.start();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_socket_server.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
20 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/ResultPointCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * Callback which is invoked when a possible result point (significant
21 | * point in the barcode image such as a corner) is found.
22 | *
23 | * @see DecodeHintType#NEED_RESULT_POINT_CALLBACK
24 | */
25 | public interface ResultPointCallback {
26 |
27 | void foundPossibleResultPoint(ResultPoint point);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_rtsplayer.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_screen_record_by_codec.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 wOw
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 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/common/reedsolomon/ReedSolomonException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.common.reedsolomon;
18 |
19 | /**
20 | *
Thrown when an exception occurs during Reed-Solomon decoding, such as when
21 | * there are too many errors to correct.
22 | *
23 | * @author Sean Owen
24 | */
25 | public final class ReedSolomonException extends Exception {
26 |
27 | public ReedSolomonException(String message) {
28 | super(message);
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/QRCode/Utils.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.QRCode;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | //import com.googlecode.tesseract.android.TessBaseAPI;
6 |
7 | /**
8 | * Created by wow on 5/8/18.
9 | */
10 |
11 | public class Utils {
12 |
13 | // public static String readBitmap(Bitmap bmp) {
14 | // TessBaseAPI tessBaseAPI = new TessBaseAPI();
15 | // String path = "/sdcard/tesseract/"; //训练数据路径
16 | //
17 | // tessBaseAPI.setDebug(true);
18 | // tessBaseAPI.init(path, "eng"); //eng为识别语言
19 | // tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); // 识别白名单
20 | // tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=-[]}{;:'\"\\|~`,./<>?"); // 识别黑名单
21 | // tessBaseAPI.setPageSegMode(TessBaseAPI.PageSegMode.PSM_AUTO_OSD);//设置识别模式
22 | //
23 | // tessBaseAPI.setImage(bmp); //设置需要识别图片的bitmap
24 | // String inspection = tessBaseAPI.getHOCRText(0);
25 | // tessBaseAPI.end();
26 | // return inspection ;
27 | // }
28 | }
29 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/encoder/BlockPair.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing.qrcode.encoder;
18 |
19 | final class BlockPair {
20 |
21 | private final byte[] dataBytes;
22 | private final byte[] errorCorrectionBytes;
23 |
24 | BlockPair(byte[] data, byte[] errorCorrection) {
25 | dataBytes = data;
26 | errorCorrectionBytes = errorCorrection;
27 | }
28 |
29 | public byte[] getDataBytes() {
30 | return dataBytes;
31 | }
32 |
33 | public byte[] getErrorCorrectionBytes() {
34 | return errorCorrectionBytes;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/WriterException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * A base class which covers the range of exceptions which may occur when encoding a barcode using
21 | * the Writer framework.
22 | *
23 | * @author dswitkin@google.com (Daniel Switkin)
24 | */
25 | public final class WriterException extends Exception {
26 |
27 | public WriterException() {
28 | }
29 |
30 | public WriterException(String message) {
31 | super(message);
32 | }
33 |
34 | public WriterException(Throwable cause) {
35 | super(cause);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/UPCEANWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.oned;
18 |
19 | /**
20 | *
Encapsulates functionality and implementation that is common to UPC and EAN families
21 | * of one-dimensional barcodes.
22 | *
23 | * @author aripollak@gmail.com (Ari Pollak)
24 | * @author dsbnatut@gmail.com (Kazuki Nishiura)
25 | */
26 | public abstract class UPCEANWriter extends OneDimensionalCodeWriter {
27 |
28 | @Override
29 | public int getDefaultMargin() {
30 | // Use a different default more appropriate for UPC/EAN
31 | return 9;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/Pair.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.oned.rss;
18 |
19 | final class Pair extends DataCharacter {
20 |
21 | private final FinderPattern finderPattern;
22 | private int count;
23 |
24 | Pair(int value, int checksumPortion, FinderPattern finderPattern) {
25 | super(value, checksumPortion);
26 | this.finderPattern = finderPattern;
27 | }
28 |
29 | FinderPattern getFinderPattern() {
30 | return finderPattern;
31 | }
32 |
33 | int getCount() {
34 | return count;
35 | }
36 |
37 | void incrementCount() {
38 | count++;
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * Thrown when a barcode was not found in the image. It might have been
21 | * partially detected but could not be confirmed.
22 | *
23 | * @author Sean Owen
24 | */
25 | public final class NotFoundException extends ReaderException {
26 |
27 | private static final NotFoundException INSTANCE = new NotFoundException();
28 | static {
29 | INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
30 | }
31 |
32 | private NotFoundException() {
33 | // do nothing
34 | }
35 |
36 | public static NotFoundException getNotFoundInstance() {
37 | return INSTANCE;
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/multi/MultipleBarcodeReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.multi;
18 |
19 | import com.google.zxing.BinaryBitmap;
20 | import com.google.zxing.DecodeHintType;
21 | import com.google.zxing.NotFoundException;
22 | import com.google.zxing.Result;
23 |
24 | import java.util.Map;
25 |
26 | /**
27 | * Implementation of this interface attempt to read several barcodes from one image.
28 | *
29 | * @see com.google.zxing.Reader
30 | * @author Sean Owen
31 | */
32 | public interface MultipleBarcodeReader {
33 |
34 | Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException;
35 |
36 | Result[] decodeMultiple(BinaryBitmap image,
37 | Map hints) throws NotFoundException;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera_record.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
30 |
31 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | /**
30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
31 | */
32 | abstract class DecodedObject {
33 |
34 | private final int newPosition;
35 |
36 | DecodedObject(int newPosition) {
37 | this.newPosition = newPosition;
38 | }
39 |
40 | final int getNewPosition() {
41 | return this.newPosition;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/common/DetectorResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.common;
18 |
19 | import com.google.zxing.ResultPoint;
20 |
21 | /**
22 | *
Encapsulates the result of detecting a barcode in an image. This includes the raw
23 | * matrix of black/white pixels corresponding to the barcode, and possibly points of interest
24 | * in the image, like the location of finder patterns or corners of the barcode in the image.
25 | *
26 | * @author Sean Owen
27 | */
28 | public class DetectorResult {
29 |
30 | private final BitMatrix bits;
31 | private final ResultPoint[] points;
32 |
33 | public DetectorResult(BitMatrix bits, ResultPoint[] points) {
34 | this.bits = bits;
35 | this.points = points;
36 | }
37 |
38 | public final BitMatrix getBits() {
39 | return bits;
40 | }
41 |
42 | public final ResultPoint[] getPoints() {
43 | return points;
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/CodecTools/VideoEncoder.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.CodecTools;
2 |
3 | import android.media.MediaCodec;
4 | import android.media.MediaFormat;
5 | import android.util.Log;
6 | import android.view.Surface;
7 |
8 | import java.util.Objects;
9 |
10 | /**
11 | * Created by wOw on 2019-08-19.
12 | * Email: wossoneri@163.com
13 | * Copyright (c) 2019 Softard. All rights reserved.
14 | */
15 | public class VideoEncoder extends BaseEncoder {
16 | private static final boolean VERBOSE = false;
17 | private VideoEncodeConfig mConfig;
18 | private Surface mSurface;
19 |
20 |
21 | VideoEncoder(VideoEncodeConfig config) {
22 | super(config.codecName);
23 | this.mConfig = config;
24 | }
25 |
26 | @Override
27 | protected void onEncoderConfigured(MediaCodec encoder) {
28 | mSurface = encoder.createInputSurface();
29 | if (VERBOSE) Log.i("@@", "VideoEncoder create input surface: " + mSurface);
30 | }
31 |
32 | @Override
33 | protected MediaFormat createMediaFormat() {
34 | return mConfig.toFormat();
35 | }
36 |
37 | /**
38 | * @throws NullPointerException if prepare() not call
39 | */
40 | Surface getInputSurface() {
41 | return Objects.requireNonNull(mSurface, "doesn't prepare()");
42 | }
43 |
44 | @Override
45 | public void release() {
46 | if (mSurface != null) {
47 | mSurface.release();
48 | mSurface = null;
49 | }
50 | super.release();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_socket.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
23 |
24 |
25 |
34 |
35 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/ChecksumException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * Thrown when a barcode was successfully detected and decoded, but
21 | * was not returned because its checksum feature failed.
22 | *
23 | * @author Sean Owen
24 | */
25 | public final class ChecksumException extends ReaderException {
26 |
27 | private static final ChecksumException INSTANCE = new ChecksumException();
28 | static {
29 | INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
30 | }
31 |
32 | private ChecksumException() {
33 | // do nothing
34 | }
35 |
36 | private ChecksumException(Throwable cause) {
37 | super(cause);
38 | }
39 |
40 | public static ChecksumException getChecksumInstance() {
41 | return isStackTrace ? new ChecksumException() : INSTANCE;
42 | }
43 |
44 | public static ChecksumException getChecksumInstance(Throwable cause) {
45 | return isStackTrace ? new ChecksumException(cause) : INSTANCE;
46 | }
47 | }
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/detector/FinderPatternInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.qrcode.detector;
18 |
19 | /**
20 | *
Encapsulates information about finder patterns in an image, including the location of
21 | * the three finder patterns, and their estimated module size.
22 | *
23 | * @author Sean Owen
24 | */
25 | public final class FinderPatternInfo {
26 |
27 | private final FinderPattern bottomLeft;
28 | private final FinderPattern topLeft;
29 | private final FinderPattern topRight;
30 |
31 | public FinderPatternInfo(FinderPattern[] patternCenters) {
32 | this.bottomLeft = patternCenters[0];
33 | this.topLeft = patternCenters[1];
34 | this.topRight = patternCenters[2];
35 | }
36 |
37 | public FinderPattern getBottomLeft() {
38 | return bottomLeft;
39 | }
40 |
41 | public FinderPattern getTopLeft() {
42 | return topLeft;
43 | }
44 |
45 | public FinderPattern getTopRight() {
46 | return topRight;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.softard.wow.screencapture"
7 | minSdkVersion 21
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 |
13 | ndk {
14 | abiFilters 'armeabi'
15 | }
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | compileOptions {
24 | sourceCompatibility = '1.8'
25 | targetCompatibility = '1.8'
26 | }
27 | buildToolsVersion = '28.0.3'
28 | }
29 |
30 | dependencies {
31 | implementation project(':zxing')
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | implementation 'androidx.appcompat:appcompat:1.0.0'
34 | implementation 'androidx.core:core:1.0.0'
35 | implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
36 | implementation 'com.google.android.material:material:1.0.0'
37 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
38 | testImplementation 'junit:junit:4.12'
39 | androidTestImplementation 'androidx.test:runner:1.1.0'
40 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
41 | // compile 'com.rmtheis:tess-two:8.0.0'
42 | implementation 'com.jakewharton:butterknife:10.1.0'
43 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
44 | }
45 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/FormatException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * Thrown when a barcode was successfully detected, but some aspect of
21 | * the content did not conform to the barcode's format rules. This could have
22 | * been due to a mis-detection.
23 | *
24 | * @author Sean Owen
25 | */
26 | public final class FormatException extends ReaderException {
27 |
28 | private static final FormatException INSTANCE = new FormatException();
29 | static {
30 | INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
31 | }
32 |
33 | private FormatException() {
34 | }
35 |
36 | private FormatException(Throwable cause) {
37 | super(cause);
38 | }
39 |
40 | public static FormatException getFormatInstance() {
41 | return isStackTrace ? new FormatException() : INSTANCE;
42 | }
43 |
44 | public static FormatException getFormatInstance(Throwable cause) {
45 | return isStackTrace ? new FormatException(cause) : INSTANCE;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/UPCEANExtensionSupport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.NotFoundException;
20 | import com.google.zxing.ReaderException;
21 | import com.google.zxing.Result;
22 | import com.google.zxing.common.BitArray;
23 |
24 | final class UPCEANExtensionSupport {
25 |
26 | private static final int[] EXTENSION_START_PATTERN = {1,1,2};
27 |
28 | private final UPCEANExtension2Support twoSupport = new UPCEANExtension2Support();
29 | private final UPCEANExtension5Support fiveSupport = new UPCEANExtension5Support();
30 |
31 | Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException {
32 | int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN);
33 | try {
34 | return fiveSupport.decodeRow(rowNumber, row, extensionStartRange);
35 | } catch (ReaderException ignored) {
36 | return twoSupport.decodeRow(rowNumber, row, extensionStartRange);
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/ReaderException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * The general exception class throw when something goes wrong during decoding of a barcode.
21 | * This includes, but is not limited to, failing checksums / error correction algorithms, being
22 | * unable to locate finder timing patterns, and so on.
23 | *
24 | * @author Sean Owen
25 | */
26 | public abstract class ReaderException extends Exception {
27 |
28 | // disable stack traces when not running inside test units
29 | protected static final boolean isStackTrace =
30 | System.getProperty("surefire.test.class.path") != null;
31 | protected static final StackTraceElement[] NO_TRACE = new StackTraceElement[0];
32 |
33 | ReaderException() {
34 | // do nothing
35 | }
36 |
37 | ReaderException(Throwable cause) {
38 | super(cause);
39 | }
40 |
41 | // Prevent stack traces from being taken
42 | @Override
43 | public final synchronized Throwable fillInStackTrace() {
44 | return null;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI013103decoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.common.BitArray;
30 |
31 | /**
32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
33 | */
34 | final class AI013103decoder extends AI013x0xDecoder {
35 |
36 | AI013103decoder(BitArray information) {
37 | super(information);
38 | }
39 |
40 | @Override
41 | protected void addWeightCode(StringBuilder buf, int weight) {
42 | buf.append("(3103)");
43 | }
44 |
45 | @Override
46 | protected int checkWeight(int weight) {
47 | return weight;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/Dimension.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * Simply encapsulates a width and height.
21 | */
22 | public final class Dimension {
23 |
24 | private final int width;
25 | private final int height;
26 |
27 | public Dimension(int width, int height) {
28 | if (width < 0 || height < 0) {
29 | throw new IllegalArgumentException();
30 | }
31 | this.width = width;
32 | this.height = height;
33 | }
34 |
35 | public int getWidth() {
36 | return width;
37 | }
38 |
39 | public int getHeight() {
40 | return height;
41 | }
42 |
43 | @Override
44 | public boolean equals(Object other) {
45 | if (other instanceof Dimension) {
46 | Dimension d = (Dimension) other;
47 | return width == d.width && height == d.height;
48 | }
49 | return false;
50 | }
51 |
52 | @Override
53 | public int hashCode() {
54 | return width * 32713 + height;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | return width + "x" + height;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_record.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
18 |
19 |
30 |
31 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedChar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | /**
30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
31 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
32 | */
33 | final class DecodedChar extends DecodedObject {
34 |
35 | private final char value;
36 |
37 | static final char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset
38 |
39 | DecodedChar(int newPosition, char value) {
40 | super(newPosition);
41 | this.value = value;
42 | }
43 |
44 | char getValue() {
45 | return this.value;
46 | }
47 |
48 | boolean isFNC1() {
49 | return this.value == FNC1;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/DataCharacter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.oned.rss;
18 |
19 | /**
20 | * Encapsulates a since character value in an RSS barcode, including its checksum information.
21 | */
22 | public class DataCharacter {
23 |
24 | private final int value;
25 | private final int checksumPortion;
26 |
27 | public DataCharacter(int value, int checksumPortion) {
28 | this.value = value;
29 | this.checksumPortion = checksumPortion;
30 | }
31 |
32 | public final int getValue() {
33 | return value;
34 | }
35 |
36 | public final int getChecksumPortion() {
37 | return checksumPortion;
38 | }
39 |
40 | @Override
41 | public final String toString() {
42 | return value + "(" + checksumPortion + ')';
43 | }
44 |
45 | @Override
46 | public final boolean equals(Object o) {
47 | if (!(o instanceof DataCharacter)) {
48 | return false;
49 | }
50 | DataCharacter that = (DataCharacter) o;
51 | return value == that.value && checksumPortion == that.checksumPortion;
52 | }
53 |
54 | @Override
55 | public final int hashCode() {
56 | return value ^ checksumPortion;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/CodecTools/AudioEncodeConfig.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.CodecTools;
2 |
3 | import android.media.MediaFormat;
4 |
5 | import java.util.Objects;
6 |
7 | /**
8 | * Created by wOw on 2019-08-19.
9 | * Email: wossoneri@163.com
10 | * Copyright (c) 2019 Softard. All rights reserved.
11 | */
12 | public class AudioEncodeConfig {
13 | final String codecName;
14 | final String mimeType;
15 | final int bitRate;
16 | final int sampleRate;
17 | final int channelCount;
18 | final int profile;
19 |
20 | public AudioEncodeConfig(String codecName, String mimeType,
21 | int bitRate, int sampleRate, int channelCount, int profile) {
22 | this.codecName = codecName;
23 | this.mimeType = Objects.requireNonNull(mimeType);
24 | this.bitRate = bitRate;
25 | this.sampleRate = sampleRate;
26 | this.channelCount = channelCount;
27 | this.profile = profile;
28 | }
29 |
30 | MediaFormat toFormat() {
31 | MediaFormat format = MediaFormat.createAudioFormat(mimeType, sampleRate, channelCount);
32 | format.setInteger(MediaFormat.KEY_AAC_PROFILE, profile);
33 | format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
34 | //format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 4096 * 4);
35 | return format;
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return "AudioEncodeConfig{" +
41 | "codecName='" + codecName + '\'' +
42 | ", mimeType='" + mimeType + '\'' +
43 | ", bitRate=" + bitRate +
44 | ", sampleRate=" + sampleRate +
45 | ", channelCount=" + channelCount +
46 | ", profile=" + profile +
47 | '}';
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_scanqr.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
26 |
27 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01320xDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.common.BitArray;
30 |
31 | /**
32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
33 | */
34 | final class AI01320xDecoder extends AI013x0xDecoder {
35 |
36 | AI01320xDecoder(BitArray information) {
37 | super(information);
38 | }
39 |
40 | @Override
41 | protected void addWeightCode(StringBuilder buf, int weight) {
42 | if (weight < 10000) {
43 | buf.append("(3202)");
44 | } else {
45 | buf.append("(3203)");
46 | }
47 | }
48 |
49 | @Override
50 | protected int checkWeight(int weight) {
51 | if (weight < 10000) {
52 | return weight;
53 | }
54 | return weight - 10000;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/BarcodeFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * Enumerates barcode formats known to this package. Please keep alphabetized.
21 | *
22 | * @author Sean Owen
23 | */
24 | public enum BarcodeFormat {
25 |
26 | /** Aztec 2D barcode format. */
27 | AZTEC,
28 |
29 | /** CODABAR 1D format. */
30 | CODABAR,
31 |
32 | /** Code 39 1D format. */
33 | CODE_39,
34 |
35 | /** Code 93 1D format. */
36 | CODE_93,
37 |
38 | /** Code 128 1D format. */
39 | CODE_128,
40 |
41 | /** Data Matrix 2D barcode format. */
42 | DATA_MATRIX,
43 |
44 | /** EAN-8 1D format. */
45 | EAN_8,
46 |
47 | /** EAN-13 1D format. */
48 | EAN_13,
49 |
50 | /** ITF (Interleaved Two of Five) 1D format. */
51 | ITF,
52 |
53 | /** MaxiCode 2D barcode format. */
54 | MAXICODE,
55 |
56 | /** PDF417 format. */
57 | PDF_417,
58 |
59 | /** QR Code 2D barcode format. */
60 | QR_CODE,
61 |
62 | /** RSS 14 */
63 | RSS_14,
64 |
65 | /** RSS EXPANDED */
66 | RSS_EXPANDED,
67 |
68 | /** UPC-A 1D format. */
69 | UPC_A,
70 |
71 | /** UPC-E 1D format. */
72 | UPC_E,
73 |
74 | /** UPC/EAN extension format. Not a stand-alone format. */
75 | UPC_EAN_EXTENSION
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.qrcode.decoder;
18 |
19 | /**
20 | *
See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels
21 | * defined by the QR code standard.
22 | *
23 | * @author Sean Owen
24 | */
25 | public enum ErrorCorrectionLevel {
26 |
27 | /** L = ~7% correction */
28 | L(0x01),
29 | /** M = ~15% correction */
30 | M(0x00),
31 | /** Q = ~25% correction */
32 | Q(0x03),
33 | /** H = ~30% correction */
34 | H(0x02);
35 |
36 | private static final ErrorCorrectionLevel[] FOR_BITS = {M, L, H, Q};
37 |
38 | private final int bits;
39 |
40 | ErrorCorrectionLevel(int bits) {
41 | this.bits = bits;
42 | }
43 |
44 | public int getBits() {
45 | return bits;
46 | }
47 |
48 | /**
49 | * @param bits int containing the two bits encoding a QR Code's error correction level
50 | * @return ErrorCorrectionLevel representing the encoded error correction level
51 | */
52 | public static ErrorCorrectionLevel forBits(int bits) {
53 | if (bits < 0 || bits >= FOR_BITS.length) {
54 | throw new IllegalArgumentException();
55 | }
56 | return FOR_BITS[bits];
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/decoder/QRCodeDecoderMetaData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 ZXing authors
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 com.google.zxing.qrcode.decoder;
18 |
19 | import com.google.zxing.ResultPoint;
20 |
21 | /**
22 | * Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the
23 | * decoding caller. Callers are expected to process this.
24 | *
25 | * @see com.google.zxing.common.DecoderResult#getOther()
26 | */
27 | public final class QRCodeDecoderMetaData {
28 |
29 | private final boolean mirrored;
30 |
31 | QRCodeDecoderMetaData(boolean mirrored) {
32 | this.mirrored = mirrored;
33 | }
34 |
35 | /**
36 | * @return true if the QR Code was mirrored.
37 | */
38 | public boolean isMirrored() {
39 | return mirrored;
40 | }
41 |
42 | /**
43 | * Apply the result points' order correction due to mirroring.
44 | *
45 | * @param points Array of points to apply mirror correction to.
46 | */
47 | public void applyMirroredCorrection(ResultPoint[] points) {
48 | if (!mirrored || points == null || points.length < 3) {
49 | return;
50 | }
51 | ResultPoint bottomLeft = points[0];
52 | points[0] = points[2];
53 | points[2] = bottomLeft;
54 | // No need to 'fix' top-left and alignment pattern.
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/BlockParsedResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | /**
30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
31 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
32 | */
33 | final class BlockParsedResult {
34 |
35 | private final DecodedInformation decodedInformation;
36 | private final boolean finished;
37 |
38 | BlockParsedResult(boolean finished) {
39 | this(null, finished);
40 | }
41 |
42 | BlockParsedResult(DecodedInformation information, boolean finished) {
43 | this.finished = finished;
44 | this.decodedInformation = information;
45 | }
46 |
47 | DecodedInformation getDecodedInformation() {
48 | return this.decodedInformation;
49 | }
50 |
51 | boolean isFinished() {
52 | return this.finished;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AnyAIDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.FormatException;
30 | import com.google.zxing.NotFoundException;
31 | import com.google.zxing.common.BitArray;
32 |
33 | /**
34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
35 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
36 | */
37 | final class AnyAIDecoder extends AbstractExpandedDecoder {
38 |
39 | private static final int HEADER_SIZE = 2 + 1 + 2;
40 |
41 | AnyAIDecoder(BitArray information) {
42 | super(information);
43 | }
44 |
45 | @Override
46 | public String parseInformation() throws NotFoundException, FormatException {
47 | StringBuilder buf = new StringBuilder();
48 | return this.getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/FinderPattern.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.oned.rss;
18 |
19 | import com.google.zxing.ResultPoint;
20 |
21 | /**
22 | * Encapsulates an RSS barcode finder pattern, including its start/end position and row.
23 | */
24 | public final class FinderPattern {
25 |
26 | private final int value;
27 | private final int[] startEnd;
28 | private final ResultPoint[] resultPoints;
29 |
30 | public FinderPattern(int value, int[] startEnd, int start, int end, int rowNumber) {
31 | this.value = value;
32 | this.startEnd = startEnd;
33 | this.resultPoints = new ResultPoint[] {
34 | new ResultPoint(start, rowNumber),
35 | new ResultPoint(end, rowNumber),
36 | };
37 | }
38 |
39 | public int getValue() {
40 | return value;
41 | }
42 |
43 | public int[] getStartEnd() {
44 | return startEnd;
45 | }
46 |
47 | public ResultPoint[] getResultPoints() {
48 | return resultPoints;
49 | }
50 |
51 | @Override
52 | public boolean equals(Object o) {
53 | if (!(o instanceof FinderPattern)) {
54 | return false;
55 | }
56 | FinderPattern that = (FinderPattern) o;
57 | return value == that.value;
58 | }
59 |
60 | @Override
61 | public int hashCode() {
62 | return value;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/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/java/com/softard/wow/screencapture/View/SocketActivity.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.View;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.widget.CompoundButton;
6 | import android.widget.Switch;
7 |
8 | import com.softard.wow.screencapture.R;
9 |
10 | import butterknife.BindView;
11 | import butterknife.ButterKnife;
12 |
13 | public class SocketActivity extends AppCompatActivity {
14 |
15 | @BindView(R.id.CS_switch) Switch CSSwitch;
16 | SocketClientFragment socketClientFragment;
17 | SocketServerFragment socketServerFragment;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_socket);
23 | ButterKnife.bind(this);
24 |
25 | socketClientFragment = new SocketClientFragment();
26 | socketServerFragment = new SocketServerFragment();
27 |
28 | CSSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
29 | @Override
30 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
31 | if (isChecked) {
32 | setServer();
33 | } else {
34 | setClient();
35 | }
36 | }
37 | });
38 |
39 | }
40 |
41 | @Override
42 | protected void onResume() {
43 | super.onResume();
44 | setClient();
45 | }
46 |
47 | private void setClient() {
48 | CSSwitch.setText(R.string.socket_client);
49 | getSupportFragmentManager().beginTransaction().replace(
50 | R.id.socket_fragment_container,
51 | socketClientFragment).commit();
52 | }
53 |
54 | private void setServer() {
55 | CSSwitch.setText(R.string.socket_server);
56 | getSupportFragmentManager().beginTransaction().replace(
57 | R.id.socket_fragment_container,
58 | socketServerFragment).commit();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/UPCAWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.BarcodeFormat;
20 | import com.google.zxing.EncodeHintType;
21 | import com.google.zxing.Writer;
22 | import com.google.zxing.WriterException;
23 | import com.google.zxing.common.BitMatrix;
24 |
25 | import java.util.Map;
26 |
27 | /**
28 | * This object renders a UPC-A code as a {@link BitMatrix}.
29 | *
30 | * @author qwandor@google.com (Andrew Walbran)
31 | */
32 | public final class UPCAWriter implements Writer {
33 |
34 | private final EAN13Writer subWriter = new EAN13Writer();
35 |
36 | @Override
37 | public BitMatrix encode(String contents, BarcodeFormat format, int width, int height)
38 | throws WriterException {
39 | return encode(contents, format, width, height, null);
40 | }
41 |
42 | @Override
43 | public BitMatrix encode(String contents,
44 | BarcodeFormat format,
45 | int width,
46 | int height,
47 | Map hints) throws WriterException {
48 | if (format != BarcodeFormat.UPC_A) {
49 | throw new IllegalArgumentException("Can only encode UPC-A, but got " + format);
50 | }
51 | // Transform a UPC-A code into the equivalent EAN-13 code and write it that way
52 | return subWriter.encode('0' + contents, BarcodeFormat.EAN_13, width, height, hints);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.NotFoundException;
30 | import com.google.zxing.common.BitArray;
31 |
32 | /**
33 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
34 | */
35 | abstract class AI013x0xDecoder extends AI01weightDecoder {
36 |
37 | private static final int HEADER_SIZE = 4 + 1;
38 | private static final int WEIGHT_SIZE = 15;
39 |
40 | AI013x0xDecoder(BitArray information) {
41 | super(information);
42 | }
43 |
44 | @Override
45 | public String parseInformation() throws NotFoundException {
46 | if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) {
47 | throw NotFoundException.getNotFoundInstance();
48 | }
49 |
50 | StringBuilder buf = new StringBuilder();
51 |
52 | encodeCompressedGtin(buf, HEADER_SIZE);
53 | encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE);
54 |
55 | return buf.toString();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dlg_scan_result.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
34 |
35 |
48 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01weightDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.common.BitArray;
30 |
31 | /**
32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
33 | */
34 | abstract class AI01weightDecoder extends AI01decoder {
35 |
36 | AI01weightDecoder(BitArray information) {
37 | super(information);
38 | }
39 |
40 | final void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) {
41 | int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize);
42 | addWeightCode(buf, originalWeightNumeric);
43 |
44 | int weightNumeric = checkWeight(originalWeightNumeric);
45 |
46 | int currentDivisor = 100000;
47 | for (int i = 0; i < 5; ++i) {
48 | if (weightNumeric / currentDivisor == 0) {
49 | buf.append('0');
50 | }
51 | currentDivisor /= 10;
52 | }
53 | buf.append(weightNumeric);
54 | }
55 |
56 | protected abstract void addWeightCode(StringBuilder buf, int weight);
57 |
58 | protected abstract int checkWeight(int weight);
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedInformation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | /**
30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
31 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
32 | */
33 | final class DecodedInformation extends DecodedObject {
34 |
35 | private final String newString;
36 | private final int remainingValue;
37 | private final boolean remaining;
38 |
39 | DecodedInformation(int newPosition, String newString) {
40 | super(newPosition);
41 | this.newString = newString;
42 | this.remaining = false;
43 | this.remainingValue = 0;
44 | }
45 |
46 | DecodedInformation(int newPosition, String newString, int remainingValue) {
47 | super(newPosition);
48 | this.remaining = true;
49 | this.remainingValue = remainingValue;
50 | this.newString = newString;
51 | }
52 |
53 | String getNewString() {
54 | return this.newString;
55 | }
56 |
57 | boolean isRemaining() {
58 | return this.remaining;
59 | }
60 |
61 | int getRemainingValue() {
62 | return this.remainingValue;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/Writer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing;
18 |
19 | import com.google.zxing.common.BitMatrix;
20 |
21 | import java.util.Map;
22 |
23 | /**
24 | * The base class for all objects which encode/generate a barcode image.
25 | *
26 | * @author dswitkin@google.com (Daniel Switkin)
27 | */
28 | public interface Writer {
29 |
30 | /**
31 | * Encode a barcode using the default settings.
32 | *
33 | * @param contents The contents to encode in the barcode
34 | * @param format The barcode format to generate
35 | * @param width The preferred width in pixels
36 | * @param height The preferred height in pixels
37 | * @return {@link BitMatrix} representing encoded barcode image
38 | * @throws WriterException if contents cannot be encoded legally in a format
39 | */
40 | BitMatrix encode(String contents, BarcodeFormat format, int width, int height)
41 | throws WriterException;
42 |
43 | /**
44 | * @param contents The contents to encode in the barcode
45 | * @param format The barcode format to generate
46 | * @param width The preferred width in pixels
47 | * @param height The preferred height in pixels
48 | * @param hints Additional parameters to supply to the encoder
49 | * @return {@link BitMatrix} representing encoded barcode image
50 | * @throws WriterException if contents cannot be encoded legally in a format
51 | */
52 | BitMatrix encode(String contents,
53 | BarcodeFormat format,
54 | int width,
55 | int height,
56 | Map hints)
57 | throws WriterException;
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
23 |
24 |
25 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
44 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/CurrentParsingState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | /**
30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
31 | */
32 | final class CurrentParsingState {
33 |
34 | private int position;
35 | private State encoding;
36 |
37 | private enum State {
38 | NUMERIC,
39 | ALPHA,
40 | ISO_IEC_646
41 | }
42 |
43 | CurrentParsingState() {
44 | this.position = 0;
45 | this.encoding = State.NUMERIC;
46 | }
47 |
48 | int getPosition() {
49 | return position;
50 | }
51 |
52 | void setPosition(int position) {
53 | this.position = position;
54 | }
55 |
56 | void incrementPosition(int delta) {
57 | position += delta;
58 | }
59 |
60 | boolean isAlpha() {
61 | return this.encoding == State.ALPHA;
62 | }
63 |
64 | boolean isNumeric() {
65 | return this.encoding == State.NUMERIC;
66 | }
67 |
68 | boolean isIsoIec646() {
69 | return this.encoding == State.ISO_IEC_646;
70 | }
71 |
72 | void setNumeric() {
73 | this.encoding = State.NUMERIC;
74 | }
75 |
76 | void setAlpha() {
77 | this.encoding = State.ALPHA;
78 | }
79 |
80 | void setIsoIec646() {
81 | this.encoding = State.ISO_IEC_646;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/ExpandedRow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 com.google.zxing.oned.rss.expanded;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | /**
23 | * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs.
24 | */
25 | final class ExpandedRow {
26 |
27 | private final List pairs;
28 | private final int rowNumber;
29 | /** Did this row of the image have to be reversed (mirrored) to recognize the pairs? */
30 | private final boolean wasReversed;
31 |
32 | ExpandedRow(List pairs, int rowNumber, boolean wasReversed) {
33 | this.pairs = new ArrayList<>(pairs);
34 | this.rowNumber = rowNumber;
35 | this.wasReversed = wasReversed;
36 | }
37 |
38 | List getPairs() {
39 | return this.pairs;
40 | }
41 |
42 | int getRowNumber() {
43 | return this.rowNumber;
44 | }
45 |
46 | boolean isReversed() {
47 | return this.wasReversed;
48 | }
49 |
50 | boolean isEquivalent(List otherPairs) {
51 | return this.pairs.equals(otherPairs);
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | return "{ " + pairs + " }";
57 | }
58 |
59 | /**
60 | * Two rows are equal if they contain the same pairs in the same order.
61 | */
62 | @Override
63 | public boolean equals(Object o) {
64 | if (!(o instanceof ExpandedRow)) {
65 | return false;
66 | }
67 | ExpandedRow that = (ExpandedRow) o;
68 | return this.pairs.equals(that.getPairs()) && wasReversed == that.wasReversed;
69 | }
70 |
71 | @Override
72 | public int hashCode() {
73 | return pairs.hashCode() ^ Boolean.valueOf(wasReversed).hashCode();
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.FormatException;
30 | import com.google.zxing.NotFoundException;
31 | import com.google.zxing.common.BitArray;
32 |
33 | /**
34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
35 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
36 | */
37 | final class AI01AndOtherAIs extends AI01decoder {
38 |
39 | private static final int HEADER_SIZE = 1 + 1 + 2; //first bit encodes the linkage flag,
40 | //the second one is the encodation method, and the other two are for the variable length
41 | AI01AndOtherAIs(BitArray information) {
42 | super(information);
43 | }
44 |
45 | @Override
46 | public String parseInformation() throws NotFoundException, FormatException {
47 | StringBuilder buff = new StringBuilder();
48 |
49 | buff.append("(01)");
50 | int initialGtinPosition = buff.length();
51 | int firstGtinDigit = this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE, 4);
52 | buff.append(firstGtinDigit);
53 |
54 | this.encodeCompressedGtinWithoutAI(buff, HEADER_SIZE + 4, initialGtinPosition);
55 |
56 | return this.getGeneralDecoder().decodeAllCodes(buff, HEADER_SIZE + 44);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/detector/AlignmentPattern.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.qrcode.detector;
18 |
19 | import com.google.zxing.ResultPoint;
20 |
21 | /**
22 | *
Encapsulates an alignment pattern, which are the smaller square patterns found in
23 | * all but the simplest QR Codes.
Determines if this alignment pattern "about equals" an alignment pattern at the stated
38 | * position and size -- meaning, it is at nearly the same center with nearly the same size.
39 | */
40 | boolean aboutEquals(float moduleSize, float i, float j) {
41 | if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) {
42 | float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
43 | return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize;
44 | }
45 | return false;
46 | }
47 |
48 | /**
49 | * Combines this object's current estimate of a finder pattern position and module size
50 | * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two.
51 | */
52 | AlignmentPattern combineEstimate(float i, float j, float newModuleSize) {
53 | float combinedX = (getX() + j) / 2.0f;
54 | float combinedY = (getY() + i) / 2.0f;
55 | float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0f;
56 | return new AlignmentPattern(combinedX, combinedY, combinedModuleSize);
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/EAN8Reader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.BarcodeFormat;
20 | import com.google.zxing.NotFoundException;
21 | import com.google.zxing.common.BitArray;
22 |
23 | /**
24 | *
Implements decoding of the EAN-8 format.
25 | *
26 | * @author Sean Owen
27 | */
28 | public final class EAN8Reader extends UPCEANReader {
29 |
30 | private final int[] decodeMiddleCounters;
31 |
32 | public EAN8Reader() {
33 | decodeMiddleCounters = new int[4];
34 | }
35 |
36 | @Override
37 | protected int decodeMiddle(BitArray row,
38 | int[] startRange,
39 | StringBuilder result) throws NotFoundException {
40 | int[] counters = decodeMiddleCounters;
41 | counters[0] = 0;
42 | counters[1] = 0;
43 | counters[2] = 0;
44 | counters[3] = 0;
45 | int end = row.getSize();
46 | int rowOffset = startRange[1];
47 |
48 | for (int x = 0; x < 4 && rowOffset < end; x++) {
49 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
50 | result.append((char) ('0' + bestMatch));
51 | for (int counter : counters) {
52 | rowOffset += counter;
53 | }
54 | }
55 |
56 | int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN);
57 | rowOffset = middleRange[1];
58 |
59 | for (int x = 0; x < 4 && rowOffset < end; x++) {
60 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
61 | result.append((char) ('0' + bestMatch));
62 | for (int counter : counters) {
63 | rowOffset += counter;
64 | }
65 | }
66 |
67 | return rowOffset;
68 | }
69 |
70 | @Override
71 | BarcodeFormat getBarcodeFormat() {
72 | return BarcodeFormat.EAN_8;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedNumeric.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.FormatException;
30 |
31 | /**
32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
33 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
34 | */
35 | final class DecodedNumeric extends DecodedObject {
36 |
37 | private final int firstDigit;
38 | private final int secondDigit;
39 |
40 | static final int FNC1 = 10;
41 |
42 | DecodedNumeric(int newPosition, int firstDigit, int secondDigit) throws FormatException {
43 | super(newPosition);
44 |
45 | if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) {
46 | throw FormatException.getFormatInstance();
47 | }
48 |
49 | this.firstDigit = firstDigit;
50 | this.secondDigit = secondDigit;
51 | }
52 |
53 | int getFirstDigit() {
54 | return this.firstDigit;
55 | }
56 |
57 | int getSecondDigit() {
58 | return this.secondDigit;
59 | }
60 |
61 | int getValue() {
62 | return this.firstDigit * 10 + this.secondDigit;
63 | }
64 |
65 | boolean isFirstDigitFNC1() {
66 | return this.firstDigit == FNC1;
67 | }
68 |
69 | boolean isSecondDigitFNC1() {
70 | return this.secondDigit == FNC1;
71 | }
72 |
73 | boolean isAnyFNC1() {
74 | return this.firstDigit == FNC1 || this.secondDigit == FNC1;
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/QRCode/ResultDialog.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.QRCode;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.softard.wow.screencapture.R;
14 |
15 | import butterknife.BindView;
16 | import butterknife.ButterKnife;
17 |
18 | /**
19 | * Created by wow on 5/8/18.
20 | */
21 |
22 | public class ResultDialog extends Dialog {
23 |
24 | public ResultDialog(@NonNull Context context) {
25 | super(context);
26 |
27 | }
28 |
29 | public ResultDialog(@NonNull Context context, int themeResId) {
30 | super(context, themeResId);
31 | }
32 |
33 | protected ResultDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
34 | super(context, cancelable, cancelListener);
35 | }
36 |
37 | public static class Builder {
38 |
39 | private Context context;
40 | private Bitmap bitmap;
41 | private String result;
42 |
43 | @BindView(R.id.dlg_result_imageView) ImageView iv;
44 | @BindView(R.id.dlg_result_content) TextView tv;
45 |
46 | public Builder(Context context) {
47 | this.context = context;
48 | }
49 |
50 | public Builder setBitmap(Bitmap bmp) {
51 | this.bitmap = bmp;
52 | return this;
53 | }
54 |
55 | public Builder setResult(String str) {
56 | this.result = str;
57 | return this;
58 | }
59 |
60 | public ResultDialog create() {
61 | LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
62 | View layout = inflater.inflate(R.layout.dlg_scan_result, null);
63 | ButterKnife.bind(layout);
64 |
65 | iv.setImageBitmap(this.bitmap);
66 | tv.setText(this.result);
67 |
68 | final ResultDialog dialog = new ResultDialog(context);
69 | // dialog.addContentView(layout, new ViewGroup.LayoutParams(
70 | // ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
71 | dialog.setContentView(layout);
72 | return dialog;
73 |
74 |
75 | }
76 | }
77 |
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01392xDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.FormatException;
30 | import com.google.zxing.NotFoundException;
31 | import com.google.zxing.common.BitArray;
32 |
33 | /**
34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
35 | */
36 | final class AI01392xDecoder extends AI01decoder {
37 |
38 | private static final int HEADER_SIZE = 5 + 1 + 2;
39 | private static final int LAST_DIGIT_SIZE = 2;
40 |
41 | AI01392xDecoder(BitArray information) {
42 | super(information);
43 | }
44 |
45 | @Override
46 | public String parseInformation() throws NotFoundException, FormatException {
47 | if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
48 | throw NotFoundException.getNotFoundInstance();
49 | }
50 |
51 | StringBuilder buf = new StringBuilder();
52 |
53 | encodeCompressedGtin(buf, HEADER_SIZE);
54 |
55 | int lastAIdigit =
56 | this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);
57 | buf.append("(392");
58 | buf.append(lastAIdigit);
59 | buf.append(')');
60 |
61 | DecodedInformation decodedInformation =
62 | this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null);
63 | buf.append(decodedInformation.getNewString());
64 |
65 | return buf.toString();
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/common/detector/MathUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 ZXing authors
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 com.google.zxing.common.detector;
18 |
19 | /**
20 | * General math-related and numeric utility functions.
21 | */
22 | public final class MathUtils {
23 |
24 | private MathUtils() {
25 | }
26 |
27 | /**
28 | * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its
29 | * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut
30 | * differ slightly from {@link Math#round(float)} in that half rounds down for negative
31 | * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference.
32 | *
33 | * @param d real value to round
34 | * @return nearest {@code int}
35 | */
36 | public static int round(float d) {
37 | return (int) (d + (d < 0.0f ? -0.5f : 0.5f));
38 | }
39 |
40 | /**
41 | * @param aX point A x coordinate
42 | * @param aY point A y coordinate
43 | * @param bX point B x coordinate
44 | * @param bY point B y coordinate
45 | * @return Euclidean distance between points A and B
46 | */
47 | public static float distance(float aX, float aY, float bX, float bY) {
48 | float xDiff = aX - bX;
49 | float yDiff = aY - bY;
50 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff);
51 | }
52 |
53 | /**
54 | * @param aX point A x coordinate
55 | * @param aY point A y coordinate
56 | * @param bX point B x coordinate
57 | * @param bY point B y coordinate
58 | * @return Euclidean distance between points A and B
59 | */
60 | public static float distance(int aX, int aY, int bX, int bY) {
61 | int xDiff = aX - bX;
62 | int yDiff = aY - bY;
63 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff);
64 | }
65 |
66 | /**
67 | * @param array values to sum
68 | * @return sum of values in array
69 | */
70 | public static int sum(int[] array) {
71 | int count = 0;
72 | for (int a : array) {
73 | count += a;
74 | }
75 | return count;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/multi/qrcode/detector/MultiDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.multi.qrcode.detector;
18 |
19 | import com.google.zxing.DecodeHintType;
20 | import com.google.zxing.NotFoundException;
21 | import com.google.zxing.ReaderException;
22 | import com.google.zxing.ResultPointCallback;
23 | import com.google.zxing.common.BitMatrix;
24 | import com.google.zxing.common.DetectorResult;
25 | import com.google.zxing.qrcode.detector.Detector;
26 | import com.google.zxing.qrcode.detector.FinderPatternInfo;
27 |
28 | import java.util.ArrayList;
29 | import java.util.List;
30 | import java.util.Map;
31 |
32 | /**
33 | *
Encapsulates logic that can detect one or more QR Codes in an image, even if the QR Code
34 | * is rotated or skewed, or partially obscured.
35 | *
36 | * @author Sean Owen
37 | * @author Hannes Erven
38 | */
39 | public final class MultiDetector extends Detector {
40 |
41 | private static final DetectorResult[] EMPTY_DETECTOR_RESULTS = new DetectorResult[0];
42 |
43 | public MultiDetector(BitMatrix image) {
44 | super(image);
45 | }
46 |
47 | public DetectorResult[] detectMulti(Map hints) throws NotFoundException {
48 | BitMatrix image = getImage();
49 | ResultPointCallback resultPointCallback =
50 | hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
51 | MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
52 | FinderPatternInfo[] infos = finder.findMulti(hints);
53 |
54 | if (infos.length == 0) {
55 | throw NotFoundException.getNotFoundInstance();
56 | }
57 |
58 | List result = new ArrayList<>();
59 | for (FinderPatternInfo info : infos) {
60 | try {
61 | result.add(processFinderPatternInfo(info));
62 | } catch (ReaderException e) {
63 | // ignore
64 | }
65 | }
66 | if (result.isEmpty()) {
67 | return EMPTY_DETECTOR_RESULTS;
68 | } else {
69 | return result.toArray(new DetectorResult[result.size()]);
70 | }
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded;
28 |
29 | import com.google.zxing.common.BitArray;
30 |
31 | import java.util.List;
32 |
33 | /**
34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
35 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
36 | */
37 | final class BitArrayBuilder {
38 |
39 | private BitArrayBuilder() {
40 | }
41 |
42 | static BitArray buildBitArray(List pairs) {
43 | int charNumber = (pairs.size() * 2) - 1;
44 | if (pairs.get(pairs.size() - 1).getRightChar() == null) {
45 | charNumber -= 1;
46 | }
47 |
48 | int size = 12 * charNumber;
49 |
50 | BitArray binary = new BitArray(size);
51 | int accPos = 0;
52 |
53 | ExpandedPair firstPair = pairs.get(0);
54 | int firstValue = firstPair.getRightChar().getValue();
55 | for (int i = 11; i >= 0; --i) {
56 | if ((firstValue & (1 << i)) != 0) {
57 | binary.set(accPos);
58 | }
59 | accPos++;
60 | }
61 |
62 | for (int i = 1; i < pairs.size(); ++i) {
63 | ExpandedPair currentPair = pairs.get(i);
64 |
65 | int leftValue = currentPair.getLeftChar().getValue();
66 | for (int j = 11; j >= 0; --j) {
67 | if ((leftValue & (1 << j)) != 0) {
68 | binary.set(accPos);
69 | }
70 | accPos++;
71 | }
72 |
73 | if (currentPair.getRightChar() != null) {
74 | int rightValue = currentPair.getRightChar().getValue();
75 | for (int j = 11; j >= 0; --j) {
76 | if ((rightValue & (1 << j)) != 0) {
77 | binary.set(accPos);
78 | }
79 | accPos++;
80 | }
81 | }
82 | }
83 | return binary;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01decoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.common.BitArray;
30 |
31 | /**
32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
33 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
34 | */
35 | abstract class AI01decoder extends AbstractExpandedDecoder {
36 |
37 | static final int GTIN_SIZE = 40;
38 |
39 | AI01decoder(BitArray information) {
40 | super(information);
41 | }
42 |
43 | final void encodeCompressedGtin(StringBuilder buf, int currentPos) {
44 | buf.append("(01)");
45 | int initialPosition = buf.length();
46 | buf.append('9');
47 |
48 | encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition);
49 | }
50 |
51 | final void encodeCompressedGtinWithoutAI(StringBuilder buf, int currentPos, int initialBufferPosition) {
52 | for (int i = 0; i < 4; ++i) {
53 | int currentBlock = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10);
54 | if (currentBlock / 100 == 0) {
55 | buf.append('0');
56 | }
57 | if (currentBlock / 10 == 0) {
58 | buf.append('0');
59 | }
60 | buf.append(currentBlock);
61 | }
62 |
63 | appendCheckDigit(buf, initialBufferPosition);
64 | }
65 |
66 | private static void appendCheckDigit(StringBuilder buf, int currentPos) {
67 | int checkDigit = 0;
68 | for (int i = 0; i < 13; i++) {
69 | int digit = buf.charAt(i + currentPos) - '0';
70 | checkDigit += (i & 0x01) == 0 ? 3 * digit : digit;
71 | }
72 |
73 | checkDigit = 10 - (checkDigit % 10);
74 | if (checkDigit == 10) {
75 | checkDigit = 0;
76 | }
77 |
78 | buf.append(checkDigit);
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/InvertedLuminanceSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes
21 | * white and vice versa, and each value becomes (255-value).
22 | *
23 | * @author Sean Owen
24 | */
25 | public final class InvertedLuminanceSource extends LuminanceSource {
26 |
27 | private final LuminanceSource delegate;
28 |
29 | public InvertedLuminanceSource(LuminanceSource delegate) {
30 | super(delegate.getWidth(), delegate.getHeight());
31 | this.delegate = delegate;
32 | }
33 |
34 | @Override
35 | public byte[] getRow(int y, byte[] row) {
36 | row = delegate.getRow(y, row);
37 | int width = getWidth();
38 | for (int i = 0; i < width; i++) {
39 | row[i] = (byte) (255 - (row[i] & 0xFF));
40 | }
41 | return row;
42 | }
43 |
44 | @Override
45 | public byte[] getMatrix() {
46 | byte[] matrix = delegate.getMatrix();
47 | int length = getWidth() * getHeight();
48 | byte[] invertedMatrix = new byte[length];
49 | for (int i = 0; i < length; i++) {
50 | invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF));
51 | }
52 | return invertedMatrix;
53 | }
54 |
55 | @Override
56 | public boolean isCropSupported() {
57 | return delegate.isCropSupported();
58 | }
59 |
60 | @Override
61 | public LuminanceSource crop(int left, int top, int width, int height) {
62 | return new InvertedLuminanceSource(delegate.crop(left, top, width, height));
63 | }
64 |
65 | @Override
66 | public boolean isRotateSupported() {
67 | return delegate.isRotateSupported();
68 | }
69 |
70 | /**
71 | * @return original delegate {@link LuminanceSource} since invert undoes itself
72 | */
73 | @Override
74 | public LuminanceSource invert() {
75 | return delegate;
76 | }
77 |
78 | @Override
79 | public LuminanceSource rotateCounterClockwise() {
80 | return new InvertedLuminanceSource(delegate.rotateCounterClockwise());
81 | }
82 |
83 | @Override
84 | public LuminanceSource rotateCounterClockwise45() {
85 | return new InvertedLuminanceSource(delegate.rotateCounterClockwise45());
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/ITFWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.BarcodeFormat;
20 | import com.google.zxing.EncodeHintType;
21 | import com.google.zxing.WriterException;
22 | import com.google.zxing.common.BitMatrix;
23 |
24 | import java.util.Map;
25 |
26 | /**
27 | * This object renders a ITF code as a {@link BitMatrix}.
28 | *
29 | * @author erik.barbara@gmail.com (Erik Barbara)
30 | */
31 | public final class ITFWriter extends OneDimensionalCodeWriter {
32 |
33 | private static final int[] START_PATTERN = {1, 1, 1, 1};
34 | private static final int[] END_PATTERN = {3, 1, 1};
35 |
36 | @Override
37 | public BitMatrix encode(String contents,
38 | BarcodeFormat format,
39 | int width,
40 | int height,
41 | Map hints) throws WriterException {
42 | if (format != BarcodeFormat.ITF) {
43 | throw new IllegalArgumentException("Can only encode ITF, but got " + format);
44 | }
45 |
46 | return super.encode(contents, format, width, height, hints);
47 | }
48 |
49 | @Override
50 | public boolean[] encode(String contents) {
51 | int length = contents.length();
52 | if (length % 2 != 0) {
53 | throw new IllegalArgumentException("The length of the input should be even");
54 | }
55 | if (length > 80) {
56 | throw new IllegalArgumentException(
57 | "Requested contents should be less than 80 digits long, but got " + length);
58 | }
59 | boolean[] result = new boolean[9 + 9 * length];
60 | int pos = appendPattern(result, 0, START_PATTERN, true);
61 | for (int i = 0; i < length; i += 2) {
62 | int one = Character.digit(contents.charAt(i), 10);
63 | int two = Character.digit(contents.charAt(i + 1), 10);
64 | int[] encoding = new int[10];
65 | for (int j = 0; j < 5; j++) {
66 | encoding[2 * j] = ITFReader.PATTERNS[one][j];
67 | encoding[2 * j + 1] = ITFReader.PATTERNS[two][j];
68 | }
69 | pos += appendPattern(result, pos, encoding, true);
70 | }
71 | appendPattern(result, pos, END_PATTERN, true);
72 |
73 | return result;
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/encoder/ByteMatrix.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing.qrcode.encoder;
18 |
19 | import java.util.Arrays;
20 |
21 | /**
22 | * JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned
23 | * -1, 0, and 1, I'm going to use less memory and go with bytes.
24 | *
25 | * @author dswitkin@google.com (Daniel Switkin)
26 | */
27 | public final class ByteMatrix {
28 |
29 | private final byte[][] bytes;
30 | private final int width;
31 | private final int height;
32 |
33 | public ByteMatrix(int width, int height) {
34 | bytes = new byte[height][width];
35 | this.width = width;
36 | this.height = height;
37 | }
38 |
39 | public int getHeight() {
40 | return height;
41 | }
42 |
43 | public int getWidth() {
44 | return width;
45 | }
46 |
47 | public byte get(int x, int y) {
48 | return bytes[y][x];
49 | }
50 |
51 | /**
52 | * @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y)
53 | */
54 | public byte[][] getArray() {
55 | return bytes;
56 | }
57 |
58 | public void set(int x, int y, byte value) {
59 | bytes[y][x] = value;
60 | }
61 |
62 | public void set(int x, int y, int value) {
63 | bytes[y][x] = (byte) value;
64 | }
65 |
66 | public void set(int x, int y, boolean value) {
67 | bytes[y][x] = (byte) (value ? 1 : 0);
68 | }
69 |
70 | public void clear(byte value) {
71 | for (byte[] aByte : bytes) {
72 | Arrays.fill(aByte, value);
73 | }
74 | }
75 |
76 | @Override
77 | public String toString() {
78 | StringBuilder result = new StringBuilder(2 * width * height + 2);
79 | for (int y = 0; y < height; ++y) {
80 | byte[] bytesY = bytes[y];
81 | for (int x = 0; x < width; ++x) {
82 | switch (bytesY[x]) {
83 | case 0:
84 | result.append(" 0");
85 | break;
86 | case 1:
87 | result.append(" 1");
88 | break;
89 | default:
90 | result.append(" ");
91 | break;
92 | }
93 | }
94 | result.append('\n');
95 | }
96 | return result.toString();
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01393xDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 | package com.google.zxing.oned.rss.expanded.decoders;
27 |
28 | import com.google.zxing.FormatException;
29 | import com.google.zxing.NotFoundException;
30 | import com.google.zxing.common.BitArray;
31 |
32 | /**
33 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
34 | */
35 | final class AI01393xDecoder extends AI01decoder {
36 |
37 | private static final int HEADER_SIZE = 5 + 1 + 2;
38 | private static final int LAST_DIGIT_SIZE = 2;
39 | private static final int FIRST_THREE_DIGITS_SIZE = 10;
40 |
41 | AI01393xDecoder(BitArray information) {
42 | super(information);
43 | }
44 |
45 | @Override
46 | public String parseInformation() throws NotFoundException, FormatException {
47 | if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
48 | throw NotFoundException.getNotFoundInstance();
49 | }
50 |
51 | StringBuilder buf = new StringBuilder();
52 |
53 | encodeCompressedGtin(buf, HEADER_SIZE);
54 |
55 | int lastAIdigit =
56 | this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);
57 |
58 | buf.append("(393");
59 | buf.append(lastAIdigit);
60 | buf.append(')');
61 |
62 | int firstThreeDigits =
63 | this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE);
64 | if (firstThreeDigits / 100 == 0) {
65 | buf.append('0');
66 | }
67 | if (firstThreeDigits / 10 == 0) {
68 | buf.append('0');
69 | }
70 | buf.append(firstThreeDigits);
71 |
72 | DecodedInformation generalInformation =
73 | this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, null);
74 | buf.append(generalInformation.getNewString());
75 |
76 | return buf.toString();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing.common.reedsolomon;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | /**
23 | *
Implements Reed-Solomon encoding, as the name implies.
24 | *
25 | * @author Sean Owen
26 | * @author William Rucklidge
27 | */
28 | public final class ReedSolomonEncoder {
29 |
30 | private final GenericGF field;
31 | private final List cachedGenerators;
32 |
33 | public ReedSolomonEncoder(GenericGF field) {
34 | this.field = field;
35 | this.cachedGenerators = new ArrayList<>();
36 | cachedGenerators.add(new GenericGFPoly(field, new int[]{1}));
37 | }
38 |
39 | private GenericGFPoly buildGenerator(int degree) {
40 | if (degree >= cachedGenerators.size()) {
41 | GenericGFPoly lastGenerator = cachedGenerators.get(cachedGenerators.size() - 1);
42 | for (int d = cachedGenerators.size(); d <= degree; d++) {
43 | GenericGFPoly nextGenerator = lastGenerator.multiply(
44 | new GenericGFPoly(field, new int[] { 1, field.exp(d - 1 + field.getGeneratorBase()) }));
45 | cachedGenerators.add(nextGenerator);
46 | lastGenerator = nextGenerator;
47 | }
48 | }
49 | return cachedGenerators.get(degree);
50 | }
51 |
52 | public void encode(int[] toEncode, int ecBytes) {
53 | if (ecBytes == 0) {
54 | throw new IllegalArgumentException("No error correction bytes");
55 | }
56 | int dataBytes = toEncode.length - ecBytes;
57 | if (dataBytes <= 0) {
58 | throw new IllegalArgumentException("No data bytes provided");
59 | }
60 | GenericGFPoly generator = buildGenerator(ecBytes);
61 | int[] infoCoefficients = new int[dataBytes];
62 | System.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes);
63 | GenericGFPoly info = new GenericGFPoly(field, infoCoefficients);
64 | info = info.multiplyByMonomial(ecBytes, 1);
65 | GenericGFPoly remainder = info.divide(generator)[1];
66 | int[] coefficients = remainder.getCoefficients();
67 | int numZeroCoefficients = ecBytes - coefficients.length;
68 | for (int i = 0; i < numZeroCoefficients; i++) {
69 | toEncode[dataBytes + i] = 0;
70 | }
71 | System.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/Reader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing;
18 |
19 | import java.util.Map;
20 |
21 | /**
22 | * Implementations of this interface can decode an image of a barcode in some format into
23 | * the String it encodes. For example, {@link com.google.zxing.qrcode.QRCodeReader} can
24 | * decode a QR code. The decoder may optionally receive hints from the caller which may help
25 | * it decode more quickly or accurately.
26 | *
27 | * See {@link MultiFormatReader}, which attempts to determine what barcode
28 | * format is present within the image as well, and then decodes it accordingly.
29 | *
30 | * @author Sean Owen
31 | * @author dswitkin@google.com (Daniel Switkin)
32 | */
33 | public interface Reader {
34 |
35 | /**
36 | * Locates and decodes a barcode in some format within an image.
37 | *
38 | * @param image image of barcode to decode
39 | * @return String which the barcode encodes
40 | * @throws NotFoundException if no potential barcode is found
41 | * @throws ChecksumException if a potential barcode is found but does not pass its checksum
42 | * @throws FormatException if a potential barcode is found but format is invalid
43 | */
44 | Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException;
45 |
46 | /**
47 | * Locates and decodes a barcode in some format within an image. This method also accepts
48 | * hints, each possibly associated to some data, which may help the implementation decode.
49 | *
50 | * @param image image of barcode to decode
51 | * @param hints passed as a {@link Map} from {@link DecodeHintType}
52 | * to arbitrary data. The
53 | * meaning of the data depends upon the hint type. The implementation may or may not do
54 | * anything with these hints.
55 | * @return String which the barcode encodes
56 | * @throws NotFoundException if no potential barcode is found
57 | * @throws ChecksumException if a potential barcode is found but does not pass its checksum
58 | * @throws FormatException if a potential barcode is found but format is invalid
59 | */
60 | Result decode(BinaryBitmap image, Map hints)
61 | throws NotFoundException, ChecksumException, FormatException;
62 |
63 | /**
64 | * Resets any internal state the implementation has after a decode, to prepare it
65 | * for reuse.
66 | */
67 | void reset();
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/detector/FinderPattern.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.qrcode.detector;
18 |
19 | import com.google.zxing.ResultPoint;
20 |
21 | /**
22 | *
Encapsulates a finder pattern, which are the three square patterns found in
23 | * the corners of QR Codes. It also encapsulates a count of similar finder patterns,
24 | * as a convenience to the finder's bookkeeping.
Determines if this finder pattern "about equals" a finder pattern at the stated
59 | * position and size -- meaning, it is at nearly the same center with nearly the same size.
60 | */
61 | boolean aboutEquals(float moduleSize, float i, float j) {
62 | if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) {
63 | float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
64 | return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize;
65 | }
66 | return false;
67 | }
68 |
69 | /**
70 | * Combines this object's current estimate of a finder pattern position and module size
71 | * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average
72 | * based on count.
73 | */
74 | FinderPattern combineEstimate(float i, float j, float newModuleSize) {
75 | int combinedCount = count + 1;
76 | float combinedX = (count * getX() + j) / combinedCount;
77 | float combinedY = (count * getY() + i) / combinedCount;
78 | float combinedModuleSize = (count * estimatedModuleSize + newModuleSize) / combinedCount;
79 | return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount);
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/UPCAReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.BarcodeFormat;
20 | import com.google.zxing.BinaryBitmap;
21 | import com.google.zxing.ChecksumException;
22 | import com.google.zxing.DecodeHintType;
23 | import com.google.zxing.FormatException;
24 | import com.google.zxing.NotFoundException;
25 | import com.google.zxing.Result;
26 | import com.google.zxing.common.BitArray;
27 |
28 | import java.util.Map;
29 |
30 | /**
31 | *
Implements decoding of the UPC-A format.
32 | *
33 | * @author dswitkin@google.com (Daniel Switkin)
34 | * @author Sean Owen
35 | */
36 | public final class UPCAReader extends UPCEANReader {
37 |
38 | private final UPCEANReader ean13Reader = new EAN13Reader();
39 |
40 | @Override
41 | public Result decodeRow(int rowNumber,
42 | BitArray row,
43 | int[] startGuardRange,
44 | Map hints)
45 | throws NotFoundException, FormatException, ChecksumException {
46 | return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange, hints));
47 | }
48 |
49 | @Override
50 | public Result decodeRow(int rowNumber, BitArray row, Map hints)
51 | throws NotFoundException, FormatException, ChecksumException {
52 | return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, hints));
53 | }
54 |
55 | @Override
56 | public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
57 | return maybeReturnResult(ean13Reader.decode(image));
58 | }
59 |
60 | @Override
61 | public Result decode(BinaryBitmap image, Map hints)
62 | throws NotFoundException, FormatException {
63 | return maybeReturnResult(ean13Reader.decode(image, hints));
64 | }
65 |
66 | @Override
67 | BarcodeFormat getBarcodeFormat() {
68 | return BarcodeFormat.UPC_A;
69 | }
70 |
71 | @Override
72 | protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString)
73 | throws NotFoundException {
74 | return ean13Reader.decodeMiddle(row, startRange, resultString);
75 | }
76 |
77 | private static Result maybeReturnResult(Result result) throws FormatException {
78 | String text = result.getText();
79 | if (text.charAt(0) == '0') {
80 | return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
81 | } else {
82 | throw FormatException.getFormatInstance();
83 | }
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/encoder/QRCode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing.qrcode.encoder;
18 |
19 | import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
20 | import com.google.zxing.qrcode.decoder.Mode;
21 | import com.google.zxing.qrcode.decoder.Version;
22 |
23 | /**
24 | * @author satorux@google.com (Satoru Takabayashi) - creator
25 | * @author dswitkin@google.com (Daniel Switkin) - ported from C++
26 | */
27 | public final class QRCode {
28 |
29 | public static final int NUM_MASK_PATTERNS = 8;
30 |
31 | private Mode mode;
32 | private ErrorCorrectionLevel ecLevel;
33 | private Version version;
34 | private int maskPattern;
35 | private ByteMatrix matrix;
36 |
37 | public QRCode() {
38 | maskPattern = -1;
39 | }
40 |
41 | public Mode getMode() {
42 | return mode;
43 | }
44 |
45 | public ErrorCorrectionLevel getECLevel() {
46 | return ecLevel;
47 | }
48 |
49 | public Version getVersion() {
50 | return version;
51 | }
52 |
53 | public int getMaskPattern() {
54 | return maskPattern;
55 | }
56 |
57 | public ByteMatrix getMatrix() {
58 | return matrix;
59 | }
60 |
61 | @Override
62 | public String toString() {
63 | StringBuilder result = new StringBuilder(200);
64 | result.append("<<\n");
65 | result.append(" mode: ");
66 | result.append(mode);
67 | result.append("\n ecLevel: ");
68 | result.append(ecLevel);
69 | result.append("\n version: ");
70 | result.append(version);
71 | result.append("\n maskPattern: ");
72 | result.append(maskPattern);
73 | if (matrix == null) {
74 | result.append("\n matrix: null\n");
75 | } else {
76 | result.append("\n matrix:\n");
77 | result.append(matrix);
78 | }
79 | result.append(">>\n");
80 | return result.toString();
81 | }
82 |
83 | public void setMode(Mode value) {
84 | mode = value;
85 | }
86 |
87 | public void setECLevel(ErrorCorrectionLevel value) {
88 | ecLevel = value;
89 | }
90 |
91 | public void setVersion(Version version) {
92 | this.version = version;
93 | }
94 |
95 | public void setMaskPattern(int value) {
96 | maskPattern = value;
97 | }
98 |
99 | public void setMatrix(ByteMatrix value) {
100 | matrix = value;
101 | }
102 |
103 | // Check if "mask_pattern" is valid.
104 | public static boolean isValidMaskPattern(int maskPattern) {
105 | return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS;
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/CodecTools/VideoEncodeConfig.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.CodecTools;
2 |
3 | import android.media.MediaCodecInfo;
4 | import android.media.MediaFormat;
5 | import androidx.annotation.NonNull;
6 |
7 | import java.util.Objects;
8 |
9 | /**
10 | * Created by wOw on 2019-08-19.
11 | * Email: wossoneri@163.com
12 | * Copyright (c) 2019 Softard. All rights reserved.
13 | */
14 | public class VideoEncodeConfig {
15 | public final int width;
16 | public final int height;
17 | public final int bitrate;
18 | public final int framerate;
19 | public final int iframeInterval;
20 | public final String codecName;
21 | public final String mimeType;
22 | public final MediaCodecInfo.CodecProfileLevel codecProfileLevel;
23 |
24 | /**
25 | * @param codecName selected codec name, maybe null
26 | * @param mimeType video MIME type, cannot be null
27 | * @param codecProfileLevel profile level for video encoder nullable
28 | */
29 | public VideoEncodeConfig(@NonNull int width, @NonNull int height, int bitrate,
30 | int framerate, int iframeInterval,
31 | String codecName, @NonNull String mimeType,
32 | MediaCodecInfo.CodecProfileLevel codecProfileLevel) {
33 | this.width = width;
34 | this.height = height;
35 | this.bitrate = bitrate;
36 | this.framerate = framerate;
37 | this.iframeInterval = iframeInterval;
38 | this.codecName = codecName;
39 | this.mimeType = Objects.requireNonNull(mimeType);
40 | this.codecProfileLevel = codecProfileLevel;
41 | }
42 |
43 | MediaFormat toFormat() {
44 | MediaFormat format = MediaFormat.createVideoFormat(mimeType, width, height);
45 | format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
46 | format.setInteger(MediaFormat.KEY_BIT_RATE, bitrate);
47 | format.setInteger(MediaFormat.KEY_FRAME_RATE, framerate);
48 | format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, iframeInterval);
49 | if (codecProfileLevel != null && codecProfileLevel.profile != 0 && codecProfileLevel.level != 0) {
50 | format.setInteger(MediaFormat.KEY_PROFILE, codecProfileLevel.profile);
51 | format.setInteger("level", codecProfileLevel.level);
52 | }
53 | // maybe useful
54 | // format.setInteger(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, 10_000_000);
55 | return format;
56 | }
57 |
58 | @Override
59 | public String toString() {
60 | return "VideoEncodeConfig{" +
61 | "width=" + width +
62 | ", height=" + height +
63 | ", bitrate=" + bitrate +
64 | ", framerate=" + framerate +
65 | ", iframeInterval=" + iframeInterval +
66 | ", codecName='" + codecName + '\'' +
67 | ", mimeType='" + mimeType + '\'' +
68 | ", codecProfileLevel=" + (codecProfileLevel == null ? "" : Utils.avcProfileLevelToString(
69 | codecProfileLevel)) +
70 | '}';
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/ResultMetadataType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 ZXing authors
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 com.google.zxing;
18 |
19 | /**
20 | * Represents some type of metadata about the result of the decoding that the decoder
21 | * wishes to communicate back to the caller.
22 | *
23 | * @author Sean Owen
24 | */
25 | public enum ResultMetadataType {
26 |
27 | /**
28 | * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
29 | */
30 | OTHER,
31 |
32 | /**
33 | * Denotes the likely approximate orientation of the barcode in the image. This value
34 | * is given as degrees rotated clockwise from the normal, upright orientation.
35 | * For example a 1D barcode which was found by reading top-to-bottom would be
36 | * said to have orientation "90". This key maps to an {@link Integer} whose
37 | * value is in the range [0,360).
38 | */
39 | ORIENTATION,
40 |
41 | /**
42 | *
2D barcode formats typically encode text, but allow for a sort of 'byte mode'
43 | * which is sometimes used to encode binary data. While {@link Result} makes available
44 | * the complete raw bytes in the barcode for these formats, it does not offer the bytes
45 | * from the byte segments alone.
46 | *
47 | *
This maps to a {@link java.util.List} of byte arrays corresponding to the
48 | * raw bytes in the byte segments in the barcode, in order.
49 | */
50 | BYTE_SEGMENTS,
51 |
52 | /**
53 | * Error correction level used, if applicable. The value type depends on the
54 | * format, but is typically a String.
55 | */
56 | ERROR_CORRECTION_LEVEL,
57 |
58 | /**
59 | * For some periodicals, indicates the issue number as an {@link Integer}.
60 | */
61 | ISSUE_NUMBER,
62 |
63 | /**
64 | * For some products, indicates the suggested retail price in the barcode as a
65 | * formatted {@link String}.
66 | */
67 | SUGGESTED_PRICE,
68 |
69 | /**
70 | * For some products, the possible country of manufacture as a {@link String} denoting the
71 | * ISO country code. Some map to multiple possible countries, like "US/CA".
72 | */
73 | POSSIBLE_COUNTRY,
74 |
75 | /**
76 | * For some products, the extension text
77 | */
78 | UPC_EAN_EXTENSION,
79 |
80 | /**
81 | * PDF417-specific metadata
82 | */
83 | PDF417_EXTRA_METADATA,
84 |
85 | /**
86 | * If the code format supports structured append and the current scanned code is part of one then the
87 | * sequence number is given with it.
88 | */
89 | STRUCTURED_APPEND_SEQUENCE,
90 |
91 | /**
92 | * If the code format supports structured append and the current scanned code is part of one then the
93 | * parity is given with it.
94 | */
95 | STRUCTURED_APPEND_PARITY,
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/ExpandedPair.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded;
28 |
29 | import com.google.zxing.oned.rss.DataCharacter;
30 | import com.google.zxing.oned.rss.FinderPattern;
31 |
32 | /**
33 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
34 | */
35 | final class ExpandedPair {
36 |
37 | private final boolean mayBeLast;
38 | private final DataCharacter leftChar;
39 | private final DataCharacter rightChar;
40 | private final FinderPattern finderPattern;
41 |
42 | ExpandedPair(DataCharacter leftChar,
43 | DataCharacter rightChar,
44 | FinderPattern finderPattern,
45 | boolean mayBeLast) {
46 | this.leftChar = leftChar;
47 | this.rightChar = rightChar;
48 | this.finderPattern = finderPattern;
49 | this.mayBeLast = mayBeLast;
50 | }
51 |
52 | boolean mayBeLast() {
53 | return this.mayBeLast;
54 | }
55 |
56 | DataCharacter getLeftChar() {
57 | return this.leftChar;
58 | }
59 |
60 | DataCharacter getRightChar() {
61 | return this.rightChar;
62 | }
63 |
64 | FinderPattern getFinderPattern() {
65 | return this.finderPattern;
66 | }
67 |
68 | public boolean mustBeLast() {
69 | return this.rightChar == null;
70 | }
71 |
72 | @Override
73 | public String toString() {
74 | return
75 | "[ " + leftChar + " , " + rightChar + " : " +
76 | (finderPattern == null ? "null" : finderPattern.getValue()) + " ]";
77 | }
78 |
79 | @Override
80 | public boolean equals(Object o) {
81 | if (!(o instanceof ExpandedPair)) {
82 | return false;
83 | }
84 | ExpandedPair that = (ExpandedPair) o;
85 | return
86 | equalsOrNull(leftChar, that.leftChar) &&
87 | equalsOrNull(rightChar, that.rightChar) &&
88 | equalsOrNull(finderPattern, that.finderPattern);
89 | }
90 |
91 | private static boolean equalsOrNull(Object o1, Object o2) {
92 | return o1 == null ? o2 == null : o1.equals(o2);
93 | }
94 |
95 | @Override
96 | public int hashCode() {
97 | return hashNotNull(leftChar) ^ hashNotNull(rightChar) ^ hashNotNull(finderPattern);
98 | }
99 |
100 | private static int hashNotNull(Object o) {
101 | return o == null ? 0 : o.hashCode();
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/Code39Writer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.BarcodeFormat;
20 | import com.google.zxing.EncodeHintType;
21 | import com.google.zxing.WriterException;
22 | import com.google.zxing.common.BitMatrix;
23 |
24 | import java.util.Map;
25 |
26 | /**
27 | * This object renders a CODE39 code as a {@link BitMatrix}.
28 | *
29 | * @author erik.barbara@gmail.com (Erik Barbara)
30 | */
31 | public final class Code39Writer extends OneDimensionalCodeWriter {
32 |
33 | @Override
34 | public BitMatrix encode(String contents,
35 | BarcodeFormat format,
36 | int width,
37 | int height,
38 | Map hints) throws WriterException {
39 | if (format != BarcodeFormat.CODE_39) {
40 | throw new IllegalArgumentException("Can only encode CODE_39, but got " + format);
41 | }
42 | return super.encode(contents, format, width, height, hints);
43 | }
44 |
45 | @Override
46 | public boolean[] encode(String contents) {
47 | int length = contents.length();
48 | if (length > 80) {
49 | throw new IllegalArgumentException(
50 | "Requested contents should be less than 80 digits long, but got " + length);
51 | }
52 |
53 | int[] widths = new int[9];
54 | int codeWidth = 24 + 1 + length;
55 | for (int i = 0; i < length; i++) {
56 | int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
57 | if (indexInString < 0) {
58 | throw new IllegalArgumentException("Bad contents: " + contents);
59 | }
60 | toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
61 | for (int width : widths) {
62 | codeWidth += width;
63 | }
64 | }
65 | boolean[] result = new boolean[codeWidth];
66 | toIntArray(Code39Reader.ASTERISK_ENCODING, widths);
67 | int pos = appendPattern(result, 0, widths, true);
68 | int[] narrowWhite = {1};
69 | pos += appendPattern(result, pos, narrowWhite, false);
70 | //append next character to byte matrix
71 | for (int i = 0; i < length; i++) {
72 | int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
73 | toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
74 | pos += appendPattern(result, pos, widths, true);
75 | pos += appendPattern(result, pos, narrowWhite, false);
76 | }
77 | toIntArray(Code39Reader.ASTERISK_ENCODING, widths);
78 | appendPattern(result, pos, widths, true);
79 | return result;
80 | }
81 |
82 | private static void toIntArray(int a, int[] toReturn) {
83 | for (int i = 0; i < 9; i++) {
84 | int temp = a & (1 << (8 - i));
85 | toReturn[i] = temp == 0 ? 1 : 2;
86 | }
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/qrcode/decoder/Mode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.qrcode.decoder;
18 |
19 | /**
20 | *
See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which
21 | * data can be encoded to bits in the QR code standard.
22 | *
23 | * @author Sean Owen
24 | */
25 | public enum Mode {
26 |
27 | TERMINATOR(new int[]{0, 0, 0}, 0x00), // Not really a mode...
28 | NUMERIC(new int[]{10, 12, 14}, 0x01),
29 | ALPHANUMERIC(new int[]{9, 11, 13}, 0x02),
30 | STRUCTURED_APPEND(new int[]{0, 0, 0}, 0x03), // Not supported
31 | BYTE(new int[]{8, 16, 16}, 0x04),
32 | ECI(new int[]{0, 0, 0}, 0x07), // character counts don't apply
33 | KANJI(new int[]{8, 10, 12}, 0x08),
34 | FNC1_FIRST_POSITION(new int[]{0, 0, 0}, 0x05),
35 | FNC1_SECOND_POSITION(new int[]{0, 0, 0}, 0x09),
36 | /** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */
37 | HANZI(new int[]{8, 10, 12}, 0x0D);
38 |
39 | private final int[] characterCountBitsForVersions;
40 | private final int bits;
41 |
42 | Mode(int[] characterCountBitsForVersions, int bits) {
43 | this.characterCountBitsForVersions = characterCountBitsForVersions;
44 | this.bits = bits;
45 | }
46 |
47 | /**
48 | * @param bits four bits encoding a QR Code data mode
49 | * @return Mode encoded by these bits
50 | * @throws IllegalArgumentException if bits do not correspond to a known mode
51 | */
52 | public static Mode forBits(int bits) {
53 | switch (bits) {
54 | case 0x0:
55 | return TERMINATOR;
56 | case 0x1:
57 | return NUMERIC;
58 | case 0x2:
59 | return ALPHANUMERIC;
60 | case 0x3:
61 | return STRUCTURED_APPEND;
62 | case 0x4:
63 | return BYTE;
64 | case 0x5:
65 | return FNC1_FIRST_POSITION;
66 | case 0x7:
67 | return ECI;
68 | case 0x8:
69 | return KANJI;
70 | case 0x9:
71 | return FNC1_SECOND_POSITION;
72 | case 0xD:
73 | // 0xD is defined in GBT 18284-2000, may not be supported in foreign country
74 | return HANZI;
75 | default:
76 | throw new IllegalArgumentException();
77 | }
78 | }
79 |
80 | /**
81 | * @param version version in question
82 | * @return number of bits used, in this QR Code symbol {@link Version}, to encode the
83 | * count of characters that will follow encoded in this Mode
84 | */
85 | public int getCharacterCountBits(Version version) {
86 | int number = version.getVersionNumber();
87 | int offset;
88 | if (number <= 9) {
89 | offset = 0;
90 | } else if (number <= 26) {
91 | offset = 1;
92 | } else {
93 | offset = 2;
94 | }
95 | return characterCountBitsForVersions[offset];
96 | }
97 |
98 | public int getBits() {
99 | return bits;
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture;
2 |
3 | import android.Manifest;
4 | import android.app.AlertDialog;
5 | import android.content.DialogInterface;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.net.Uri;
9 | import android.os.Build;
10 | import android.provider.Settings;
11 | import androidx.annotation.NonNull;
12 | import androidx.appcompat.app.AppCompatActivity;
13 |
14 | /**
15 | * Created by wOw on 2019-05-21.
16 | * Email: wossoneri@163.com
17 | * Copyright (c) 2019 Softard. All rights reserved.
18 | */
19 | public class BaseActivity extends AppCompatActivity {
20 |
21 | private static final int REQUEST_CODE = 9527;
22 |
23 | private static String[] PERMISSIONS = {
24 | Manifest.permission.READ_EXTERNAL_STORAGE,
25 | Manifest.permission.WRITE_EXTERNAL_STORAGE,
26 | Manifest.permission.RECORD_AUDIO,
27 | Manifest.permission.CAMERA
28 | };
29 |
30 | @Override
31 | protected void onResume() {
32 | super.onResume();
33 | checkPermissions();
34 | }
35 |
36 | @Override
37 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[]
38 | grantResults) {
39 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
40 | if (REQUEST_CODE == requestCode) {
41 | boolean isAllGranted = false;
42 | for (int result : grantResults) {
43 | if (result != PackageManager.PERMISSION_GRANTED) {
44 | isAllGranted = false;
45 | break;
46 | }
47 | isAllGranted = true;
48 | }
49 | if (!isAllGranted) {
50 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
51 | builder.setMessage("Need Permission");
52 | builder.setPositiveButton("Grant now", new DialogInterface.OnClickListener() {
53 | @Override
54 | public void onClick(DialogInterface dialog, int which) {
55 | Intent intent = new Intent();
56 | intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
57 | intent.addCategory(Intent.CATEGORY_DEFAULT);
58 | intent.setData(Uri.parse("package:" + getPackageName()));
59 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
60 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
61 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
62 | startActivity(intent);
63 | }
64 | });
65 | builder.setNegativeButton("Fuck yourself", null);
66 | builder.show();
67 | } else {
68 |
69 | }
70 | }
71 | }
72 |
73 | //permission
74 | private void checkPermissions() {
75 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
76 | return;
77 | }
78 |
79 | Boolean isAllPermissionGranted = false;
80 | for (String permission : PERMISSIONS) {
81 | if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
82 | isAllPermissionGranted = false;
83 | break;
84 | }
85 | isAllPermissionGranted = true;
86 | }
87 |
88 | if (!isAllPermissionGranted) {
89 | requestPermissions(PERMISSIONS, REQUEST_CODE);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_socket_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
31 |
32 |
44 |
45 |
56 |
57 |
67 |
68 |
80 |
81 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
30 |
31 |
40 |
41 |
51 |
52 |
61 |
62 |
71 |
72 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.NotFoundException;
30 | import com.google.zxing.common.BitArray;
31 |
32 | /**
33 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
34 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
35 | */
36 | final class AI013x0x1xDecoder extends AI01weightDecoder {
37 |
38 | private static final int HEADER_SIZE = 7 + 1;
39 | private static final int WEIGHT_SIZE = 20;
40 | private static final int DATE_SIZE = 16;
41 |
42 | private final String dateCode;
43 | private final String firstAIdigits;
44 |
45 | AI013x0x1xDecoder(BitArray information, String firstAIdigits, String dateCode) {
46 | super(information);
47 | this.dateCode = dateCode;
48 | this.firstAIdigits = firstAIdigits;
49 | }
50 |
51 | @Override
52 | public String parseInformation() throws NotFoundException {
53 | if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) {
54 | throw NotFoundException.getNotFoundInstance();
55 | }
56 |
57 | StringBuilder buf = new StringBuilder();
58 |
59 | encodeCompressedGtin(buf, HEADER_SIZE);
60 | encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE);
61 | encodeCompressedDate(buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE);
62 |
63 | return buf.toString();
64 | }
65 |
66 | private void encodeCompressedDate(StringBuilder buf, int currentPos) {
67 | int numericDate = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, DATE_SIZE);
68 | if (numericDate == 38400) {
69 | return;
70 | }
71 |
72 | buf.append('(');
73 | buf.append(this.dateCode);
74 | buf.append(')');
75 |
76 | int day = numericDate % 32;
77 | numericDate /= 32;
78 | int month = numericDate % 12 + 1;
79 | numericDate /= 12;
80 | int year = numericDate;
81 |
82 | if (year / 10 == 0) {
83 | buf.append('0');
84 | }
85 | buf.append(year);
86 | if (month / 10 == 0) {
87 | buf.append('0');
88 | }
89 | buf.append(month);
90 | if (day / 10 == 0) {
91 | buf.append('0');
92 | }
93 | buf.append(day);
94 | }
95 |
96 | @Override
97 | protected void addWeightCode(StringBuilder buf, int weight) {
98 | buf.append('(');
99 | buf.append(this.firstAIdigits);
100 | buf.append(weight / 100000);
101 | buf.append(')');
102 | }
103 |
104 | @Override
105 | protected int checkWeight(int weight) {
106 | return weight % 100000;
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 ZXing authors
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 | /*
18 | * These authors would like to acknowledge the Spanish Ministry of Industry,
19 | * Tourism and Trade, for the support in the project TSI020301-2008-2
20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 | * Mobile Dynamic Environments", led by Treelogic
22 | * ( http://www.treelogic.com/ ):
23 | *
24 | * http://www.piramidepse.com/
25 | */
26 |
27 | package com.google.zxing.oned.rss.expanded.decoders;
28 |
29 | import com.google.zxing.FormatException;
30 | import com.google.zxing.NotFoundException;
31 | import com.google.zxing.common.BitArray;
32 |
33 | /**
34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
35 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
36 | */
37 | public abstract class AbstractExpandedDecoder {
38 |
39 | private final BitArray information;
40 | private final GeneralAppIdDecoder generalDecoder;
41 |
42 | AbstractExpandedDecoder(BitArray information) {
43 | this.information = information;
44 | this.generalDecoder = new GeneralAppIdDecoder(information);
45 | }
46 |
47 | protected final BitArray getInformation() {
48 | return information;
49 | }
50 |
51 | protected final GeneralAppIdDecoder getGeneralDecoder() {
52 | return generalDecoder;
53 | }
54 |
55 | public abstract String parseInformation() throws NotFoundException, FormatException;
56 |
57 | public static AbstractExpandedDecoder createDecoder(BitArray information) {
58 | if (information.get(1)) {
59 | return new AI01AndOtherAIs(information);
60 | }
61 | if (!information.get(2)) {
62 | return new AnyAIDecoder(information);
63 | }
64 |
65 | int fourBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 4);
66 |
67 | switch (fourBitEncodationMethod) {
68 | case 4: return new AI013103decoder(information);
69 | case 5: return new AI01320xDecoder(information);
70 | }
71 |
72 | int fiveBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 5);
73 | switch (fiveBitEncodationMethod) {
74 | case 12: return new AI01392xDecoder(information);
75 | case 13: return new AI01393xDecoder(information);
76 | }
77 |
78 | int sevenBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 7);
79 | switch (sevenBitEncodationMethod) {
80 | case 56: return new AI013x0x1xDecoder(information, "310", "11");
81 | case 57: return new AI013x0x1xDecoder(information, "320", "11");
82 | case 58: return new AI013x0x1xDecoder(information, "310", "13");
83 | case 59: return new AI013x0x1xDecoder(information, "320", "13");
84 | case 60: return new AI013x0x1xDecoder(information, "310", "15");
85 | case 61: return new AI013x0x1xDecoder(information, "320", "15");
86 | case 62: return new AI013x0x1xDecoder(information, "310", "17");
87 | case 63: return new AI013x0x1xDecoder(information, "320", "17");
88 | }
89 |
90 | throw new IllegalStateException("unknown decoder: " + information);
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/EAN8Writer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.BarcodeFormat;
20 | import com.google.zxing.EncodeHintType;
21 | import com.google.zxing.FormatException;
22 | import com.google.zxing.WriterException;
23 | import com.google.zxing.common.BitMatrix;
24 |
25 | import java.util.Map;
26 |
27 | /**
28 | * This object renders an EAN8 code as a {@link BitMatrix}.
29 | *
30 | * @author aripollak@gmail.com (Ari Pollak)
31 | */
32 | public final class EAN8Writer extends UPCEANWriter {
33 |
34 | private static final int CODE_WIDTH = 3 + // start guard
35 | (7 * 4) + // left bars
36 | 5 + // middle guard
37 | (7 * 4) + // right bars
38 | 3; // end guard
39 |
40 | @Override
41 | public BitMatrix encode(String contents,
42 | BarcodeFormat format,
43 | int width,
44 | int height,
45 | Map hints) throws WriterException {
46 | if (format != BarcodeFormat.EAN_8) {
47 | throw new IllegalArgumentException("Can only encode EAN_8, but got "
48 | + format);
49 | }
50 |
51 | return super.encode(contents, format, width, height, hints);
52 | }
53 |
54 | /**
55 | * @return a byte array of horizontal pixels (false = white, true = black)
56 | */
57 | @Override
58 | public boolean[] encode(String contents) {
59 | int length = contents.length();
60 | switch (length) {
61 | case 7:
62 | // No check digit present, calculate it and add it
63 | int check;
64 | try {
65 | check = UPCEANReader.getStandardUPCEANChecksum(contents);
66 | } catch (FormatException fe) {
67 | throw new IllegalArgumentException(fe);
68 | }
69 | contents += check;
70 | break;
71 | case 8:
72 | try {
73 | if (!UPCEANReader.checkStandardUPCEANChecksum(contents)) {
74 | throw new IllegalArgumentException("Contents do not pass checksum");
75 | }
76 | } catch (FormatException ignored) {
77 | throw new IllegalArgumentException("Illegal contents");
78 | }
79 | break;
80 | default:
81 | throw new IllegalArgumentException(
82 | "Requested contents should be 8 digits long, but got " + length);
83 | }
84 |
85 | boolean[] result = new boolean[CODE_WIDTH];
86 | int pos = 0;
87 |
88 | pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true);
89 |
90 | for (int i = 0; i <= 3; i++) {
91 | int digit = Character.digit(contents.charAt(i), 10);
92 | pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], false);
93 | }
94 |
95 | pos += appendPattern(result, pos, UPCEANReader.MIDDLE_PATTERN, false);
96 |
97 | for (int i = 4; i <= 7; i++) {
98 | int digit = Character.digit(contents.charAt(i), 10);
99 | pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], true);
100 | }
101 | appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true);
102 |
103 | return result;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/oned/UPCEWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing.oned;
18 |
19 | import com.google.zxing.BarcodeFormat;
20 | import com.google.zxing.EncodeHintType;
21 | import com.google.zxing.FormatException;
22 | import com.google.zxing.WriterException;
23 | import com.google.zxing.common.BitMatrix;
24 |
25 | import java.util.Map;
26 |
27 | /**
28 | * This object renders an UPC-E code as a {@link BitMatrix}.
29 | *
30 | * @author 0979097955s@gmail.com (RX)
31 | */
32 | public final class UPCEWriter extends UPCEANWriter {
33 |
34 | private static final int CODE_WIDTH = 3 + // start guard
35 | (7 * 6) + // bars
36 | 6; // end guard
37 |
38 | @Override
39 | public BitMatrix encode(String contents,
40 | BarcodeFormat format,
41 | int width,
42 | int height,
43 | Map hints) throws WriterException {
44 | if (format != BarcodeFormat.UPC_E) {
45 | throw new IllegalArgumentException("Can only encode UPC_E, but got " + format);
46 | }
47 |
48 | return super.encode(contents, format, width, height, hints);
49 | }
50 |
51 | @Override
52 | public boolean[] encode(String contents) {
53 | int length = contents.length();
54 | switch (length) {
55 | case 7:
56 | // No check digit present, calculate it and add it
57 | int check;
58 | try {
59 | check = UPCEANReader.getStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(contents));
60 | } catch (FormatException fe) {
61 | throw new IllegalArgumentException(fe);
62 | }
63 | contents += check;
64 | break;
65 | case 8:
66 | try {
67 | if (!UPCEANReader.checkStandardUPCEANChecksum(contents)) {
68 | throw new IllegalArgumentException("Contents do not pass checksum");
69 | }
70 | } catch (FormatException ignored) {
71 | throw new IllegalArgumentException("Illegal contents");
72 | }
73 | break;
74 | default:
75 | throw new IllegalArgumentException(
76 | "Requested contents should be 8 digits long, but got " + length);
77 | }
78 |
79 | int firstDigit = Character.digit(contents.charAt(0), 10);
80 | if (firstDigit != 0 && firstDigit != 1) {
81 | throw new IllegalArgumentException("Number system must be 0 or 1");
82 | }
83 |
84 | int checkDigit = Character.digit(contents.charAt(7), 10);
85 | int parities = UPCEReader.NUMSYS_AND_CHECK_DIGIT_PATTERNS[firstDigit][checkDigit];
86 | boolean[] result = new boolean[CODE_WIDTH];
87 | int pos = 0;
88 |
89 | pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true);
90 |
91 | for (int i = 1; i <= 6; i++) {
92 | int digit = Character.digit(contents.charAt(i), 10);
93 | if ((parities >> (6 - i) & 1) == 1) {
94 | digit += 10;
95 | }
96 | pos += appendPattern(result, pos, UPCEANReader.L_AND_G_PATTERNS[digit], false);
97 | }
98 |
99 | appendPattern(result, pos, UPCEANReader.END_PATTERN, false);
100 |
101 | return result;
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/common/BitSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 ZXing authors
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 com.google.zxing.common;
18 |
19 | /**
20 | *
This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
21 | * number of bits read is not often a multiple of 8.
22 | *
23 | *
This class is thread-safe but not reentrant -- unless the caller modifies the bytes array
24 | * it passed in, in which case all bets are off.
25 | *
26 | * @author Sean Owen
27 | */
28 | public final class BitSource {
29 |
30 | private final byte[] bytes;
31 | private int byteOffset;
32 | private int bitOffset;
33 |
34 | /**
35 | * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
36 | * Bits are read within a byte from most-significant to least-significant bit.
37 | */
38 | public BitSource(byte[] bytes) {
39 | this.bytes = bytes;
40 | }
41 |
42 | /**
43 | * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}.
44 | */
45 | public int getBitOffset() {
46 | return bitOffset;
47 | }
48 |
49 | /**
50 | * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}.
51 | */
52 | public int getByteOffset() {
53 | return byteOffset;
54 | }
55 |
56 | /**
57 | * @param numBits number of bits to read
58 | * @return int representing the bits read. The bits will appear as the least-significant
59 | * bits of the int
60 | * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available
61 | */
62 | public int readBits(int numBits) {
63 | if (numBits < 1 || numBits > 32 || numBits > available()) {
64 | throw new IllegalArgumentException(String.valueOf(numBits));
65 | }
66 |
67 | int result = 0;
68 |
69 | // First, read remainder from current byte
70 | if (bitOffset > 0) {
71 | int bitsLeft = 8 - bitOffset;
72 | int toRead = numBits < bitsLeft ? numBits : bitsLeft;
73 | int bitsToNotRead = bitsLeft - toRead;
74 | int mask = (0xFF >> (8 - toRead)) << bitsToNotRead;
75 | result = (bytes[byteOffset] & mask) >> bitsToNotRead;
76 | numBits -= toRead;
77 | bitOffset += toRead;
78 | if (bitOffset == 8) {
79 | bitOffset = 0;
80 | byteOffset++;
81 | }
82 | }
83 |
84 | // Next read whole bytes
85 | if (numBits > 0) {
86 | while (numBits >= 8) {
87 | result = (result << 8) | (bytes[byteOffset] & 0xFF);
88 | byteOffset++;
89 | numBits -= 8;
90 | }
91 |
92 | // Finally read a partial byte
93 | if (numBits > 0) {
94 | int bitsToNotRead = 8 - numBits;
95 | int mask = (0xFF >> bitsToNotRead) << bitsToNotRead;
96 | result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead);
97 | bitOffset += numBits;
98 | }
99 | }
100 |
101 | return result;
102 | }
103 |
104 | /**
105 | * @return number of bits that can be read successfully
106 | */
107 | public int available() {
108 | return 8 * (bytes.length - byteOffset) - bitOffset;
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/com/softard/wow/screencapture/Utils/ImageUtils.java:
--------------------------------------------------------------------------------
1 | package com.softard.wow.screencapture.Utils;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.media.Image;
6 | import android.util.DisplayMetrics;
7 | import android.util.Log;
8 |
9 | import java.io.ByteArrayOutputStream;
10 | import java.nio.ByteBuffer;
11 |
12 | /**
13 | * Created by wOw on 2019-05-20.
14 | * Email: wossoneri@163.com
15 | * Copyright (c) 2019 Softard. All rights reserved.
16 | */
17 | public class ImageUtils {
18 |
19 | public static Bitmap image_ARGB8888_2_bitmap(DisplayMetrics metrics, Image image) {
20 | Image.Plane[] planes = image.getPlanes();
21 | ByteBuffer buffer = planes[0].getBuffer();
22 |
23 | int width = image.getWidth();
24 | // Log.d("WOW", "image w = " + width);
25 | int height = image.getHeight();
26 | // Log.d("WOW", "image h = " + height);
27 |
28 | int pixelStride = planes[0].getPixelStride();
29 | // Log.d("WOW", "pixelStride is " + pixelStride);
30 | int rowStride = planes[0].getRowStride();
31 | // Log.d("WOW", "row Stride is " + rowStride);
32 | int rowPadding = rowStride - pixelStride * width;
33 | // Log.d("WOW", "rowPadding is " + rowPadding);
34 |
35 | int offset = 0;
36 | Bitmap bitmap;
37 | bitmap = Bitmap.createBitmap(metrics, width, height, Bitmap.Config.ARGB_8888);
38 | for (int i = 0; i < height; ++i) {
39 | for (int j = 0; j < width; ++j) {
40 | int pixel = 0;
41 | pixel |= (buffer.get(offset) & 0xff) << 16; // R
42 | pixel |= (buffer.get(offset + 1) & 0xff) << 8; // G
43 | pixel |= (buffer.get(offset + 2) & 0xff); // B
44 | pixel |= (buffer.get(offset + 3) & 0xff) << 24; // A
45 | bitmap.setPixel(j, i, pixel);
46 | offset += pixelStride;
47 | }
48 | offset += rowPadding;
49 | }
50 | return bitmap;
51 | }
52 |
53 | /**
54 | * 这个方法可以转换,但是得到的图片右边多了一列,比如上面方法得到1080x2160,这个方法得到1088x2160
55 | * 所以要对得到的Bitmap裁剪一下
56 | *
57 | * @param image
58 | * @param config
59 | * @return
60 | */
61 | public static Bitmap image_2_bitmap(Image image, Bitmap.Config config) {
62 |
63 | int width = image.getWidth();
64 | int height = image.getHeight();
65 | Bitmap bitmap;
66 |
67 | final Image.Plane[] planes = image.getPlanes();
68 | final ByteBuffer buffer = planes[0].getBuffer();
69 | int pixelStride = planes[0].getPixelStride();
70 | int rowStride = planes[0].getRowStride();
71 | int rowPadding = rowStride - pixelStride * width;
72 | Log.d("WOW",
73 | "pixelStride:" + pixelStride + ". rowStride:" + rowStride + ". rowPadding" + rowPadding);
74 |
75 | bitmap = Bitmap.createBitmap(
76 | width + rowPadding / pixelStride/*equals: rowStride/pixelStride */
77 | , height, config);
78 | bitmap.copyPixelsFromBuffer(buffer);
79 |
80 | return Bitmap.createBitmap(bitmap, 0, 0, width, height);
81 | // return bitmap;
82 | }
83 |
84 | /**
85 | * PNG
86 | * @return
87 | */
88 | public static byte[] bitmap2byte(Bitmap bmp, int quality) {
89 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
90 | bmp.compress(Bitmap.CompressFormat.PNG, quality, baos);
91 | return baos.toByteArray();
92 | }
93 |
94 | public static Bitmap byte2bitmap(byte[] data) {
95 | if (data.length != 0) {
96 | return BitmapFactory.decodeByteArray(data, 0, data.length);
97 | } else {
98 | return null;
99 | }
100 | }
101 |
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/zxing/src/main/java/com/google/zxing/Binarizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
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 com.google.zxing;
18 |
19 | import com.google.zxing.common.BitArray;
20 | import com.google.zxing.common.BitMatrix;
21 |
22 | /**
23 | * This class hierarchy provides a set of methods to convert luminance data to 1 bit data.
24 | * It allows the algorithm to vary polymorphically, for example allowing a very expensive
25 | * thresholding technique for servers and a fast one for mobile. It also permits the implementation
26 | * to vary, e.g. a JNI version for Android and a Java fallback version for other platforms.
27 | *
28 | * @author dswitkin@google.com (Daniel Switkin)
29 | */
30 | public abstract class Binarizer {
31 |
32 | private final LuminanceSource source;
33 |
34 | protected Binarizer(LuminanceSource source) {
35 | this.source = source;
36 | }
37 |
38 | public final LuminanceSource getLuminanceSource() {
39 | return source;
40 | }
41 |
42 | /**
43 | * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
44 | * cached data. Callers should assume this method is expensive and call it as seldom as possible.
45 | * This method is intended for decoding 1D barcodes and may choose to apply sharpening.
46 | * For callers which only examine one row of pixels at a time, the same BitArray should be reused
47 | * and passed in with each call for performance. However it is legal to keep more than one row
48 | * at a time if needed.
49 | *
50 | * @param y The row to fetch, which must be in [0, bitmap height)
51 | * @param row An optional preallocated array. If null or too small, it will be ignored.
52 | * If used, the Binarizer will call BitArray.clear(). Always use the returned object.
53 | * @return The array of bits for this row (true means black).
54 | * @throws NotFoundException if row can't be binarized
55 | */
56 | public abstract BitArray getBlackRow(int y, BitArray row) throws NotFoundException;
57 |
58 | /**
59 | * Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive
60 | * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
61 | * may not apply sharpening. Therefore, a row from this matrix may not be identical to one
62 | * fetched using getBlackRow(), so don't mix and match between them.
63 | *
64 | * @return The 2D array of bits for the image (true means black).
65 | * @throws NotFoundException if image can't be binarized to make a matrix
66 | */
67 | public abstract BitMatrix getBlackMatrix() throws NotFoundException;
68 |
69 | /**
70 | * Creates a new object with the same type as this Binarizer implementation, but with pristine
71 | * state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache
72 | * of 1 bit data. See Effective Java for why we can't use Java's clone() method.
73 | *
74 | * @param source The LuminanceSource this Binarizer will operate on.
75 | * @return A new concrete Binarizer implementation object.
76 | */
77 | public abstract Binarizer createBinarizer(LuminanceSource source);
78 |
79 | public final int getWidth() {
80 | return source.getWidth();
81 | }
82 |
83 | public final int getHeight() {
84 | return source.getHeight();
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------