mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-20 22:58:21 +00:00
Merge remote-tracking branch 'upstream/master' into Cmake
This commit is contained in:
commit
62d6c61bf4
4
.lgtm.yml
Normal file
4
.lgtm.yml
Normal file
@ -0,0 +1,4 @@
|
||||
extraction:
|
||||
cpp:
|
||||
configure:
|
||||
command: "qmake -o Makefile CONFIG+=Release src/QZXing.pro"
|
52
.travis.yml
Normal file
52
.travis.yml
Normal file
@ -0,0 +1,52 @@
|
||||
#Author: KangLin(kl222@126.com)
|
||||
|
||||
sudo: required
|
||||
dist: xenial
|
||||
|
||||
services:
|
||||
- xvfb
|
||||
|
||||
language: cpp
|
||||
|
||||
cache:
|
||||
- apt: true
|
||||
- directories:
|
||||
- Tools
|
||||
|
||||
compiler:
|
||||
- g++
|
||||
|
||||
jdk: oraclejdk7
|
||||
|
||||
os:
|
||||
- unix
|
||||
|
||||
addons:
|
||||
ssh_known_hosts:
|
||||
- github.com
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
|
||||
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
|
||||
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
|
||||
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
|
||||
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
|
||||
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
|
||||
|
||||
before_install:
|
||||
- echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}"
|
||||
- export DISPLAY=:99.0
|
||||
- sudo apt-get install -y libgl1-mesa-glx libgl1-mesa-dev
|
||||
|
||||
install:
|
||||
- bash ${TRAVIS_BUILD_DIR}/ci/build-install-tools.sh #> /dev/null
|
||||
|
||||
before_script:
|
||||
- source ${TRAVIS_BUILD_DIR}/ci/build_env.sh
|
||||
|
||||
script:
|
||||
- mkdir ${TRAVIS_BUILD_DIR}/build
|
||||
- cd ${TRAVIS_BUILD_DIR}/build
|
||||
- ${QT_ROOT}/bin/qmake -o Makefile CONFIG+=Release ${TRAVIS_BUILD_DIR}/src/QZXing.pro
|
||||
- make -f Makefile
|
@ -1,4 +1,4 @@
|
||||
# qzxing
|
||||
# qzxing [](https://travis-ci.com/ftylitak/qzxing) [](https://ci.appveyor.com/project/ftylitak/qzxing) [](https://lgtm.com/projects/g/ftylitak/qzxing/alerts/) [](https://lgtm.com/projects/g/ftylitak/qzxing/context:cpp)
|
||||
Qt/QML wrapper library for the [ZXing](https://github.com/zxing/zxing) barcode image processing library.
|
||||
|
||||
Supports barcode decoding for the following types:
|
||||
|
102
appveyor.yml
Normal file
102
appveyor.yml
Normal file
@ -0,0 +1,102 @@
|
||||
#original author: KangLin(kl222@126.com)
|
||||
|
||||
version: '3.0.a.5.{build}'
|
||||
|
||||
configuration:
|
||||
- release
|
||||
- debug
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
QT_ROOT: C:/Qt/5.12/msvc2017_64
|
||||
# - QT_ROOT: C:/Qt/5.12/msvc2015
|
||||
# - QT_ROOT: C:/Qt/5.12/mingw53_32
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
QT_ROOT: C:/Qt/5.9/msvc2017_64
|
||||
# - QT_ROOT: C:/Qt/5.9/msvc2015_64
|
||||
# - QT_ROOT: C:/Qt/5.9/msvc2015
|
||||
# - QT_ROOT: C:/Qt/5.9/msvc2013_64
|
||||
# - QT_ROOT: C:/Qt/5.9/mingw53_32
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
QT_ROOT: C:/Qt/5.6/msvc2015_64
|
||||
# - QT_ROOT: C:/Qt/5.6/msvc2015
|
||||
# - QT_ROOT: C:/Qt/5.6/msvc2013_64
|
||||
# - QT_ROOT: C:/Qt/5.6/msvc2013
|
||||
|
||||
init:
|
||||
|
||||
install:
|
||||
- for /f "delims=" %%i in ('git describe --tags') do (set BUILD_VERSION=%%i)
|
||||
- if "%BUILD_VERSION%" == "" for /f "delims=" %%i in ('git rev-parse HEAD') do (set BUILD_VERSION=%%i)
|
||||
- echo BUILD_VERSION=%BUILD_VERSION%
|
||||
- if NOT "%QT_ROOT%" == "NO" for /f "delims=" %%i in ('%QT_ROOT%/bin/qmake -query QT_VERSION') do (set QT_VERSION=%%i)
|
||||
- echo "QT_VERSION:%QT_VERSION"
|
||||
- if NOT "%QT_ROOT%" == "NO" for /f "delims=" %%i in ('%QT_ROOT%/bin/qmake -query QMAKE_XSPEC') do (set QMAKE_XSPEC=%%i)
|
||||
- echo "QMAKE_XSPEC=%QMAKE_XSPEC%"
|
||||
- set TOOLCHAIN_VERSION=""
|
||||
- ps: >-
|
||||
if (($env:QMAKE_XSPEC).Contains("msvc"))
|
||||
{
|
||||
$env:MAKE="nmake"
|
||||
if (($env:QT_ROOT).Contains("_64"))
|
||||
{
|
||||
$env:varch="amd64"
|
||||
}
|
||||
else
|
||||
{
|
||||
$env:varch="x86"
|
||||
}
|
||||
if (($env:QT_ROOT).Contains("2017"))
|
||||
{
|
||||
$env:TOOLCHAIN_VERSION="15"
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($env:QT_ROOT).Contains("2015"))
|
||||
{
|
||||
$env:TOOLCHAIN_VERSION="14"
|
||||
}elseif (($env:QT_ROOT).Contains("2013"))
|
||||
{
|
||||
$env:TOOLCHAIN_VERSION="12"
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$env:MAKE="mingw32-make"
|
||||
$env:PATH="C:\Qt\Tools\mingw530_32;$env:PATH"
|
||||
}
|
||||
|
||||
- if NOT "%TOOLCHAIN_VERSION%"=="" if %TOOLCHAIN_VERSION% LSS 15 (call "C:/Program Files (x86)/Microsoft Visual Studio %TOOLCHAIN_VERSION%.0/VC/vcvarsall.bat" %varch%) else (call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat" %varch%)
|
||||
- echo "cl "
|
||||
- cl
|
||||
|
||||
build_script:
|
||||
- mkdir "%APPVEYOR_BUILD_FOLDER%/build"
|
||||
- cd "%APPVEYOR_BUILD_FOLDER%/build"
|
||||
- call "%QT_ROOT%/bin/qmake.exe" CONFIG+=%Configuration% PREFIX="%APPVEYOR_BUILD_FOLDER%/install" "%APPVEYOR_BUILD_FOLDER%/src/QZXing.pro"
|
||||
- call %MAKE%
|
||||
- call %MAKE% install
|
||||
|
||||
test_script:
|
||||
|
||||
artifacts:
|
||||
- path: install
|
||||
name: QZXing_$(QMAKE_XSPEC)$(TOOLCHAIN_VERSION)_$(CONFIGURATION)_$(BUILD_VERSION)
|
||||
type: zip
|
||||
|
||||
# whitelist branches to avoid testing feature branches twice (as branch and as pull request)
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
deploy:
|
||||
provider: GitHub
|
||||
#token: https://github.com/settings/tokens encode token: https://ci.appveyor.com/tools/encrypt
|
||||
auth_token:
|
||||
secure: #TODO: set your token
|
||||
on:
|
||||
appveyor_repo_tag: true # deploy on tag push only
|
78
ci/build-install-tools.sh
Normal file
78
ci/build-install-tools.sh
Normal file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
#Author: KangLin(kl222@126.com)
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE_DIR="`pwd`"
|
||||
echo $SOURCE_DIR
|
||||
TOOLS_DIR=${SOURCE_DIR}/Tools
|
||||
echo ${TOOLS_DIR}
|
||||
|
||||
if [ ! -f "${TOOLS_DIR}" ]; then
|
||||
mkdir -p ${TOOLS_DIR}
|
||||
fi
|
||||
|
||||
function function_common()
|
||||
{
|
||||
cd ${TOOLS_DIR}
|
||||
|
||||
# Qt download and install:https://github.com/benlau/qtci
|
||||
if [ -n "${QT_VERSION}" ]; then
|
||||
QT_DIR=`pwd`/Qt/${QT_VERSION}
|
||||
if [ ! -d "${QT_DIR}" ]; then
|
||||
wget -c --no-check-certificate -nv http://download.qt.io/official_releases/qt/${QT_VERSION_DIR}/${QT_VERSION}/qt-opensource-linux-x64-${QT_VERSION}.run
|
||||
bash ${SOURCE_DIR}/ci/qt-installer.sh qt-opensource-linux-x64-${QT_VERSION}.run ${QT_DIR}
|
||||
rm qt-opensource-linux-x64-${QT_VERSION}.run
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function function_android()
|
||||
{
|
||||
cd ${TOOLS_DIR}
|
||||
|
||||
#Download android ndk
|
||||
if [ ! -d "`pwd`/android-ndk" ]; then
|
||||
wget -c -nv http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin
|
||||
chmod u+x android-ndk-r10e-linux-x86_64.bin
|
||||
./android-ndk-r10e-linux-x86_64.bin > /dev/null
|
||||
mv android-ndk-r10e android-ndk
|
||||
rm android-ndk-r10e-linux-x86_64.bin
|
||||
fi
|
||||
|
||||
cd ${TOOLS_DIR}
|
||||
|
||||
#Download android sdk
|
||||
if [ ! -d "`pwd`/android-sdk" ]; then
|
||||
wget -c -nv https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
|
||||
tar xf android-sdk_r24.4.1-linux.tgz
|
||||
mv android-sdk-linux android-sdk
|
||||
rm android-sdk_r24.4.1-linux.tgz
|
||||
(sleep 5 ; while true ; do sleep 1 ; printf 'y\r\n' ; done ) \
|
||||
| android-sdk/tools/android update sdk -u -t tool,android-18,android-24,extra,platform,platform-tools,build-tools-25
|
||||
fi
|
||||
|
||||
function_common
|
||||
cd ${SOURCE_DIR}
|
||||
}
|
||||
|
||||
function function_linux()
|
||||
{
|
||||
function_common
|
||||
|
||||
cd ${SOURCE_DIR}
|
||||
}
|
||||
|
||||
case ${BUILD_TARGERT} in
|
||||
android*)
|
||||
function_android
|
||||
;;
|
||||
linux)
|
||||
function_linux
|
||||
;;
|
||||
*)
|
||||
echo "There aren't ${BUILD_TARGERT}"
|
||||
;;
|
||||
esac
|
||||
|
||||
cd ${SOURCE_DIR}
|
24
ci/build_env.sh
Normal file
24
ci/build_env.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#Author: KangLin(kl222@126.com)
|
||||
|
||||
SOURCE_DIR="`pwd`"
|
||||
echo $SOURCE_DIR
|
||||
TOOLS_DIR=${SOURCE_DIR}/Tools
|
||||
|
||||
cd ${TOOLS_DIR}
|
||||
|
||||
case "${BUILD_TARGERT}" in
|
||||
linux)
|
||||
QT_DIR=`pwd`/Qt/${QT_VERSION}
|
||||
export QT_ROOT=${QT_DIR}/${QT_VERSION}/gcc_64
|
||||
;;
|
||||
android*)
|
||||
export ANDROID_NDK_ROOT=`pwd`/android-ndk
|
||||
export ANDROID_NDK=$ANDROID_NDK_ROOT
|
||||
|
||||
export ANDROID_SDK_ROOT=`pwd`/android-sdk
|
||||
export ANDROID_SDK=$ANDROID_SDK_ROOT
|
||||
|
||||
QT_DIR=`pwd`/Qt/${QT_VERSION}
|
||||
export QT_ROOT=${QT_DIR}/${QT_VERSION}/android_armv7
|
||||
;;
|
||||
esac
|
133
ci/qt-installer.sh
Normal file
133
ci/qt-installer.sh
Normal file
@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
|
||||
#http://stackoverflow.com/questions/25105269/silent-install-qt-run-installer-on-ubuntu-server
|
||||
#http://doc.qt.io/qtinstallerframework/noninteractive.html
|
||||
#参考:https://github.com/benlau/qtci
|
||||
# https://github.com/mjscosta/qt-silent-installer
|
||||
|
||||
set -e #quit on error
|
||||
|
||||
if [ $# -lt 2 ];
|
||||
then
|
||||
echo qt-installer.sh qt-installer-file output_path
|
||||
exit -1
|
||||
fi
|
||||
|
||||
export PATH=$PATH:$PWD
|
||||
export WORKDIR=$PWD
|
||||
INSTALLER=$1
|
||||
OUTPUT=$2
|
||||
SCRIPT="$(mktemp /tmp/tmp.XXXXXXXXX)"
|
||||
case $BUILD_TARGERT in
|
||||
android_arm*)
|
||||
SELECTEDPACKAGES=android_armv7
|
||||
;;
|
||||
android_x86)
|
||||
SELECTEDPACKAGES=android_x86
|
||||
;;
|
||||
linux)
|
||||
SELECTEDPACKAGES=gcc_64
|
||||
;;
|
||||
*)
|
||||
echo "Aach[$RABBIT_ARCH] don't suppoert"
|
||||
esac
|
||||
|
||||
cat <<EOF > $SCRIPT
|
||||
function Controller() {
|
||||
installer.autoRejectMessageBoxes();
|
||||
installer.installationFinished.connect(function() {
|
||||
gui.clickButton(buttons.NextButton);
|
||||
});
|
||||
}
|
||||
|
||||
function log() {
|
||||
var msg = ["QTCI: "].concat([].slice.call(arguments));
|
||||
|
||||
console.log(msg.join(" "));
|
||||
}
|
||||
|
||||
Controller.prototype.WelcomePageCallback = function() {
|
||||
gui.clickButton(buttons.NextButton, 5000);
|
||||
}
|
||||
|
||||
Controller.prototype.CredentialsPageCallback = function() {
|
||||
gui.clickButton(buttons.CommitButton);
|
||||
}
|
||||
|
||||
Controller.prototype.ComponentSelectionPageCallback = function() {
|
||||
var components = installer.components();
|
||||
log("Available components: " + components.length);
|
||||
for (var i = 0 ; i < components.length ;i++) {
|
||||
log(components[i].name);
|
||||
}
|
||||
log("Select components");
|
||||
function trim(str) {
|
||||
return str.replace(/^ +/,"").replace(/ *$/,"");
|
||||
}
|
||||
var widget = gui.currentPageWidget();
|
||||
widget.deselectAll();
|
||||
var packages = trim("$SELECTEDPACKAGES").split(",");
|
||||
if (packages.length > 0 && packages[0] !== "") {
|
||||
|
||||
for (var i in packages) {
|
||||
var pkg = trim(packages[i]);
|
||||
for (var i = 0 ; i < components.length ;i++) {
|
||||
if(components[i].name.indexOf(pkg) != -1)
|
||||
{
|
||||
log("Select " + components[i].name);
|
||||
widget.selectComponent(trim(components[i].name));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log("Use default component list");
|
||||
}
|
||||
|
||||
gui.clickButton(buttons.NextButton);
|
||||
}
|
||||
|
||||
Controller.prototype.IntroductionPageCallback = function() {
|
||||
gui.clickButton(buttons.NextButton);
|
||||
}
|
||||
|
||||
|
||||
Controller.prototype.TargetDirectoryPageCallback = function() {
|
||||
var widget = gui.currentPageWidget();
|
||||
|
||||
if (widget != null) {
|
||||
widget.TargetDirectoryLineEdit.setText("$OUTPUT");
|
||||
}
|
||||
|
||||
gui.clickButton(buttons.NextButton);
|
||||
|
||||
}
|
||||
|
||||
Controller.prototype.LicenseAgreementPageCallback = function() {
|
||||
var widget = gui.currentPageWidget();
|
||||
|
||||
if (widget != null) {
|
||||
widget.AcceptLicenseRadioButton.setChecked(true);
|
||||
}
|
||||
|
||||
gui.clickButton(buttons.NextButton);
|
||||
}
|
||||
|
||||
Controller.prototype.StartMenuDirectoryPageCallback = function() {
|
||||
gui.clickButton(buttons.CommitButton);
|
||||
}
|
||||
|
||||
Controller.prototype.ReadyForInstallationPageCallback = function() {
|
||||
gui.clickButton(buttons.CommitButton);
|
||||
}
|
||||
|
||||
Controller.prototype.FinishedPageCallback = function() {
|
||||
var widget = gui.currentPageWidget();
|
||||
widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false);
|
||||
gui.clickButton(buttons.FinishButton);
|
||||
}
|
||||
EOF
|
||||
|
||||
chmod u+x $1
|
||||
|
||||
$1 -v --script $SCRIPT
|
||||
|
@ -1,6 +1,6 @@
|
||||
QT += qml quick
|
||||
|
||||
CONFIG += c++11 qzxing_qml
|
||||
CONFIG += qzxing_qml
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Add more folders to ship with the application, here
|
||||
DEPLOYMENTFOLDERS = folder_01
|
||||
folder_01.source = qml/QZXingDragNDropTest
|
||||
folder_01.target = qml
|
||||
DEPLOYMENTFOLDERS = folder_01
|
||||
|
||||
QT += widgets
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += c++11 qzxing_multimedia
|
||||
CONFIG += qzxing_multimedia
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
CONFIG+=qml_debug
|
||||
|
@ -1,15 +1,17 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
classpath 'com.android.tools.build:gradle:3.2.0'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
@ -18,8 +20,8 @@ apply plugin: 'com.android.application'
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:25.0.1'
|
||||
compile 'com.android.support:design:25.0.1'
|
||||
compile 'com.android.support:appcompat-v7:28.0.0'
|
||||
compile 'com.android.support:design:28.0.0'
|
||||
}
|
||||
|
||||
android {
|
||||
|
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
#Sun Jan 29 12:19:44 EET 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
//values based on http://entropymine.com/imageworsener/grayscale/
|
||||
//round(0,2127*R)
|
||||
const byte CameraImageWrapper::R_TO_GREYSCALE[256] = {
|
||||
const zxing::byte CameraImageWrapper::R_TO_GREYSCALE[256] = {
|
||||
0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9,
|
||||
10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13,
|
||||
@ -22,7 +22,7 @@ const byte CameraImageWrapper::R_TO_GREYSCALE[256] = {
|
||||
|
||||
//values based on http://entropymine.com/imageworsener/grayscale/
|
||||
//round(0,7152*G)
|
||||
const byte CameraImageWrapper::G_TO_GREYSCALE[256] = {
|
||||
const zxing::byte CameraImageWrapper::G_TO_GREYSCALE[256] = {
|
||||
0, 1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 11, 12, 13,
|
||||
14, 14, 15, 16, 16, 17, 18, 19, 19, 20, 21, 21, 22, 23, 24, 24,
|
||||
25, 26, 26, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35,
|
||||
@ -44,7 +44,7 @@ const byte CameraImageWrapper::G_TO_GREYSCALE[256] = {
|
||||
|
||||
//values based on http://entropymine.com/imageworsener/grayscale/
|
||||
//round(0,0722*B)
|
||||
const byte CameraImageWrapper::B_TO_GREYSCALE[256] = {
|
||||
const zxing::byte CameraImageWrapper::B_TO_GREYSCALE[256] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
@ -101,12 +101,12 @@ CameraImageWrapper *CameraImageWrapper::Factory(const QImage &sourceImage, int m
|
||||
return new CameraImageWrapper(sourceImage);
|
||||
}
|
||||
|
||||
ArrayRef<ArrayRef<byte> > CameraImageWrapper::getOriginalImage()
|
||||
ArrayRef<ArrayRef<zxing::byte> > CameraImageWrapper::getOriginalImage()
|
||||
{
|
||||
return imageBytesPerRow;
|
||||
}
|
||||
|
||||
ArrayRef<byte> CameraImageWrapper::getRow(int y, ArrayRef<byte> row) const
|
||||
ArrayRef<zxing::byte> CameraImageWrapper::getRow(int y, ArrayRef<zxing::byte> row) const
|
||||
{
|
||||
if(delegate)
|
||||
return delegate->getRow(y, row);
|
||||
@ -114,7 +114,7 @@ ArrayRef<byte> CameraImageWrapper::getRow(int y, ArrayRef<byte> row) const
|
||||
return getRowP(y, row);
|
||||
}
|
||||
|
||||
ArrayRef<byte> CameraImageWrapper::getMatrix() const
|
||||
ArrayRef<zxing::byte> CameraImageWrapper::getMatrix() const
|
||||
{
|
||||
if(delegate)
|
||||
return delegate->getMatrix();
|
||||
@ -162,24 +162,24 @@ Ref<LuminanceSource> CameraImageWrapper::rotateCounterClockwise() const
|
||||
return LuminanceSource::rotateCounterClockwise();
|
||||
}
|
||||
|
||||
ArrayRef<byte> CameraImageWrapper::getRowP(int y, ArrayRef<byte> row) const
|
||||
ArrayRef<zxing::byte> CameraImageWrapper::getRowP(int y, ArrayRef<zxing::byte> row) const
|
||||
{
|
||||
int width = getWidth();
|
||||
|
||||
if (row->size() != width)
|
||||
row.reset(ArrayRef<byte>(width));
|
||||
row.reset(ArrayRef<zxing::byte>(width));
|
||||
|
||||
Q_ASSERT(y >= 0 && y < getHeight());
|
||||
|
||||
return imageBytesPerRow[y];
|
||||
}
|
||||
|
||||
ArrayRef<byte> CameraImageWrapper::getMatrixP() const
|
||||
ArrayRef<zxing::byte> CameraImageWrapper::getMatrixP() const
|
||||
{
|
||||
return imageBytes;
|
||||
}
|
||||
|
||||
byte CameraImageWrapper::gray(unsigned int r, unsigned int g, unsigned int b)
|
||||
zxing::byte CameraImageWrapper::gray(unsigned int r, unsigned int g, unsigned int b)
|
||||
{
|
||||
//the values are not masked with (x & 0xFF) because functions qRed, qGreen, qBlue already do it
|
||||
return R_TO_GREYSCALE[r] + G_TO_GREYSCALE[g] + B_TO_GREYSCALE[b];
|
||||
@ -190,18 +190,18 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin)
|
||||
bool needsConvesionToGrayscale = origin.format() != QImage::Format_Grayscale8;
|
||||
|
||||
QRgb pixel;
|
||||
byte pixelGrayscale;
|
||||
zxing::byte pixelGrayscale;
|
||||
|
||||
const int width = getWidth();
|
||||
const int height = getHeight();
|
||||
|
||||
imageBytes = ArrayRef<byte>(height*width);
|
||||
imageBytesPerRow = ArrayRef<ArrayRef<byte>>(height);
|
||||
byte* m = &imageBytes[0];
|
||||
imageBytes = ArrayRef<zxing::byte>(height*width);
|
||||
imageBytesPerRow = ArrayRef<ArrayRef<zxing::byte>>(height);
|
||||
zxing::byte* m = &imageBytes[0];
|
||||
|
||||
for(int j=0; j<height; j++)
|
||||
{
|
||||
ArrayRef<byte> line(width);
|
||||
ArrayRef<zxing::byte> line(width);
|
||||
for(int i=0; i<width; i++)
|
||||
{
|
||||
pixel = origin.pixel(i,j);
|
||||
@ -218,7 +218,7 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin)
|
||||
#else
|
||||
memcpy(m, &line[0], width);
|
||||
#endif
|
||||
m += width * sizeof(byte);
|
||||
m += width * sizeof(zxing::byte);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
|
||||
static CameraImageWrapper* Factory(const QImage& image, int maxWidth=-1, int maxHeight=-1, bool smoothTransformation=false);
|
||||
|
||||
ArrayRef<ArrayRef<byte> > getOriginalImage();
|
||||
ArrayRef<ArrayRef<zxing::byte> > getOriginalImage();
|
||||
Ref<GreyscaleLuminanceSource> getDelegate() { return delegate; }
|
||||
|
||||
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
|
||||
@ -45,7 +45,7 @@ public:
|
||||
Ref<LuminanceSource> invert() const;
|
||||
Ref<LuminanceSource> rotateCounterClockwise() const;
|
||||
|
||||
inline byte gray(unsigned int r, unsigned int g, unsigned int b);
|
||||
inline zxing::byte gray(unsigned int r, unsigned int g, unsigned int b);
|
||||
|
||||
private:
|
||||
ArrayRef<zxing::byte> getRowP(int y, ArrayRef<zxing::byte> row) const;
|
||||
@ -53,12 +53,12 @@ private:
|
||||
void updateImageAsGrayscale(const QImage &origin);
|
||||
|
||||
Ref<GreyscaleLuminanceSource> delegate;
|
||||
ArrayRef<ArrayRef<byte>> imageBytesPerRow;
|
||||
ArrayRef<byte> imageBytes;
|
||||
ArrayRef<ArrayRef<zxing::byte>> imageBytesPerRow;
|
||||
ArrayRef<zxing::byte> imageBytes;
|
||||
|
||||
static const byte B_TO_GREYSCALE[256];
|
||||
static const byte G_TO_GREYSCALE[256];
|
||||
static const byte R_TO_GREYSCALE[256];
|
||||
static const zxing::byte B_TO_GREYSCALE[256];
|
||||
static const zxing::byte G_TO_GREYSCALE[256];
|
||||
static const zxing::byte R_TO_GREYSCALE[256];
|
||||
};
|
||||
|
||||
#endif //CAMERAIMAGE_H
|
||||
|
@ -29,7 +29,7 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY,
|
||||
QQuickItem *item = qobject_cast<QQuickItem *>(imageObj);
|
||||
|
||||
if (!item || !item->window()->isVisible()) {
|
||||
qDebug() << "Item is NULL";
|
||||
qWarning() << "ImageHandler: item is NULL";
|
||||
return QImage();
|
||||
}
|
||||
|
||||
@ -52,11 +52,11 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY,
|
||||
QThread::yieldCurrentThread();
|
||||
}
|
||||
img = result->image();
|
||||
#else
|
||||
#else // QT_VERSION >= 0x050000
|
||||
QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);
|
||||
|
||||
if (!item) {
|
||||
qDebug() << "Item is NULL";
|
||||
qWarning() << "ImageHandler: item is NULL";
|
||||
return QImage();
|
||||
}
|
||||
|
||||
@ -65,8 +65,10 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY,
|
||||
QPainter painter(&img);
|
||||
QStyleOptionGraphicsItem styleOption;
|
||||
item->paint(&painter, &styleOption);
|
||||
#endif
|
||||
#endif //defined(QZXING_QML)
|
||||
#endif // QT_VERSION >= 0x050000
|
||||
#else // defined(QZXING_QML)
|
||||
Q_UNUSED(imageObj);
|
||||
#endif // defined(QZXING_QML)
|
||||
|
||||
if (offsetX < 0)
|
||||
offsetX = 0;
|
||||
|
147
src/QZXing.cpp
147
src/QZXing.cpp
@ -5,6 +5,7 @@
|
||||
#include <zxing/BinaryBitmap.h>
|
||||
#include <zxing/MultiFormatReader.h>
|
||||
#include <zxing/DecodeHints.h>
|
||||
#include <zxing/ResultMetadata.h>
|
||||
#include "CameraImageWrapper.h"
|
||||
#include "ImageHandler.h"
|
||||
#include <QTime>
|
||||
@ -37,7 +38,7 @@
|
||||
|
||||
using namespace zxing;
|
||||
|
||||
QZXing::QZXing(QObject *parent) : QObject(parent), tryHarder_(false)
|
||||
QZXing::QZXing(QObject *parent) : QObject(parent), tryHarder_(false), lastDecodeOperationSucceded_(false)
|
||||
{
|
||||
decoder = new MultiFormatReader();
|
||||
setDecoder(DecoderFormat_QR_CODE |
|
||||
@ -69,7 +70,7 @@ QZXing::~QZXing()
|
||||
delete decoder;
|
||||
}
|
||||
|
||||
QZXing::QZXing(QZXing::DecoderFormat decodeHints, QObject *parent) : QObject(parent)
|
||||
QZXing::QZXing(QZXing::DecoderFormat decodeHints, QObject *parent) : QObject(parent), lastDecodeOperationSucceded_(false)
|
||||
{
|
||||
decoder = new MultiFormatReader();
|
||||
imageHandler = new ImageHandler();
|
||||
@ -109,6 +110,25 @@ bool QZXing::getTryHarder()
|
||||
{
|
||||
return tryHarder_;
|
||||
}
|
||||
void QZXing::setAllowedExtensions(const QVariantList& extensions)
|
||||
{
|
||||
std::set<int> allowedExtensions;
|
||||
for (const QVariant& extension: extensions) {
|
||||
allowedExtensions.insert(extension.toInt());
|
||||
}
|
||||
|
||||
allowedExtensions_ = allowedExtensions;
|
||||
}
|
||||
|
||||
QVariantList QZXing::getAllowedExtensions()
|
||||
{
|
||||
QVariantList allowedExtensions;
|
||||
for (const int& extension: allowedExtensions_) {
|
||||
allowedExtensions << extension;
|
||||
}
|
||||
|
||||
return allowedExtensions;
|
||||
}
|
||||
|
||||
QString QZXing::decoderFormatToString(int fmt)
|
||||
{
|
||||
@ -180,6 +200,42 @@ QString QZXing::charSet() const
|
||||
return charSet_;
|
||||
}
|
||||
|
||||
bool QZXing::getLastDecodeOperationSucceded()
|
||||
{
|
||||
return lastDecodeOperationSucceded_;
|
||||
}
|
||||
|
||||
QVariantMap QZXing::metadataToMap(const ResultMetadata &metadata)
|
||||
{
|
||||
QVariantMap obj;
|
||||
for (const ResultMetadata::Key &key: metadata.keys()) {
|
||||
QString keyName = QString::fromStdString(metadata.keyToString(key));
|
||||
|
||||
switch (key) {
|
||||
case ResultMetadata::ORIENTATION:
|
||||
case ResultMetadata::ISSUE_NUMBER:
|
||||
case ResultMetadata::STRUCTURED_APPEND_SEQUENCE:
|
||||
case ResultMetadata::STRUCTURED_APPEND_CODE_COUNT:
|
||||
case ResultMetadata::STRUCTURED_APPEND_PARITY:
|
||||
obj[keyName] = QVariant(metadata.getInt(key));
|
||||
break;
|
||||
case ResultMetadata::ERROR_CORRECTION_LEVEL:
|
||||
case ResultMetadata::SUGGESTED_PRICE:
|
||||
case ResultMetadata::POSSIBLE_COUNTRY:
|
||||
case ResultMetadata::UPC_EAN_EXTENSION:
|
||||
obj[keyName] = QVariant(metadata.getString(key).c_str());
|
||||
break;
|
||||
|
||||
case ResultMetadata::OTHER:
|
||||
case ResultMetadata::PDF417_EXTRA_METADATA:
|
||||
case ResultMetadata::BYTE_SEGMENTS:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void QZXing::setDecoder(const uint &hint)
|
||||
{
|
||||
unsigned int newHints = 0;
|
||||
@ -258,31 +314,31 @@ QRectF getTagRect(const ArrayRef<Ref<ResultPoint> > &resultPoints, const Ref<Bit
|
||||
{
|
||||
if (resultPoints->size() < 2)
|
||||
return QRectF();
|
||||
|
||||
|
||||
int matrixWidth = bitMatrix->getWidth();
|
||||
int matrixHeight = bitMatrix->getHeight();
|
||||
// 1D barcode
|
||||
if (resultPoints->size() == 2) {
|
||||
WhiteRectangleDetector detector(bitMatrix);
|
||||
std::vector<Ref<ResultPoint> > resultRectPoints = detector.detect();
|
||||
|
||||
|
||||
if (resultRectPoints.size() != 4)
|
||||
return QRectF();
|
||||
|
||||
qreal xMin = resultPoints[0]->getX();
|
||||
qreal xMin = qreal(resultPoints[0]->getX());
|
||||
qreal xMax = xMin;
|
||||
for (unsigned int i = 1; i < resultPoints->size(); ++i) {
|
||||
qreal x = resultPoints[i]->getX();
|
||||
for (int i = 1; i < resultPoints->size(); ++i) {
|
||||
qreal x = qreal(resultPoints[i]->getX());
|
||||
if (x < xMin)
|
||||
xMin = x;
|
||||
if (x > xMax)
|
||||
xMax = x;
|
||||
}
|
||||
|
||||
qreal yMin = resultRectPoints[0]->getY();
|
||||
qreal yMin = qreal(resultRectPoints[0]->getY());
|
||||
qreal yMax = yMin;
|
||||
for (unsigned int i = 1; i < resultRectPoints.size(); ++i) {
|
||||
qreal y = resultRectPoints[i]->getY();
|
||||
qreal y = qreal(resultRectPoints[i]->getY());
|
||||
if (y < yMin)
|
||||
yMin = y;
|
||||
if (y > yMax)
|
||||
@ -294,13 +350,13 @@ QRectF getTagRect(const ArrayRef<Ref<ResultPoint> > &resultPoints, const Ref<Bit
|
||||
|
||||
// 2D QR code
|
||||
if (resultPoints->size() == 4) {
|
||||
qreal xMin = resultPoints[0]->getX();
|
||||
qreal xMin = qreal(resultPoints[0]->getX());
|
||||
qreal xMax = xMin;
|
||||
qreal yMin = resultPoints[0]->getY();
|
||||
qreal yMin = qreal(resultPoints[0]->getY());
|
||||
qreal yMax = yMin;
|
||||
for (unsigned int i = 1; i < resultPoints->size(); ++i) {
|
||||
qreal x = resultPoints[i]->getX();
|
||||
qreal y = resultPoints[i]->getY();
|
||||
for (int i = 1; i < resultPoints->size(); ++i) {
|
||||
qreal x = qreal(resultPoints[i]->getX());
|
||||
qreal y = qreal(resultPoints[i]->getY());
|
||||
if (x < xMin)
|
||||
xMin = x;
|
||||
if (x > xMax)
|
||||
@ -321,6 +377,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
||||
{
|
||||
QTime t;
|
||||
t.start();
|
||||
processingTime = -1;
|
||||
Ref<Result> res;
|
||||
emit decodingStarted();
|
||||
|
||||
@ -331,7 +388,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
||||
return "";
|
||||
}
|
||||
|
||||
CameraImageWrapper *ciw = NULL;
|
||||
CameraImageWrapper *ciw = ZXING_NULLPTR;
|
||||
|
||||
if ((maxWidth > 0) || (maxHeight > 0))
|
||||
ciw = CameraImageWrapper::Factory(image, maxWidth, maxHeight, smoothTransformation);
|
||||
@ -344,40 +401,59 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
||||
Ref<GlobalHistogramBinarizer> binz( new GlobalHistogramBinarizer(imageRef) );
|
||||
Ref<BinaryBitmap> bb( new BinaryBitmap(binz) );
|
||||
|
||||
DecodeHints hints((int)enabledDecoders);
|
||||
DecodeHints hints(static_cast<DecodeHintType>(enabledDecoders));
|
||||
|
||||
bool hasSucceded = false;
|
||||
if (hints.containsFormat(BarcodeFormat::UPC_EAN_EXTENSION)) {
|
||||
hints.setAllowedEanExtensions(allowedExtensions_);
|
||||
}
|
||||
|
||||
lastDecodeOperationSucceded_ = false;
|
||||
try {
|
||||
res = decoder->decode(bb, hints);
|
||||
hasSucceded = true;
|
||||
}catch(zxing::Exception &e){}
|
||||
processingTime = t.elapsed();
|
||||
lastDecodeOperationSucceded_ = true;
|
||||
} catch(zxing::Exception &/*e*/){}
|
||||
|
||||
if(!hasSucceded)
|
||||
if(!lastDecodeOperationSucceded_)
|
||||
{
|
||||
hints.setTryHarder(true);
|
||||
|
||||
try {
|
||||
res = decoder->decode(bb, hints);
|
||||
hasSucceded = true;
|
||||
} catch(zxing::Exception &e) {}
|
||||
processingTime = t.elapsed();
|
||||
lastDecodeOperationSucceded_ = true;
|
||||
} catch(zxing::Exception &/*e*/) {}
|
||||
|
||||
if (!lastDecodeOperationSucceded_ &&
|
||||
hints.containsFormat(BarcodeFormat::UPC_EAN_EXTENSION) &&
|
||||
!allowedExtensions_.empty() &&
|
||||
!(hints & DecodeHints::PRODUCT_HINT).isEmpty() ) {
|
||||
hints.setAllowedEanExtensions(std::set<int>());
|
||||
|
||||
try {
|
||||
res = decoder->decode(bb, hints);
|
||||
processingTime = t.elapsed();
|
||||
lastDecodeOperationSucceded_ = true;
|
||||
} catch(zxing::Exception &/*e*/) {}
|
||||
}
|
||||
|
||||
if (tryHarder_ && bb->isRotateSupported()) {
|
||||
Ref<BinaryBitmap> bbTmp = bb;
|
||||
|
||||
for (int i=0; (i<3 && !hasSucceded); i++) {
|
||||
for (int i=0; (i<3 && !lastDecodeOperationSucceded_); i++) {
|
||||
Ref<BinaryBitmap> rotatedImage(bbTmp->rotateCounterClockwise());
|
||||
bbTmp = rotatedImage;
|
||||
|
||||
try {
|
||||
res = decoder->decode(rotatedImage, hints);
|
||||
processingTime = t.elapsed();
|
||||
hasSucceded = true;
|
||||
} catch(zxing::Exception &e) {}
|
||||
lastDecodeOperationSucceded_ = true;
|
||||
} catch(zxing::Exception &/*e*/) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSucceded) {
|
||||
if (lastDecodeOperationSucceded_) {
|
||||
QString string = QString(res->getText()->getText().c_str());
|
||||
if (!string.isEmpty() && (string.length() > 0)) {
|
||||
int fmt = res->getBarcodeFormat().value;
|
||||
@ -392,6 +468,9 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
||||
emit tagFound(string);
|
||||
emit tagFoundAdvanced(string, foundedFmt, charSet_);
|
||||
|
||||
QVariantMap metadataMap = metadataToMap(res->getMetadata());
|
||||
emit tagFoundAdvanced(string, foundedFmt, charSet_, metadataMap);
|
||||
|
||||
try {
|
||||
const QRectF rect = getTagRect(res->getResultPoints(), binz->getBlackMatrix());
|
||||
emit tagFoundAdvanced(string, foundedFmt, charSet_, rect);
|
||||
@ -437,7 +516,7 @@ QString QZXing::decodeSubImageQML(QObject *item,
|
||||
const int offsetX, const int offsetY,
|
||||
const int width, const int height)
|
||||
{
|
||||
if(item == NULL)
|
||||
if(item == ZXING_NULLPTR)
|
||||
{
|
||||
processingTime = 0;
|
||||
emit decodingFinished(false);
|
||||
@ -484,6 +563,11 @@ QString QZXing::decodeSubImageQML(const QUrl &imageUrl,
|
||||
img = img.copy(offsetX, offsetY, width, height);
|
||||
return decodeImage(img);
|
||||
#else
|
||||
Q_UNUSED(imageUrl);
|
||||
Q_UNUSED(offsetX);
|
||||
Q_UNUSED(offsetY);
|
||||
Q_UNUSED(width);
|
||||
Q_UNUSED(height);
|
||||
return decodeImage(QImage());
|
||||
#endif //QZXING_QML
|
||||
}
|
||||
@ -511,10 +595,10 @@ QImage QZXing::encodeData(const QString& data,
|
||||
|
||||
Ref<qrcode::ByteMatrix> bytesRef = barcode->getMatrix();
|
||||
const std::vector< std::vector <zxing::byte> >& bytes = bytesRef->getArray();
|
||||
image = QImage(bytesRef->getWidth(), bytesRef->getHeight(), QImage::Format_ARGB32);
|
||||
for(int i=0; i<bytesRef->getWidth(); i++)
|
||||
for(int j=0; j<bytesRef->getHeight(); j++)
|
||||
image.setPixel(i, j, bytes[j][i] ?
|
||||
image = QImage(int(bytesRef->getWidth()), int(bytesRef->getHeight()), QImage::Format_ARGB32);
|
||||
for(size_t i=0; i<bytesRef->getWidth(); i++)
|
||||
for(size_t j=0; j<bytesRef->getHeight(); j++)
|
||||
image.setPixel(int(i), int(j), bytes[j][i] ?
|
||||
qRgb(0,0,0) :
|
||||
qRgb(255,255,255));
|
||||
|
||||
@ -522,7 +606,6 @@ QImage QZXing::encodeData(const QString& data,
|
||||
break;
|
||||
}
|
||||
case EncoderFormat_INVALID:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
|
21
src/QZXing.h
21
src/QZXing.h
@ -18,8 +18,13 @@
|
||||
#define QZXING_H
|
||||
|
||||
#include "QZXing_global.h"
|
||||
#include "zxing/ZXing.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QImage>
|
||||
#include <QVariantList>
|
||||
|
||||
#include <set>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
class QQmlEngine;
|
||||
@ -28,6 +33,7 @@
|
||||
// forward declaration
|
||||
namespace zxing {
|
||||
class MultiFormatReader;
|
||||
class ResultMetadata;
|
||||
}
|
||||
class ImageHandler;
|
||||
|
||||
@ -51,6 +57,7 @@ class
|
||||
Q_PROPERTY(int processingTime READ getProcessTimeOfLastDecoding)
|
||||
Q_PROPERTY(uint enabledDecoders READ getEnabledFormats WRITE setDecoder NOTIFY enabledFormatsChanged)
|
||||
Q_PROPERTY(bool tryHarder READ getTryHarder WRITE setTryHarder)
|
||||
Q_PROPERTY(QVariantList allowedExtensions READ getAllowedExtensions WRITE setAllowedExtensions)
|
||||
|
||||
public:
|
||||
/*
|
||||
@ -91,10 +98,10 @@ public:
|
||||
EncodeErrorCorrectionLevel_H
|
||||
};
|
||||
|
||||
QZXing(QObject *parent = NULL);
|
||||
QZXing(QObject *parent = ZXING_NULLPTR);
|
||||
~QZXing();
|
||||
|
||||
QZXing(DecoderFormat decodeHints, QObject *parent = NULL);
|
||||
QZXing(DecoderFormat decodeHints, QObject *parent = ZXING_NULLPTR);
|
||||
|
||||
#ifdef QZXING_QML
|
||||
|
||||
@ -110,10 +117,17 @@ public:
|
||||
|
||||
void setTryHarder(bool tryHarder);
|
||||
bool getTryHarder();
|
||||
void setAllowedExtensions(const QVariantList& extensions);
|
||||
QVariantList getAllowedExtensions();
|
||||
static QString decoderFormatToString(int fmt);
|
||||
Q_INVOKABLE QString foundedFormat() const;
|
||||
Q_INVOKABLE QString charSet() const;
|
||||
|
||||
bool getLastDecodeOperationSucceded();
|
||||
|
||||
private:
|
||||
QVariantMap metadataToMap(const zxing::ResultMetadata& metadata);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* The decoding function. Will try to decode the given image based on the enabled decoders.
|
||||
@ -196,6 +210,7 @@ signals:
|
||||
void tagFound(QString tag);
|
||||
void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet) const;
|
||||
void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet, const QRectF &rect) const;
|
||||
void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet, const QVariantMap &metadata) const;
|
||||
void error(QString msg);
|
||||
|
||||
private:
|
||||
@ -206,6 +221,8 @@ private:
|
||||
QString foundedFmt;
|
||||
QString charSet_;
|
||||
bool tryHarder_;
|
||||
bool lastDecodeOperationSucceded_;
|
||||
std::set<int> allowedExtensions_;
|
||||
|
||||
/**
|
||||
* If true, the decoding operation will take place at a different thread.
|
||||
|
@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
CONFIG += qt
|
||||
CONFIG += qt warn_on
|
||||
|
||||
DEFINES += QZXING_LIBRARY \
|
||||
ZXING_ICONV_CONST \
|
||||
@ -34,6 +34,7 @@ HEADERS += $$PWD/QZXing_global.h \
|
||||
$$PWD/zxing/zxing/ResultPointCallback.h \
|
||||
$$PWD/zxing/zxing/ResultPoint.h \
|
||||
$$PWD/zxing/zxing/Result.h \
|
||||
$$PWD/zxing/zxing/ResultMetadata.h \
|
||||
$$PWD/zxing/zxing/ReaderException.h \
|
||||
$$PWD/zxing/zxing/Reader.h \
|
||||
$$PWD/zxing/zxing/NotFoundException.h \
|
||||
@ -75,6 +76,7 @@ HEADERS += $$PWD/QZXing_global.h \
|
||||
$$PWD/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h \
|
||||
$$PWD/zxing/zxing/common/reedsolomon/GenericGFPoly.h \
|
||||
$$PWD/zxing/zxing/common/reedsolomon/GenericGF.h \
|
||||
$$PWD/zxing/zxing/common/ByteArray.h \
|
||||
$$PWD/zxing/zxing/datamatrix/Version.h \
|
||||
$$PWD/zxing/zxing/datamatrix/DataMatrixReader.h \
|
||||
$$PWD/zxing/zxing/datamatrix/decoder/Decoder.h \
|
||||
@ -86,6 +88,9 @@ HEADERS += $$PWD/QZXing_global.h \
|
||||
$$PWD/zxing/zxing/datamatrix/detector/CornerPoint.h \
|
||||
$$PWD/zxing/zxing/oned/UPCEReader.h \
|
||||
$$PWD/zxing/zxing/oned/UPCEANReader.h \
|
||||
$$PWD/zxing/zxing/oned/UPCEANExtensionSupport.h \
|
||||
$$PWD/zxing/zxing/oned/UPCEANExtension2Support.h \
|
||||
$$PWD/zxing/zxing/oned/UPCEANExtension5Support.h \
|
||||
$$PWD/zxing/zxing/oned/UPCAReader.h \
|
||||
$$PWD/zxing/zxing/oned/OneDResultPoint.h \
|
||||
$$PWD/zxing/zxing/oned/OneDReader.h \
|
||||
@ -94,10 +99,40 @@ HEADERS += $$PWD/QZXing_global.h \
|
||||
$$PWD/zxing/zxing/oned/ITFReader.h \
|
||||
$$PWD/zxing/zxing/oned/EAN13Reader.h \
|
||||
$$PWD/zxing/zxing/oned/EAN8Reader.h \
|
||||
$$PWD/zxing/zxing/oned/EANManufacturerOrgSupport.h \
|
||||
$$PWD/zxing/zxing/oned/Code128Reader.h \
|
||||
$$PWD/zxing/zxing/oned/Code39Reader.h \
|
||||
$$PWD/zxing/zxing/oned/CodaBarReader.h \
|
||||
$$PWD/zxing/zxing/oned/Code93Reader.h \
|
||||
$$PWD/zxing/zxing/oned/rss/AbstractRSSReader.h \
|
||||
$$PWD/zxing/zxing/oned/rss/DataCharacter.h \
|
||||
$$PWD/zxing/zxing/oned/rss/FinderPattern.h \
|
||||
$$PWD/zxing/zxing/oned/rss/Pair.h \
|
||||
$$PWD/zxing/zxing/oned/rss/RSS14Reader.h \
|
||||
$$PWD/zxing/zxing/oned/rss/RSSUtils.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.h \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h \
|
||||
$$PWD/zxing/zxing/qrcode/Version.h \
|
||||
$$PWD/zxing/zxing/qrcode/QRCodeReader.h \
|
||||
$$PWD/zxing/zxing/qrcode/FormatInformation.h \
|
||||
@ -157,6 +192,7 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
|
||||
$$PWD/zxing/zxing/ResultPointCallback.cpp \
|
||||
$$PWD/zxing/zxing/ResultPoint.cpp \
|
||||
$$PWD/zxing/zxing/Result.cpp \
|
||||
$$PWD/zxing/zxing/ResultMetadata.cpp \
|
||||
$$PWD/zxing/zxing/Reader.cpp \
|
||||
$$PWD/zxing/zxing/MultiFormatReader.cpp \
|
||||
$$PWD/zxing/zxing/LuminanceSource.cpp \
|
||||
@ -166,8 +202,14 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
|
||||
$$PWD/zxing/zxing/BinaryBitmap.cpp \
|
||||
$$PWD/zxing/zxing/Binarizer.cpp \
|
||||
$$PWD/zxing/zxing/BarcodeFormat.cpp \
|
||||
$$PWD/zxing/zxing/ReaderException.cpp \
|
||||
$$PWD/zxing/zxing/IllegalStateException.cpp \
|
||||
$$PWD/zxing/zxing/NotFoundException.cpp \
|
||||
$$PWD/zxing/zxing/UnsupportedEncodingException.cpp \
|
||||
$$PWD/zxing/zxing/WriterException.cpp \
|
||||
$$PWD/zxing/zxing/aztec/AztecReader.cpp \
|
||||
$$PWD/zxing/zxing/aztec/AztecDetectorResult.cpp \
|
||||
$$PWD/zxing/zxing/common/Counted.cpp \
|
||||
$$PWD/zxing/zxing/common/StringUtils.cpp \
|
||||
$$PWD/zxing/zxing/common/Str.cpp \
|
||||
$$PWD/zxing/zxing/common/PerspectiveTransform.cpp \
|
||||
@ -193,6 +235,9 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
|
||||
$$PWD/zxing/zxing/datamatrix/DataMatrixReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/UPCEReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/UPCEANReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/UPCEANExtensionSupport.cpp \
|
||||
$$PWD/zxing/zxing/oned/UPCEANExtension2Support.cpp \
|
||||
$$PWD/zxing/zxing/oned/UPCEANExtension5Support.cpp \
|
||||
$$PWD/zxing/zxing/oned/UPCAReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/OneDResultPoint.cpp \
|
||||
$$PWD/zxing/zxing/oned/OneDReader.cpp \
|
||||
@ -201,10 +246,40 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
|
||||
$$PWD/zxing/zxing/oned/ITFReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/EAN13Reader.cpp \
|
||||
$$PWD/zxing/zxing/oned/EAN8Reader.cpp \
|
||||
$$PWD/zxing/zxing/oned/EANManufacturerOrgSupport.cpp \
|
||||
$$PWD/zxing/zxing/oned/Code128Reader.cpp \
|
||||
$$PWD/zxing/zxing/oned/Code39Reader.cpp \
|
||||
$$PWD/zxing/zxing/oned/CodaBarReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/Code93Reader.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/AbstractRSSReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/DataCharacter.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/FinderPattern.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/Pair.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/RSS14Reader.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/RSSUtils.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp \
|
||||
$$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp \
|
||||
$$PWD/zxing/zxing/qrcode/QRCodeReader.cpp \
|
||||
$$PWD/zxing/zxing/multi/MultipleBarcodeReader.cpp \
|
||||
$$PWD/zxing/zxing/multi/GenericMultipleBarcodeReader.cpp \
|
||||
|
@ -66,5 +66,3 @@ OTHER_FILES += \
|
||||
qtc_packaging/debian_fremantle/control \
|
||||
qtc_packaging/debian_fremantle/compat \
|
||||
qtc_packaging/debian_fremantle/changelog
|
||||
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "zxing/ZXing.h"
|
||||
#include "QZXingFilter.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -14,19 +15,33 @@ namespace {
|
||||
}
|
||||
uchar yuvToGray(uchar Y, uchar U, uchar V)
|
||||
{
|
||||
const int C = (int) Y - 16;
|
||||
const int D = (int) U - 128;
|
||||
const int E = (int) V - 128;
|
||||
const int C = int(Y) - 16;
|
||||
const int D = int(U) - 128;
|
||||
const int E = int(V) - 128;
|
||||
return gray(
|
||||
qBound(0, (298 * C + 409 * E + 128) >> 8, 255),
|
||||
qBound(0, (298 * C - 100 * D - 208 * E + 128) >> 8, 255),
|
||||
qBound(0, (298 * C + 516 * D + 128) >> 8, 255)
|
||||
qBound(0, ((298 * C + 409 * E + 128) >> 8), 255),
|
||||
qBound(0, ((298 * C - 100 * D - 208 * E + 128) >> 8), 255),
|
||||
qBound(0, ((298 * C + 516 * D + 128) >> 8), 255)
|
||||
);
|
||||
}
|
||||
|
||||
uchar yuvToGray2(uchar y, uchar u, uchar v)
|
||||
{
|
||||
double rD = y + 1.4075 * (v - 128);
|
||||
double gD = y - 0.3455 * (u - 128) - (0.7169 * (v - 128));
|
||||
double bD = y + 1.7790 * (u - 128);
|
||||
|
||||
return gray(
|
||||
qBound<uchar>(0, (uchar)::floor(rD), 255),
|
||||
qBound<uchar>(0, (uchar)::floor(gD), 255),
|
||||
qBound<uchar>(0, (uchar)::floor(bD), 255)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
QZXingFilter::QZXingFilter(QObject *parent)
|
||||
: QAbstractVideoFilter(parent)
|
||||
, decoder(QZXing::DecoderFormat_QR_CODE)
|
||||
, decoding(false)
|
||||
{
|
||||
/// Connecting signals to handlers that will send signals to QML
|
||||
@ -68,14 +83,14 @@ QVideoFilterRunnable * QZXingFilter::createFilterRunnable()
|
||||
///
|
||||
|
||||
QZXingFilterRunnable::QZXingFilterRunnable(QZXingFilter * filter)
|
||||
: QObject(nullptr)
|
||||
: QObject(ZXING_NULLPTR)
|
||||
, filter(filter)
|
||||
{
|
||||
|
||||
}
|
||||
QZXingFilterRunnable::~QZXingFilterRunnable()
|
||||
{
|
||||
filter = nullptr;
|
||||
filter = ZXING_NULLPTR;
|
||||
}
|
||||
|
||||
QVideoFrame QZXingFilterRunnable::run(QVideoFrame * input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags)
|
||||
@ -133,6 +148,8 @@ struct CaptureRect
|
||||
{}
|
||||
|
||||
bool isValid;
|
||||
char pad[3]; // avoid warning about padding
|
||||
|
||||
int sourceWidth;
|
||||
int sourceHeight;
|
||||
|
||||
@ -172,9 +189,9 @@ static QImage* rgbDataToGrayscale(const uchar* data, const CaptureRect& captureR
|
||||
uchar b = data[blue];
|
||||
if (isPremultiplied) {
|
||||
uchar a = data[alpha];
|
||||
r = (uint(r) * 255) / a;
|
||||
g = (uint(g) * 255) / a;
|
||||
b = (uint(b) * 255) / a;
|
||||
r = uchar((uint(r) * 255) / a);
|
||||
g = uchar((uint(g) * 255) / a);
|
||||
b = uchar((uint(b) * 255) / a);
|
||||
}
|
||||
*pixel = gray(r, g, b);
|
||||
++pixel;
|
||||
@ -188,23 +205,29 @@ static QImage* rgbDataToGrayscale(const uchar* data, const CaptureRect& captureR
|
||||
|
||||
void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame, const QRect& _captureRect)
|
||||
{
|
||||
if (videoFrame.data.length() < 1) {
|
||||
qDebug() << "QZXingFilterRunnable: Buffer is empty";
|
||||
filter->decoding = false;
|
||||
return;
|
||||
}
|
||||
|
||||
static unsigned int i = 0; i++;
|
||||
// qDebug() << "Future: Going to process frame: " << i;
|
||||
|
||||
const int width = videoFrame.size.width();
|
||||
const int height = videoFrame.size.height();
|
||||
const CaptureRect captureRect(_captureRect, width, height);
|
||||
const uchar* data = (uchar*) videoFrame.data.constData();
|
||||
const uchar* data = reinterpret_cast<const uchar *>(videoFrame.data.constData());
|
||||
|
||||
uchar* pixel;
|
||||
int wh;
|
||||
int w_2;
|
||||
int wh_54;
|
||||
|
||||
uint32_t *yuvPtr = (uint32_t *)data;
|
||||
const uint32_t *yuvPtr = reinterpret_cast<const uint32_t *>(data);
|
||||
|
||||
/// Create QImage from QVideoFrame.
|
||||
QImage *image_ptr = nullptr;
|
||||
QImage *image_ptr = ZXING_NULLPTR;
|
||||
|
||||
switch (videoFrame.pixelFormat) {
|
||||
case QVideoFrame::Format_RGB32:
|
||||
@ -223,6 +246,9 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame
|
||||
image_ptr = rgbDataToGrayscale(data, captureRect, 3, 2, 1, 0, true);
|
||||
break;
|
||||
case QVideoFrame::Format_BGR32:
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
|
||||
case QVideoFrame::Format_ABGR32:
|
||||
#endif
|
||||
image_ptr = rgbDataToGrayscale(data, captureRect, 3, 2, 1, 0);
|
||||
break;
|
||||
case QVideoFrame::Format_BGR24:
|
||||
@ -237,28 +263,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame
|
||||
image_ptr = new QImage(data, width, height, QImage::Format_RGB16);
|
||||
break;
|
||||
case QVideoFrame::Format_YUV420P:
|
||||
//fix for issues #4 and #9
|
||||
image_ptr = new QImage(captureRect.targetWidth, captureRect.targetHeight, QImage::Format_Grayscale8);
|
||||
pixel = image_ptr->bits();
|
||||
wh = width * height;
|
||||
w_2 = width / 2;
|
||||
wh_54 = wh * 5 / 4;
|
||||
|
||||
for (int y = captureRect.startY; y < captureRect.endY; y++) {
|
||||
const int Y_offset = y * width;
|
||||
const int y_2 = y / 2;
|
||||
const int U_offset = y_2 * w_2 + wh;
|
||||
const int V_offset = y_2 * w_2 + wh_54;
|
||||
for (int x = captureRect.startX; x < captureRect.endX; x++) {
|
||||
const int x_2 = x / 2;
|
||||
const uchar Y = data[Y_offset + x];
|
||||
const uchar U = data[U_offset + x_2];
|
||||
const uchar V = data[V_offset + x_2];
|
||||
*pixel = yuvToGray(Y, U, V);
|
||||
++pixel;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QVideoFrame::Format_NV12:
|
||||
/// nv12 format, encountered on macOS
|
||||
image_ptr = new QImage(captureRect.targetWidth, captureRect.targetHeight, QImage::Format_Grayscale8);
|
||||
@ -281,22 +285,29 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame
|
||||
++pixel;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case QVideoFrame::Format_YUYV:
|
||||
image_ptr = new QImage(captureRect.targetWidth, captureRect.targetHeight, QImage::Format_Grayscale8);
|
||||
pixel = image_ptr->bits();
|
||||
|
||||
for (int y = captureRect.startY; y < captureRect.endY; y++){
|
||||
uint32_t *row = &yuvPtr[y*(width/2)-(width/4)];
|
||||
for (int x = captureRect.startX; x < captureRect.endX; x++){
|
||||
uint32_t pxl = row[x];
|
||||
const int y0 = (unsigned char)((uint8_t *)&pxl)[0];
|
||||
const int u = (unsigned char)((uint8_t *)&pxl)[1];
|
||||
const int v = (unsigned char)((uint8_t *)&pxl)[3];
|
||||
*pixel = yuvToGray(y0, u, v);
|
||||
const uint32_t *row = &yuvPtr[y*(width/2)];
|
||||
int end = captureRect.startX/2 + (captureRect.endX - captureRect.startX)/2;
|
||||
for (int x = captureRect.startX/2; x < end; x++){
|
||||
const uint8_t *pxl = reinterpret_cast<const uint8_t *>(&row[x]);
|
||||
const uint8_t y0 = pxl[0];
|
||||
const uint8_t u = pxl[1];
|
||||
const uint8_t v = pxl[3];
|
||||
const uint8_t y1 = pxl[2];
|
||||
|
||||
*pixel = yuvToGray2(y0, u, v);
|
||||
++pixel;
|
||||
*pixel = yuvToGray2(y1, u, v);
|
||||
++pixel;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
/// TODO: Handle (create QImages from) YUV formats.
|
||||
default:
|
||||
@ -333,6 +344,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame
|
||||
|
||||
QString QZXingFilterRunnable::decode(const QImage &image)
|
||||
{
|
||||
return (filter != nullptr) ?
|
||||
return (filter != ZXING_NULLPTR) ?
|
||||
filter->decoder.decodeImage(image, image.width(), image.height()) : QString();
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ QZXingImageProvider::QZXingImageProvider() : QQuickImageProvider(QQuickImageProv
|
||||
QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
||||
{
|
||||
int slashIndex = id.indexOf('/');
|
||||
if (slashIndex == -1) {
|
||||
if (slashIndex == -1)
|
||||
{
|
||||
qWarning() << "Can't parse url" << id << ". Usage is encode?<format>/<data>";
|
||||
return QImage();
|
||||
}
|
||||
@ -23,15 +24,11 @@ QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const Q
|
||||
return QImage();
|
||||
}
|
||||
|
||||
int customSettingsIndex = id.lastIndexOf('?');
|
||||
|
||||
QString data;
|
||||
QImage result;
|
||||
QString corretionLevel;
|
||||
QString format;
|
||||
QZXing::EncodeErrorCorrectionLevel correctionLevelEnum =
|
||||
QZXing::EncodeErrorCorrectionLevel_L;
|
||||
QZXing::EncoderFormat format = QZXing::EncoderFormat_QR_CODE;
|
||||
QZXing::EncodeErrorCorrectionLevel correctionLevel = QZXing::EncodeErrorCorrectionLevel_L;
|
||||
|
||||
int customSettingsIndex = id.lastIndexOf('?');
|
||||
if(customSettingsIndex >= 0)
|
||||
{
|
||||
int startOfDataIndex = slashIndex + 1;
|
||||
@ -41,37 +38,29 @@ QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const Q
|
||||
// it could not recognize the first key-value pair provided
|
||||
QUrlQuery optionQuery("options?dummy=&" + id.mid(customSettingsIndex + 1));
|
||||
|
||||
corretionLevel = optionQuery.queryItemValue("corretionLevel");
|
||||
format = optionQuery.queryItemValue("format");
|
||||
|
||||
if(corretionLevel == "H")
|
||||
correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_H;
|
||||
else if(corretionLevel == "Q")
|
||||
correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_Q;
|
||||
else if(corretionLevel == "M")
|
||||
correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_M;
|
||||
else if(corretionLevel == "L")
|
||||
correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_L;
|
||||
}
|
||||
|
||||
if(!corretionLevel.isEmpty() || !format.isEmpty())
|
||||
{
|
||||
if(format != "qrcode")
|
||||
{
|
||||
qWarning() << "Format not supported: " << format;
|
||||
return QImage();
|
||||
if (optionQuery.hasQueryItem("format")) {
|
||||
QString formatString = optionQuery.queryItemValue("format");
|
||||
if (formatString != "qrcode") {
|
||||
qWarning() << "Format not supported: " << formatString;
|
||||
return QImage();
|
||||
}
|
||||
}
|
||||
|
||||
result = QZXing::encodeData(data, QZXing::EncoderFormat_QR_CODE,
|
||||
requestedSize,
|
||||
correctionLevelEnum);
|
||||
}
|
||||
else
|
||||
QString correctionLevelString = optionQuery.queryItemValue("corretionLevel");
|
||||
if(correctionLevelString == "H")
|
||||
correctionLevel = QZXing::EncodeErrorCorrectionLevel_H;
|
||||
else if(correctionLevelString == "Q")
|
||||
correctionLevel = QZXing::EncodeErrorCorrectionLevel_Q;
|
||||
else if(correctionLevelString == "M")
|
||||
correctionLevel = QZXing::EncodeErrorCorrectionLevel_M;
|
||||
else if(correctionLevelString == "L")
|
||||
correctionLevel = QZXing::EncodeErrorCorrectionLevel_L;
|
||||
} else
|
||||
{
|
||||
data = id.mid(slashIndex + 1);
|
||||
result = QZXing::encodeData(data);
|
||||
}
|
||||
|
||||
QImage result = QZXing::encodeData(data, format, requestedSize, correctionLevel);
|
||||
*size = result.size();
|
||||
return result;
|
||||
}
|
||||
|
@ -783,7 +783,7 @@ win_iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t
|
||||
if (outbuf != NULL && *outbuf != NULL && cd->to.flush != NULL)
|
||||
{
|
||||
tomode = cd->to.mode;
|
||||
outsize = cd->to.flush(&cd->to, (uchar *)*outbuf, *outbytesleft);
|
||||
outsize = cd->to.flush(&cd->to, (uchar *)*outbuf, (int)*outbytesleft);
|
||||
if (outsize == -1)
|
||||
{
|
||||
if ((cd->to.flags & FLAG_IGNORE) && errno != E2BIG)
|
||||
@ -810,7 +810,7 @@ win_iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t
|
||||
tomode = cd->to.mode;
|
||||
wsize = MB_CHAR_MAX;
|
||||
|
||||
insize = cd->from.mbtowc(&cd->from, (const uchar *)*inbuf, *inbytesleft, wbuf, &wsize);
|
||||
insize = cd->from.mbtowc(&cd->from, (const uchar *)*inbuf, (int)*inbytesleft, wbuf, &wsize);
|
||||
if (insize == -1)
|
||||
{
|
||||
if (cd->to.flags & FLAG_IGNORE)
|
||||
@ -861,7 +861,7 @@ win_iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t
|
||||
}
|
||||
}
|
||||
|
||||
outsize = cd->to.wctomb(&cd->to, wbuf, wsize, (uchar *)*outbuf, *outbytesleft);
|
||||
outsize = cd->to.wctomb(&cd->to, wbuf, wsize, (uchar *)*outbuf, (int)*outbytesleft);
|
||||
if (outsize == -1)
|
||||
{
|
||||
if ((cd->to.flags & FLAG_IGNORE) && errno != E2BIG)
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __BARCODE_FORMAT_H__
|
||||
#define __BARCODE_FORMAT_H__
|
||||
#ifndef ZXING_BARCODE_FORMAT_H
|
||||
#define ZXING_BARCODE_FORMAT_H
|
||||
|
||||
/*
|
||||
* BarcodeFormat.h
|
||||
@ -58,4 +58,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // __BARCODE_FORMAT_H__
|
||||
#endif // ZXING_BARCODE_FORMAT_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __BINARYBITMAP_H__
|
||||
#define __BINARYBITMAP_H__
|
||||
#ifndef ZXING_BINARYBITMAP_H
|
||||
#define ZXING_BINARYBITMAP_H
|
||||
|
||||
/*
|
||||
* BinaryBitmap.h
|
||||
@ -53,4 +53,4 @@ namespace zxing {
|
||||
|
||||
}
|
||||
|
||||
#endif /* BINARYBITMAP_H_ */
|
||||
#endif /* ZXING_BINARYBITMAP_H */
|
||||
|
@ -23,6 +23,6 @@
|
||||
|
||||
using zxing::ChecksumException;
|
||||
|
||||
ChecksumException::ChecksumException() throw() {}
|
||||
ChecksumException::ChecksumException(const char *msg) throw() : ReaderException(msg) {}
|
||||
ChecksumException::~ChecksumException() throw() {}
|
||||
ChecksumException::ChecksumException() ZXING_NOEXCEPT {}
|
||||
ChecksumException::ChecksumException(const char *msg) ZXING_NOEXCEPT : ReaderException(msg) {}
|
||||
ChecksumException::~ChecksumException() ZXING_NOEXCEPT {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
|
||||
#ifndef __CHECKSUM_EXCEPTION_H__
|
||||
#define __NOT_FOUND_EXCEPTION_H__
|
||||
#ifndef ZXING_CHECKSUM_EXCEPTION_H
|
||||
#define ZXING_CHECKSUM_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* Copyright 20011 ZXing authors
|
||||
@ -23,12 +23,11 @@
|
||||
|
||||
namespace zxing {
|
||||
class ChecksumException : public ReaderException {
|
||||
typedef ReaderException Base;
|
||||
public:
|
||||
ChecksumException() throw();
|
||||
ChecksumException(const char *msg) throw();
|
||||
~ChecksumException() throw();
|
||||
ChecksumException() ZXING_NOEXCEPT;
|
||||
ChecksumException(const char *msg) ZXING_NOEXCEPT;
|
||||
~ChecksumException() ZXING_NOEXCEPT;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __CHECKSUM_EXCEPTION_H__
|
||||
#endif // ZXING_CHECKSUM_EXCEPTION_H
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <zxing/DecodeHints.h>
|
||||
#include <zxing/common/IllegalArgumentException.h>
|
||||
#include <qglobal.h>
|
||||
#include <iterator>
|
||||
|
||||
using zxing::Ref;
|
||||
using zxing::ResultPointCallback;
|
||||
@ -77,6 +78,7 @@ const zxing::DecodeHints DecodeHints::DEFAULT_HINT(
|
||||
|
||||
DecodeHints::DecodeHints() {
|
||||
hints = 0;
|
||||
allowedEanExtensions = {};
|
||||
}
|
||||
|
||||
DecodeHints::DecodeHints(const zxing::DecodeHintType &init) {
|
||||
@ -86,6 +88,7 @@ DecodeHints::DecodeHints(const zxing::DecodeHintType &init) {
|
||||
DecodeHints::DecodeHints(const DecodeHints &other) {
|
||||
hints = other.hints;
|
||||
callback = other.callback;
|
||||
allowedEanExtensions = other.allowedEanExtensions;
|
||||
}
|
||||
|
||||
void DecodeHints::addFormat(BarcodeFormat toadd) {
|
||||
@ -150,6 +153,14 @@ bool DecodeHints::getTryHarder() const {
|
||||
return (hints & TRYHARDER_HINT) != 0;
|
||||
}
|
||||
|
||||
void DecodeHints::setAllowedEanExtensions(std::set<int> toset) {
|
||||
allowedEanExtensions = toset;
|
||||
}
|
||||
|
||||
std::set<int> DecodeHints::getAllowedEanExtensions() const {
|
||||
return allowedEanExtensions;
|
||||
}
|
||||
|
||||
void DecodeHints::setResultPointCallback(Ref<ResultPointCallback> const& _callback) {
|
||||
callback = _callback;
|
||||
}
|
||||
@ -162,6 +173,7 @@ zxing::DecodeHints &zxing::DecodeHints::operator =(const zxing::DecodeHints &oth
|
||||
{
|
||||
hints = other.hints;
|
||||
callback = other.callback;
|
||||
allowedEanExtensions = other.allowedEanExtensions;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -171,5 +183,27 @@ zxing::DecodeHints zxing::operator | (DecodeHints const& l, DecodeHints const& r
|
||||
if (!result.callback) {
|
||||
result.callback = r.callback;
|
||||
}
|
||||
|
||||
result.allowedEanExtensions = l.allowedEanExtensions;
|
||||
result.allowedEanExtensions.insert(r.allowedEanExtensions.begin(),
|
||||
r.allowedEanExtensions.end());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
zxing::DecodeHints zxing::operator & (DecodeHints const& l, DecodeHints const& r) {
|
||||
DecodeHints result (l);
|
||||
result.hints &= r.hints;
|
||||
if (!result.callback) {
|
||||
result.callback = r.callback;
|
||||
}
|
||||
|
||||
std::set<int> intersect;
|
||||
std::set_intersection(l.allowedEanExtensions.begin(), l.allowedEanExtensions.end(),
|
||||
r.allowedEanExtensions.begin(), r.allowedEanExtensions.end(),
|
||||
std::inserter(intersect, intersect.begin()));
|
||||
|
||||
result.allowedEanExtensions = intersect;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __DECODEHINTS_H_
|
||||
#define __DECODEHINTS_H_
|
||||
#ifndef ZXING_DECODEHINTS_H
|
||||
#define ZXING_DECODEHINTS_H
|
||||
/*
|
||||
* DecodeHintType.h
|
||||
* zxing
|
||||
@ -23,16 +23,20 @@
|
||||
#include <zxing/BarcodeFormat.h>
|
||||
#include <zxing/ResultPointCallback.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace zxing {
|
||||
|
||||
typedef unsigned int DecodeHintType;
|
||||
class DecodeHints;
|
||||
DecodeHints operator | (DecodeHints const&, DecodeHints const&);
|
||||
DecodeHints operator & (DecodeHints const&, DecodeHints const&);
|
||||
|
||||
class DecodeHints {
|
||||
private:
|
||||
DecodeHintType hints;
|
||||
Ref<ResultPointCallback> callback;
|
||||
std::set<int> allowedEanExtensions;
|
||||
|
||||
public:
|
||||
static const DecodeHintType AZTEC_HINT;
|
||||
@ -75,14 +79,19 @@ class DecodeHints {
|
||||
void setTryHarder(bool toset);
|
||||
bool getTryHarder() const;
|
||||
|
||||
void setAllowedEanExtensions(std::set<int> toset);
|
||||
std::set<int> getAllowedEanExtensions() const;
|
||||
|
||||
void setResultPointCallback(Ref<ResultPointCallback> const&);
|
||||
Ref<ResultPointCallback> getResultPointCallback() const;
|
||||
|
||||
DecodeHints& operator =(DecodeHints const &other);
|
||||
|
||||
friend DecodeHints operator| (DecodeHints const&, DecodeHints const&);
|
||||
friend DecodeHints operator& (DecodeHints const&, DecodeHints const&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_DECODEHINTS_H
|
||||
|
||||
|
@ -26,18 +26,41 @@
|
||||
|
||||
using zxing::Exception;
|
||||
|
||||
Exception::Exception() ZXING_NOEXCEPT
|
||||
: message(ZXING_NULLPTR) {
|
||||
}
|
||||
|
||||
Exception::Exception(const char *msg) ZXING_NOEXCEPT
|
||||
: message(copy(msg)) {
|
||||
}
|
||||
|
||||
Exception::Exception(const zxing::Exception &that) ZXING_NOEXCEPT
|
||||
: std::exception(that),
|
||||
message(copy(that.message)) {
|
||||
}
|
||||
|
||||
Exception::~Exception() ZXING_NOEXCEPT {
|
||||
if(message) {
|
||||
deleteMessage();
|
||||
}
|
||||
}
|
||||
|
||||
const char *Exception::what() const ZXING_NOEXCEPT {
|
||||
return message ? message : "";
|
||||
}
|
||||
|
||||
void Exception::deleteMessage() {
|
||||
delete [] message;
|
||||
delete [] message;
|
||||
}
|
||||
|
||||
char const* Exception::copy(char const* msg) {
|
||||
char* message = 0;
|
||||
if (msg) {
|
||||
int l = strlen(msg)+1;
|
||||
if (l) {
|
||||
message = new char[l];
|
||||
strcpy(message, msg);
|
||||
char* message = ZXING_NULLPTR;
|
||||
if (msg) {
|
||||
size_t l = strlen(msg)+1;
|
||||
if (l) {
|
||||
message = new char[l];
|
||||
strcpy(message, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
return message;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __EXCEPTION_H__
|
||||
#define __EXCEPTION_H__
|
||||
#ifndef ZXING_EXCEPTION_H
|
||||
#define ZXING_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* Exception.h
|
||||
@ -21,6 +21,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <zxing/ZXing.h>
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
@ -31,15 +33,11 @@ private:
|
||||
char const* const message;
|
||||
|
||||
public:
|
||||
Exception() throw() : message(0) {}
|
||||
Exception(const char* msg) throw() : message(copy(msg)) {}
|
||||
Exception(Exception const& that) throw() : std::exception(that), message(copy(that.message)) {}
|
||||
~Exception() throw() {
|
||||
if(message) {
|
||||
deleteMessage();
|
||||
}
|
||||
}
|
||||
char const* what() const throw() {return message ? message : "";}
|
||||
Exception() ZXING_NOEXCEPT;
|
||||
Exception(const char* msg) ZXING_NOEXCEPT;
|
||||
Exception(Exception const& that) ZXING_NOEXCEPT;
|
||||
~Exception() ZXING_NOEXCEPT;
|
||||
char const* what() const ZXING_NOEXCEPT;
|
||||
|
||||
private:
|
||||
static char const* copy(char const*);
|
||||
@ -48,4 +46,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // __EXCEPTION_H__
|
||||
#endif // ZXING_EXCEPTION_H
|
||||
|
@ -29,7 +29,7 @@ FormatException::FormatException(const char *msg) :
|
||||
ReaderException(msg) {
|
||||
}
|
||||
|
||||
FormatException::~FormatException() throw() {
|
||||
FormatException::~FormatException() ZXING_NOEXCEPT {
|
||||
}
|
||||
|
||||
FormatException const&
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __FORMAT_EXCEPTION_H__
|
||||
#define __FORMAT_EXCEPTION_H__
|
||||
#ifndef ZXING_FORMAT_EXCEPTION_H
|
||||
#define ZXING_FORMAT_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* FormatException.h
|
||||
@ -28,10 +28,10 @@ class FormatException : public ReaderException {
|
||||
public:
|
||||
FormatException();
|
||||
FormatException(const char *msg);
|
||||
~FormatException() throw();
|
||||
~FormatException() ZXING_NOEXCEPT;
|
||||
|
||||
static FormatException const& getFormatInstance();
|
||||
};
|
||||
|
||||
}
|
||||
#endif // __FORMAT_EXCEPTION_H__
|
||||
#endif // ZXING_FORMAT_EXCEPTION_H
|
||||
|
30
src/zxing/zxing/IllegalStateException.cpp
Normal file
30
src/zxing/zxing/IllegalStateException.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* IllegalStateException.cpp
|
||||
* zxing
|
||||
*
|
||||
* Created by Alexander Stillich on 05/11/2018.
|
||||
* Copyright 2008 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <zxing/IllegalStateException.h>
|
||||
|
||||
zxing::IllegalStateException::IllegalStateException() ZXING_NOEXCEPT {
|
||||
}
|
||||
|
||||
zxing::IllegalStateException::IllegalStateException(const char *msg) ZXING_NOEXCEPT
|
||||
: ReaderException(msg) {
|
||||
}
|
||||
|
||||
zxing::IllegalStateException::~IllegalStateException() ZXING_NOEXCEPT {
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
|
||||
#ifndef __ILLEGAL_STATE_EXCEPTION_H__
|
||||
#define __ILLEGAL_STATE_EXCEPTION_H__
|
||||
#ifndef ZXING_ILLEGAL_STATE_EXCEPTION_H
|
||||
#define ZXING_ILLEGAL_STATE_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* Copyright 20011 ZXing authors
|
||||
@ -25,11 +25,11 @@ namespace zxing {
|
||||
|
||||
class IllegalStateException : public ReaderException {
|
||||
public:
|
||||
IllegalStateException() throw() {}
|
||||
IllegalStateException(const char *msg) throw() : ReaderException(msg) {}
|
||||
~IllegalStateException() throw() {}
|
||||
IllegalStateException() ZXING_NOEXCEPT;
|
||||
IllegalStateException(const char *msg) ZXING_NOEXCEPT;
|
||||
~IllegalStateException() ZXING_NOEXCEPT;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __ILLEGAL_STATE_EXCEPTION_H__
|
||||
#endif // ZXING_ILLEGAL_STATE_EXCEPTION_H
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <zxing/ZXing.h>
|
||||
#include <zxing/InvertedLuminanceSource.h>
|
||||
|
||||
using zxing::boolean;
|
||||
using zxing::Ref;
|
||||
using zxing::ArrayRef;
|
||||
using zxing::LuminanceSource;
|
||||
@ -28,21 +27,21 @@ namespace zxing {
|
||||
InvertedLuminanceSource::InvertedLuminanceSource(Ref<LuminanceSource> const& delegate_)
|
||||
: Super(delegate_->getWidth(), delegate_->getHeight()), delegate(delegate_) {}
|
||||
|
||||
ArrayRef<byte> InvertedLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
|
||||
ArrayRef<zxing::byte> InvertedLuminanceSource::getRow(int y, ArrayRef<zxing::byte> row) const {
|
||||
row = delegate->getRow(y, row);
|
||||
int width = getWidth();
|
||||
for (int i = 0; i < width; i++) {
|
||||
row[i] = (byte) (255 - (row[i] & 0xFF));
|
||||
row[i] = (zxing::byte) (255 - (row[i] & 0xFF));
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
ArrayRef<byte> InvertedLuminanceSource::getMatrix() const {
|
||||
ArrayRef<byte> matrix = delegate->getMatrix();
|
||||
ArrayRef<zxing::byte> InvertedLuminanceSource::getMatrix() const {
|
||||
ArrayRef<zxing::byte> matrix = delegate->getMatrix();
|
||||
int length = getWidth() * getHeight();
|
||||
ArrayRef<byte> invertedMatrix(length);
|
||||
ArrayRef<zxing::byte> invertedMatrix(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF));
|
||||
invertedMatrix[i] = (zxing::byte) (255 - (matrix[i] & 0xFF));
|
||||
}
|
||||
return invertedMatrix;
|
||||
}
|
||||
@ -55,7 +54,7 @@ Ref<LuminanceSource> InvertedLuminanceSource::crop(int left, int top, int width,
|
||||
return Ref<LuminanceSource>(new InvertedLuminanceSource(delegate->crop(left, top, width, height)));
|
||||
}
|
||||
|
||||
boolean InvertedLuminanceSource::isRotateSupported() const {
|
||||
zxing::boolean InvertedLuminanceSource::isRotateSupported() const {
|
||||
return delegate->isRotateSupported();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __INVERTEDLUMINANCESOURCE_H__
|
||||
#define __INVERTEDLUMINANCESOURCE_H__
|
||||
#ifndef ZXING_INVERTEDLUMINANCESOURCE_H
|
||||
#define ZXING_INVERTEDLUMINANCESOURCE_H
|
||||
/*
|
||||
* Copyright 2013 ZXing authors All rights reserved.
|
||||
*
|
||||
@ -30,8 +30,8 @@ private:
|
||||
public:
|
||||
InvertedLuminanceSource(Ref<LuminanceSource> const&);
|
||||
|
||||
ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const;
|
||||
ArrayRef<byte> getMatrix() const;
|
||||
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
|
||||
ArrayRef<zxing::byte> getMatrix() const;
|
||||
|
||||
boolean isCropSupported() const;
|
||||
Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
|
||||
@ -45,4 +45,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif /* INVERTEDLUMINANCESOURCE_H_ */
|
||||
#endif // ZXING_INVERTEDLUMINANCESOURCE_H
|
||||
|
@ -52,7 +52,7 @@ Ref<zxing::LuminanceSource> LuminanceSource::rotateCounterClockwise45() const
|
||||
}
|
||||
|
||||
LuminanceSource::operator std::string() const {
|
||||
ArrayRef<byte> row;
|
||||
ArrayRef<zxing::byte> row;
|
||||
std::ostringstream oss;
|
||||
for (int y = 0; y < getHeight(); y++) {
|
||||
row = getRow(y, row);
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __LUMINANCESOURCE_H__
|
||||
#define __LUMINANCESOURCE_H__
|
||||
#ifndef ZXING_LUMINANCESOURCE_H
|
||||
#define ZXING_LUMINANCESOURCE_H
|
||||
/*
|
||||
* LuminanceSource.h
|
||||
* zxing
|
||||
@ -40,8 +40,8 @@ class LuminanceSource : public Counted {
|
||||
int getHeight() const { return height; }
|
||||
|
||||
// Callers take ownership of the returned memory and must call delete [] on it themselves.
|
||||
virtual ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const = 0;
|
||||
virtual ArrayRef<byte> getMatrix() const = 0;
|
||||
virtual ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const = 0;
|
||||
virtual ArrayRef<zxing::byte> getMatrix() const = 0;
|
||||
|
||||
virtual bool isCropSupported() const;
|
||||
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
|
||||
@ -59,4 +59,4 @@ class LuminanceSource : public Counted {
|
||||
|
||||
}
|
||||
|
||||
#endif /* LUMINANCESOURCE_H_ */
|
||||
#endif // ZXING_LUMINANCESOURCE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __MULTI_FORMAT_READER_H__
|
||||
#define __MULTI_FORMAT_READER_H__
|
||||
#ifndef ZXING_MULTI_FORMAT_READER_H
|
||||
#define ZXING_MULTI_FORMAT_READER_H
|
||||
|
||||
/*
|
||||
* MultiFormatBarcodeReader.h
|
||||
@ -45,4 +45,5 @@ namespace zxing {
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_MULTI_FORMAT_READER_H
|
||||
|
||||
|
30
src/zxing/zxing/NotFoundException.cpp
Normal file
30
src/zxing/zxing/NotFoundException.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* IllegalStateException.cpp
|
||||
* zxing
|
||||
*
|
||||
* Created by Alexander Stillich on 05/11/2018.
|
||||
* Copyright 2008 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <zxing/NotFoundException.h>
|
||||
|
||||
zxing::NotFoundException::NotFoundException() ZXING_NOEXCEPT {
|
||||
}
|
||||
|
||||
zxing::NotFoundException::NotFoundException(const char *msg) ZXING_NOEXCEPT
|
||||
: ReaderException(msg) {
|
||||
}
|
||||
|
||||
zxing::NotFoundException::~NotFoundException() ZXING_NOEXCEPT {
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
|
||||
#ifndef __NOT_FOUND_EXCEPTION_H__
|
||||
#define __NOT_FOUND_EXCEPTION_H__
|
||||
#ifndef ZXING_NOT_FOUND_EXCEPTION_H
|
||||
#define ZXING_NOT_FOUND_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* Copyright 20011 ZXing authors
|
||||
@ -25,11 +25,11 @@ namespace zxing {
|
||||
|
||||
class NotFoundException : public ReaderException {
|
||||
public:
|
||||
NotFoundException() throw() {}
|
||||
NotFoundException(const char *msg) throw() : ReaderException(msg) {}
|
||||
~NotFoundException() throw() {}
|
||||
NotFoundException() ZXING_NOEXCEPT;
|
||||
NotFoundException(const char *msg) ZXING_NOEXCEPT;
|
||||
~NotFoundException() ZXING_NOEXCEPT;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __NOT_FOUND_EXCEPTION_H__
|
||||
#endif // ZXING_NOT_FOUND_EXCEPTION_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __READER_H__
|
||||
#define __READER_H__
|
||||
#ifndef ZXING_READER_H
|
||||
#define ZXING_READER_H
|
||||
|
||||
/*
|
||||
* Reader.h
|
||||
@ -37,4 +37,4 @@ namespace zxing {
|
||||
|
||||
}
|
||||
|
||||
#endif // __READER_H__
|
||||
#endif // ZXING_READER_H
|
||||
|
30
src/zxing/zxing/ReaderException.cpp
Normal file
30
src/zxing/zxing/ReaderException.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* ReaderException.cpp
|
||||
* zxing
|
||||
*
|
||||
* Created by Alexander Stillich on 05/11/2018.
|
||||
* Copyright 2008 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <zxing/ReaderException.h>
|
||||
|
||||
zxing::ReaderException::ReaderException() ZXING_NOEXCEPT {
|
||||
}
|
||||
|
||||
zxing::ReaderException::ReaderException(const char *msg) ZXING_NOEXCEPT
|
||||
: Exception(msg) {
|
||||
}
|
||||
|
||||
zxing::ReaderException::~ReaderException() ZXING_NOEXCEPT {
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __READER_EXCEPTION_H__
|
||||
#define __READER_EXCEPTION_H__
|
||||
#ifndef ZXING_READER_EXCEPTION_H
|
||||
#define ZXING_READER_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* ReaderException.h
|
||||
@ -27,11 +27,11 @@ namespace zxing {
|
||||
|
||||
class ReaderException : public Exception {
|
||||
public:
|
||||
ReaderException() throw() {}
|
||||
ReaderException(char const* msg) throw() : Exception(msg) {}
|
||||
~ReaderException() throw() {}
|
||||
ReaderException() ZXING_NOEXCEPT;
|
||||
ReaderException(char const* msg) ZXING_NOEXCEPT;
|
||||
~ReaderException() ZXING_NOEXCEPT;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __READER_EXCEPTION_H__
|
||||
#endif // ZXING_READER_EXCEPTION_H
|
||||
|
@ -33,10 +33,11 @@ using zxing::BarcodeFormat;
|
||||
namespace zxing {
|
||||
|
||||
Result::Result(Ref<String> text,
|
||||
ArrayRef<byte> rawBytes,
|
||||
ArrayRef<zxing::byte> rawBytes,
|
||||
ArrayRef< Ref<ResultPoint> > resultPoints,
|
||||
BarcodeFormat format, std::string charSet) :
|
||||
text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet) {
|
||||
BarcodeFormat format, std::string charSet,
|
||||
ResultMetadata metadata) :
|
||||
text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet), metadata_(metadata) {
|
||||
}
|
||||
|
||||
Result::~Result() {
|
||||
@ -46,7 +47,7 @@ Ref<String> Result::getText() {
|
||||
return text_;
|
||||
}
|
||||
|
||||
ArrayRef<byte> Result::getRawBytes() {
|
||||
ArrayRef<zxing::byte> Result::getRawBytes() {
|
||||
return rawBytes_;
|
||||
}
|
||||
|
||||
@ -67,4 +68,9 @@ std::string Result::getCharSet() const
|
||||
return charSet_;
|
||||
}
|
||||
|
||||
ResultMetadata &Result::getMetadata()
|
||||
{
|
||||
return metadata_;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __RESULT_H__
|
||||
#define __RESULT_H__
|
||||
#ifndef ZXING_RESULT_H
|
||||
#define ZXING_RESULT_H
|
||||
|
||||
/*
|
||||
* Result.h
|
||||
@ -26,6 +26,7 @@
|
||||
#include <zxing/common/Str.h>
|
||||
#include <zxing/common/Types.h>
|
||||
#include <zxing/ResultPoint.h>
|
||||
#include <zxing/ResultMetadata.h>
|
||||
#include <zxing/BarcodeFormat.h>
|
||||
|
||||
namespace zxing {
|
||||
@ -33,26 +34,29 @@ namespace zxing {
|
||||
class Result : public Counted {
|
||||
private:
|
||||
Ref<String> text_;
|
||||
ArrayRef<byte> rawBytes_;
|
||||
ArrayRef<zxing::byte> rawBytes_;
|
||||
ArrayRef< Ref<ResultPoint> > resultPoints_;
|
||||
BarcodeFormat format_;
|
||||
std::string charSet_;
|
||||
ResultMetadata metadata_;
|
||||
|
||||
public:
|
||||
Result(Ref<String> text,
|
||||
ArrayRef<byte> rawBytes,
|
||||
ArrayRef<zxing::byte> rawBytes,
|
||||
ArrayRef< Ref<ResultPoint> > resultPoints,
|
||||
BarcodeFormat format, std::string charSet = "");
|
||||
BarcodeFormat format, std::string charSet = "",
|
||||
ResultMetadata metadata = ResultMetadata());
|
||||
~Result();
|
||||
Ref<String> getText();
|
||||
ArrayRef<byte> getRawBytes();
|
||||
ArrayRef<zxing::byte> getRawBytes();
|
||||
ArrayRef< Ref<ResultPoint> > const& getResultPoints() const;
|
||||
ArrayRef< Ref<ResultPoint> >& getResultPoints();
|
||||
BarcodeFormat getBarcodeFormat() const;
|
||||
std::string getCharSet() const;
|
||||
ResultMetadata& getMetadata();
|
||||
|
||||
friend std::ostream& operator<<(std::ostream &out, Result& result);
|
||||
};
|
||||
|
||||
}
|
||||
#endif // __RESULT_H__
|
||||
#endif // ZXING_RESULT_H
|
||||
|
111
src/zxing/zxing/ResultMetadata.cpp
Normal file
111
src/zxing/zxing/ResultMetadata.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2008 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* 2019-05-08 translation from Java into C++
|
||||
*/
|
||||
|
||||
#include <zxing/ResultMetadata.h>
|
||||
#include <zxing/common/ByteArray.h>
|
||||
|
||||
namespace zxing {
|
||||
|
||||
struct ResultMetadata::Value
|
||||
{
|
||||
virtual ~Value() {}
|
||||
virtual int toInteger(int fallback) const {
|
||||
return fallback;
|
||||
}
|
||||
virtual std::string toString() const {
|
||||
return std::string();
|
||||
}
|
||||
};
|
||||
|
||||
struct ResultMetadata::IntegerValue : public Value
|
||||
{
|
||||
int value;
|
||||
explicit IntegerValue(int v) : value(v) {}
|
||||
int toInteger(int) const override {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
struct ResultMetadata::StringValue : public Value
|
||||
{
|
||||
std::string value;
|
||||
explicit StringValue(std::string v) : value(std::move(v)) {}
|
||||
std::string toString() const override {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
int ResultMetadata::getInt(Key key, int fallbackValue) const
|
||||
{
|
||||
auto it = _contents.find(key);
|
||||
return it != _contents.end() ? it->second->toInteger(fallbackValue) : fallbackValue;
|
||||
}
|
||||
|
||||
std::string ResultMetadata::getString(Key key) const {
|
||||
auto it = _contents.find(key);
|
||||
return it != _contents.end() ? it->second->toString() : std::string();
|
||||
}
|
||||
|
||||
void ResultMetadata::put(Key key, int value) {
|
||||
_contents[key] = std::make_shared<IntegerValue>(value);
|
||||
}
|
||||
|
||||
void ResultMetadata::put(Key key, const std::string &value) {
|
||||
_contents[key] = std::make_shared<StringValue>(value);
|
||||
}
|
||||
|
||||
void ResultMetadata::putAll(const ResultMetadata& other) {
|
||||
_contents.insert(other._contents.begin(), other._contents.end());
|
||||
}
|
||||
|
||||
std::list<ResultMetadata::Key> ResultMetadata::keys() const
|
||||
{
|
||||
std::list<Key> keys;
|
||||
for(auto it = _contents.begin(); it != _contents.end(); ++it) {
|
||||
keys.push_back(it->first);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
bool ResultMetadata::empty() const
|
||||
{
|
||||
return _contents.empty();
|
||||
}
|
||||
|
||||
std::string ResultMetadata::keyToString(Key key) const
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case OTHER: return "OTHER";
|
||||
case ORIENTATION: return "ORIENTATION";
|
||||
case BYTE_SEGMENTS: return "BYTE_SEGMENTS";
|
||||
case ERROR_CORRECTION_LEVEL: return "ERROR_CORRECTION_LEVEL";
|
||||
case ISSUE_NUMBER: return "ISSUE_NUMBER";
|
||||
case SUGGESTED_PRICE: return "SUGGESTED_PRICE";
|
||||
case POSSIBLE_COUNTRY: return "POSSIBLE_COUNTRY";
|
||||
case UPC_EAN_EXTENSION: return "UPC_EAN_EXTENSION";
|
||||
case PDF417_EXTRA_METADATA: return "PDF417_EXTRA_METADATA";
|
||||
case STRUCTURED_APPEND_SEQUENCE: return "STRUCTURED_APPEND_SEQUENCE";
|
||||
case STRUCTURED_APPEND_CODE_COUNT: return "STRUCTURED_APPEND_CODE_COUNT";
|
||||
case STRUCTURED_APPEND_PARITY: return "STRUCTURED_APPEND_PARITY";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
} // zxing
|
137
src/zxing/zxing/ResultMetadata.h
Normal file
137
src/zxing/zxing/ResultMetadata.h
Normal file
@ -0,0 +1,137 @@
|
||||
#ifndef ZXING_RESULT_METADATA_H
|
||||
#define ZXING_RESULT_METADATA_H
|
||||
/*
|
||||
* Copyright 2008 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* 2019-05-08 translation from Java into C++
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <list>
|
||||
|
||||
namespace zxing {
|
||||
|
||||
class ByteArray;
|
||||
|
||||
/**
|
||||
* Represents some type of metadata about the result of the decoding that the decoder
|
||||
* wishes to communicate back to the caller.
|
||||
*/
|
||||
class ResultMetadata
|
||||
{
|
||||
public:
|
||||
|
||||
enum Key {
|
||||
|
||||
/**
|
||||
* Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
|
||||
*/
|
||||
OTHER,
|
||||
|
||||
/**
|
||||
* Denotes the likely approximate orientation of the barcode in the image. This value
|
||||
* is given as degrees rotated clockwise from the normal, upright orientation.
|
||||
* For example a 1D barcode which was found by reading top-to-bottom would be
|
||||
* said to have orientation "90". This key maps to an {@link Integer} whose
|
||||
* value is in the range [0,360).
|
||||
*/
|
||||
ORIENTATION,
|
||||
|
||||
/**
|
||||
* <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode'
|
||||
* which is sometimes used to encode binary data. While {@link Result} makes available
|
||||
* the complete raw bytes in the barcode for these formats, it does not offer the bytes
|
||||
* from the byte segments alone.</p>
|
||||
*/
|
||||
BYTE_SEGMENTS,
|
||||
|
||||
/**
|
||||
* Error correction level used, if applicable. The value type depends on the
|
||||
* format, but is typically a String.
|
||||
*/
|
||||
ERROR_CORRECTION_LEVEL,
|
||||
|
||||
/**
|
||||
* For some periodicals, indicates the issue number as an {@link Integer}.
|
||||
*/
|
||||
ISSUE_NUMBER,
|
||||
|
||||
/**
|
||||
* For some products, indicates the suggested retail price in the barcode as a
|
||||
* formatted {@link String}.
|
||||
*/
|
||||
SUGGESTED_PRICE,
|
||||
|
||||
/**
|
||||
* For some products, the possible country of manufacture as a {@link String} denoting the
|
||||
* ISO country code. Some map to multiple possible countries, like "US/CA".
|
||||
*/
|
||||
POSSIBLE_COUNTRY,
|
||||
|
||||
/**
|
||||
* For some products, the extension text
|
||||
*/
|
||||
UPC_EAN_EXTENSION,
|
||||
|
||||
/**
|
||||
* PDF417-specific metadata
|
||||
*/
|
||||
PDF417_EXTRA_METADATA,
|
||||
|
||||
/**
|
||||
* If the code format supports structured append and the current scanned code is part of one then the
|
||||
* sequence number is given with it.
|
||||
*/
|
||||
STRUCTURED_APPEND_SEQUENCE,
|
||||
|
||||
/**
|
||||
* If the code format supports structured append and the current scanned code is part of one then the
|
||||
* total code count is given with it.
|
||||
*/
|
||||
STRUCTURED_APPEND_CODE_COUNT,
|
||||
|
||||
/**
|
||||
* If the code format supports structured append and the current scanned code is part of one then the
|
||||
* parity is given with it.
|
||||
*/
|
||||
STRUCTURED_APPEND_PARITY
|
||||
};
|
||||
|
||||
int getInt(Key key, int fallbackValue = 0) const;
|
||||
std::string getString(Key key) const;
|
||||
|
||||
void put(Key key, int value);
|
||||
void put(Key key, const std::string& value);
|
||||
|
||||
void putAll(const ResultMetadata& other);
|
||||
|
||||
std::list<Key> keys() const;
|
||||
std::string keyToString(Key key) const;
|
||||
|
||||
bool empty() const;
|
||||
|
||||
private:
|
||||
struct Value;
|
||||
struct IntegerValue;
|
||||
struct StringValue;
|
||||
|
||||
std::map<Key, std::shared_ptr<Value>> _contents;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __RESULT_POINT_H__
|
||||
#define __RESULT_POINT_H__
|
||||
#ifndef ZXING_RESULT_POINT_H
|
||||
#define ZXING_RESULT_POINT_H
|
||||
|
||||
/*
|
||||
* ResultPoint.h
|
||||
@ -52,4 +52,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // __RESULT_POINT_H__
|
||||
#endif // ZXING_RESULT_POINT_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __RESULT_POINT_CALLBACK_H__
|
||||
#define __RESULT_POINT_CALLBACK_H__
|
||||
#ifndef ZXING_RESULT_POINT_CALLBACK_H
|
||||
#define ZXING_RESULT_POINT_CALLBACK_H
|
||||
|
||||
/*
|
||||
* ResultPointCallback.h
|
||||
@ -36,4 +36,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // __RESULT_POINT_CALLBACK_H__
|
||||
#endif // ZXING_RESULT_POINT_CALLBACK_H
|
||||
|
30
src/zxing/zxing/UnsupportedEncodingException.cpp
Normal file
30
src/zxing/zxing/UnsupportedEncodingException.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* UnsupportedEncodingException.cpp
|
||||
* zxing
|
||||
*
|
||||
* Created by Alexander Stillich on 05/11/2018.
|
||||
* Copyright 2008 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <zxing/UnsupportedEncodingException.h>
|
||||
|
||||
zxing::UnsupportedEncodingException::UnsupportedEncodingException() ZXING_NOEXCEPT {
|
||||
}
|
||||
|
||||
zxing::UnsupportedEncodingException::UnsupportedEncodingException(const char *msg) ZXING_NOEXCEPT
|
||||
: Exception(msg) {
|
||||
}
|
||||
|
||||
zxing::UnsupportedEncodingException::~UnsupportedEncodingException() ZXING_NOEXCEPT {
|
||||
}
|
@ -7,9 +7,9 @@ namespace zxing {
|
||||
|
||||
class UnsupportedEncodingException : public Exception {
|
||||
public:
|
||||
UnsupportedEncodingException() throw() {}
|
||||
UnsupportedEncodingException(char const* msg) throw() : Exception(msg) {}
|
||||
~UnsupportedEncodingException() throw() {}
|
||||
UnsupportedEncodingException() ZXING_NOEXCEPT;
|
||||
UnsupportedEncodingException(char const* msg) ZXING_NOEXCEPT;
|
||||
~UnsupportedEncodingException() ZXING_NOEXCEPT;
|
||||
};
|
||||
|
||||
}
|
||||
|
30
src/zxing/zxing/WriterException.cpp
Normal file
30
src/zxing/zxing/WriterException.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* UnsupportedEncodingException.cpp
|
||||
* zxing
|
||||
*
|
||||
* Created by Alexander Stillich on 05/11/2018.
|
||||
* Copyright 2008 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <zxing/WriterException.h>
|
||||
|
||||
zxing::WriterException::WriterException() ZXING_NOEXCEPT {
|
||||
}
|
||||
|
||||
zxing::WriterException::WriterException(const char *msg) ZXING_NOEXCEPT
|
||||
: Exception(msg) {
|
||||
}
|
||||
|
||||
zxing::WriterException::~WriterException() ZXING_NOEXCEPT {
|
||||
}
|
@ -7,9 +7,9 @@ namespace zxing {
|
||||
|
||||
class WriterException : public Exception {
|
||||
public:
|
||||
WriterException() throw() {}
|
||||
WriterException(char const* msg) throw() : Exception(msg) {}
|
||||
~WriterException() throw() {}
|
||||
WriterException() ZXING_NOEXCEPT;
|
||||
WriterException(char const* msg) ZXING_NOEXCEPT;
|
||||
~WriterException() ZXING_NOEXCEPT;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -14,8 +14,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __ZXING_H_
|
||||
#define __ZXING_H_
|
||||
#ifndef ZXING_H
|
||||
#define ZXING_H
|
||||
|
||||
#define ZXING_ARRAY_LEN(v) ((int)(sizeof(v)/sizeof(v[0])))
|
||||
#define ZX_LOG_DIGITS(digits) \
|
||||
@ -151,4 +151,18 @@ private:
|
||||
#define ZXING_TIME_MARK(string) (void)0
|
||||
#endif
|
||||
|
||||
#ifndef ZXING_NULLPTR
|
||||
#if __cplusplus >= 201103L
|
||||
#define ZXING_NULLPTR nullptr
|
||||
#else
|
||||
#define ZXING_NULLPTR NULL
|
||||
#endif
|
||||
#endif // ZXING_NULLPTR
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#define ZXING_NOEXCEPT noexcept
|
||||
#else
|
||||
#define ZXING_NOEXCEPT throw()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -171,9 +171,9 @@ Ref<DecoderResult> Decoder::decode(Ref<zxing::aztec::AztecDetectorResult> detect
|
||||
Ref<String> result = getEncodedData(aCorrectedBits);
|
||||
|
||||
// std::printf("constructing array\n");
|
||||
ArrayRef<byte> arrayOut(aCorrectedBits->getSize());
|
||||
ArrayRef<zxing::byte> arrayOut(aCorrectedBits->getSize());
|
||||
for (int i = 0; i < aCorrectedBits->count(); i++) {
|
||||
arrayOut[i] = (byte)aCorrectedBits->get(i);
|
||||
arrayOut[i] = (zxing::byte)aCorrectedBits->get(i);
|
||||
}
|
||||
|
||||
// std::printf("returning\n");
|
||||
@ -441,7 +441,7 @@ Ref<BitArray> Decoder::extractBits(Ref<zxing::BitMatrix> matrix) {
|
||||
|
||||
}
|
||||
|
||||
Ref<BitArray> returnValue(new BitArray(rawbits.size()));
|
||||
Ref<BitArray> returnValue(new BitArray(int(rawbits.size())));
|
||||
for (int i = 0; i < (int)rawbits.size(); i++) {
|
||||
if (rawbits[i]) returnValue->set(i);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ZXING_AZTEC_DECODER_DECODER_H__
|
||||
#define __ZXING_AZTEC_DECODER_DECODER_H__
|
||||
#ifndef ZXING_AZTEC_DECODER_DECODER_H
|
||||
#define ZXING_AZTEC_DECODER_DECODER_H
|
||||
|
||||
#include <zxing/common/BitMatrix.h>
|
||||
#include <zxing/common/Str.h>
|
||||
@ -66,4 +66,4 @@ class Decoder : public Counted {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_AZTEC_DECODER_DECODER_H
|
||||
|
@ -19,8 +19,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ZXING_AZTEC_DETECTOR_DETECTOR_H__
|
||||
#define __ZXING_AZTEC_DETECTOR_DETECTOR_H__
|
||||
#ifndef ZXING_AZTEC_DETECTOR_DETECTOR_H
|
||||
#define ZXING_AZTEC_DETECTOR_DETECTOR_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -89,4 +89,4 @@ class Detector : public Counted {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_AZTEC_DETECTOR_DETECTOR_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __ARRAY_H__
|
||||
#define __ARRAY_H__
|
||||
#ifndef ZXING_ARRAY_H
|
||||
#define ZXING_ARRAY_H
|
||||
|
||||
/*
|
||||
* Array.h
|
||||
@ -70,7 +70,7 @@ public:
|
||||
return values_[i];
|
||||
}
|
||||
int size() const {
|
||||
return values_.size();
|
||||
return int(values_.size());
|
||||
}
|
||||
bool empty() const {
|
||||
return values_.size() == 0;
|
||||
@ -170,4 +170,4 @@ public:
|
||||
|
||||
} // namespace zxing
|
||||
|
||||
#endif // __ARRAY_H__
|
||||
#endif // ZXING_ARRAY_H
|
||||
|
@ -41,11 +41,13 @@ BitArray::BitArray(int size_)
|
||||
|
||||
//this could be wrong. TODO: check size value
|
||||
BitArray::BitArray(std::vector<int> other)
|
||||
: size(other.size()), bits(other.size())
|
||||
: size(int(other.size())), bits(int(other.size()))
|
||||
{
|
||||
for(int i=0; i<other.size(); i++)
|
||||
for(size_t i=0; i<other.size(); i++)
|
||||
{
|
||||
if(other[i])
|
||||
set(i);
|
||||
set(int(i));
|
||||
}
|
||||
}
|
||||
|
||||
BitArray::~BitArray() {
|
||||
@ -116,13 +118,13 @@ void BitArray::reverse()
|
||||
int len = ((this->size-1) / 32);
|
||||
int oldBitsLen = len + 1;
|
||||
for (int i = 0; i < oldBitsLen; i++) {
|
||||
long x = (long) bits[i];
|
||||
long x = long(bits[i]);
|
||||
x = ((x >> 1) & 0x55555555L) | ((x & 0x55555555L) << 1);
|
||||
x = ((x >> 2) & 0x33333333L) | ((x & 0x33333333L) << 2);
|
||||
x = ((x >> 4) & 0x0f0f0f0fL) | ((x & 0x0f0f0f0fL) << 4);
|
||||
x = ((x >> 8) & 0x00ff00ffL) | ((x & 0x00ff00ffL) << 8);
|
||||
x = ((x >> 16) & 0x0000ffffL) | ((x & 0x0000ffffL) << 16);
|
||||
newBits[len - i] = (int) x;
|
||||
newBits[len - i] = int(x);
|
||||
}
|
||||
// now correct the int's if the bit size isn't a multiple of 32
|
||||
if (size != oldBitsLen * 32) {
|
||||
@ -156,7 +158,7 @@ namespace {
|
||||
int numberOfTrailingZeros(int i) {
|
||||
// HD, Figure 5-14
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
return __builtin_ctz(i);
|
||||
return __builtin_ctz(unsigned(i));
|
||||
#else
|
||||
int y;
|
||||
if (i == 0) return 32;
|
||||
@ -179,7 +181,7 @@ int BitArray::getNextSet(int from) {
|
||||
// mask off lesser bits first
|
||||
currentBits &= ~((1 << (from & bitsMask)) - 1);
|
||||
while (currentBits == 0) {
|
||||
if (++bitsOffset == (int)bits->size()) {
|
||||
if (++bitsOffset == bits->size()) {
|
||||
return size;
|
||||
}
|
||||
currentBits = bits[bitsOffset];
|
||||
@ -197,7 +199,7 @@ int BitArray::getNextUnset(int from) {
|
||||
// mask off lesser bits first
|
||||
currentBits &= ~((1 << (from & bitsMask)) - 1);
|
||||
while (currentBits == 0) {
|
||||
if (++bitsOffset == (int)bits->size()) {
|
||||
if (++bitsOffset == bits->size()) {
|
||||
return size;
|
||||
}
|
||||
currentBits = ~bits[bitsOffset];
|
||||
@ -241,7 +243,7 @@ void BitArray::ensureCapacity(int size)
|
||||
{
|
||||
ArrayRef<int> newBits = makeArray(size);
|
||||
//memcpy(bits, newBits->, bits->size());
|
||||
for (size_t i=0; i<bits->size(); ++i) {
|
||||
for (int i=0; i<bits->size(); ++i) {
|
||||
newBits[i] = bits[i];
|
||||
}
|
||||
bits = newBits;
|
||||
@ -261,10 +263,10 @@ void BitArray::xor_(const BitArray& other)
|
||||
}
|
||||
}
|
||||
|
||||
void BitArray::toBytes(int bitOffset, std::vector<byte>& array, int offset, int numBytes) const
|
||||
void BitArray::toBytes(int bitOffset, std::vector<zxing::byte>& array, int offset, int numBytes) const
|
||||
{
|
||||
if(array.size() < (numBytes + offset))
|
||||
array.resize(numBytes + offset);
|
||||
if(int(array.size()) < (numBytes + offset))
|
||||
array.resize(size_t(numBytes + offset));
|
||||
|
||||
for (int i = 0; i < numBytes; i++) {
|
||||
int theByte = 0;
|
||||
@ -274,7 +276,7 @@ void BitArray::toBytes(int bitOffset, std::vector<byte>& array, int offset, int
|
||||
}
|
||||
bitOffset++;
|
||||
}
|
||||
array[offset + i] = (byte) theByte;
|
||||
array[size_t(offset + i)] = zxing::byte(theByte);
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +284,7 @@ const std::string BitArray::toString() const
|
||||
{
|
||||
std::stringstream result;// = new StringBuilder(2 * width * height + 2);
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
if ((i & 0x07) == 0) {
|
||||
result << ' ';
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __BIT_ARRAY_H__
|
||||
#define __BIT_ARRAY_H__
|
||||
#ifndef ZXING_BIT_ARRAY_H
|
||||
#define ZXING_BIT_ARRAY_H
|
||||
|
||||
/*
|
||||
* Copyright 2010 ZXing authors. All rights reserved.
|
||||
@ -74,7 +74,7 @@ public:
|
||||
|
||||
void xor_(const BitArray& other);
|
||||
|
||||
void toBytes(int bitOffset, std::vector<byte>& array, int offset, int numBytes) const;
|
||||
void toBytes(int bitOffset, std::vector<zxing::byte>& array, int offset, int numBytes) const;
|
||||
|
||||
const std::string toString() const;
|
||||
|
||||
@ -100,4 +100,4 @@ std::ostream& operator << (std::ostream&, BitArray const&);
|
||||
|
||||
}
|
||||
|
||||
#endif // __BIT_ARRAY_H__
|
||||
#endif // ZXING_BIT_ARRAY_H
|
||||
|
@ -111,7 +111,7 @@ void BitMatrix::setRow(int y, Ref<zxing::BitArray> row)
|
||||
}
|
||||
|
||||
//change with memcopy
|
||||
for(size_t i=0; i<width; i++)
|
||||
for(int i=0; i<width; i++)
|
||||
bits[y * rowSize + i] = row->get(i);
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ ArrayRef<int> BitMatrix::getEnclosingRectangle() const
|
||||
}
|
||||
if (x32 * 32 + 31 > right) {
|
||||
int bit = 31;
|
||||
while (((unsigned)theBits >> (unsigned)bit) == 0) {
|
||||
while ((unsigned(theBits) >> unsigned(bit)) == 0) {
|
||||
bit--;
|
||||
}
|
||||
if ((x32 * 32 + bit) > right) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __BIT_MATRIX_H__
|
||||
#define __BIT_MATRIX_H__
|
||||
#ifndef ZXING_BIT_MATRIX_H
|
||||
#define ZXING_BIT_MATRIX_H
|
||||
|
||||
/*
|
||||
* BitMatrix.h
|
||||
@ -38,17 +38,6 @@ private:
|
||||
int rowSize;
|
||||
ArrayRef<int> bits;
|
||||
|
||||
//#define ZX_LOG_DIGITS(digits) \
|
||||
// ((digits == 8) ? 3 : \
|
||||
// ((digits == 16) ? 4 : \
|
||||
// ((digits == 32) ? 5 : \
|
||||
// ((digits == 64) ? 6 : \
|
||||
// ((digits == 128) ? 7 : \
|
||||
// (-1))))))
|
||||
|
||||
// static const int logBits = ZX_LOG_DIGITS(bitsPerWord);
|
||||
// static const int bitsMask = (1 << logBits) - 1;
|
||||
|
||||
public:
|
||||
BitMatrix(int dimension);
|
||||
BitMatrix(int width, int height);
|
||||
@ -92,4 +81,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // __BIT_MATRIX_H__
|
||||
#endif // ZXING_BIT_MATRIX_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __BIT_SOURCE_H__
|
||||
#define __BIT_SOURCE_H__
|
||||
#ifndef ZXING_BIT_SOURCE_H
|
||||
#define ZXING_BIT_SOURCE_H
|
||||
|
||||
/*
|
||||
* BitSource.h
|
||||
@ -35,7 +35,7 @@ namespace zxing {
|
||||
*/
|
||||
class BitSource : public Counted {
|
||||
private:
|
||||
ArrayRef<byte> bytes_;
|
||||
ArrayRef<zxing::byte> bytes_;
|
||||
int byteOffset_;
|
||||
int bitOffset_;
|
||||
public:
|
||||
@ -43,7 +43,7 @@ public:
|
||||
* @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
|
||||
* Bits are read within a byte from most-significant to least-significant bit.
|
||||
*/
|
||||
BitSource(ArrayRef<byte> &bytes) :
|
||||
BitSource(ArrayRef<zxing::byte> &bytes) :
|
||||
bytes_(bytes), byteOffset_(0), bitOffset_(0) {
|
||||
}
|
||||
|
||||
@ -71,4 +71,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // __BIT_SOURCE_H__
|
||||
#endif // ZXING_BIT_SOURCE_H
|
||||
|
43
src/zxing/zxing/common/ByteArray.h
Normal file
43
src/zxing/zxing/common/ByteArray.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef ZXING_BYTE_ARRAY_H
|
||||
#define ZXING_BYTE_ARRAY_H
|
||||
/*
|
||||
* Copyright 2008 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* 2019-05-08 translation from Java into C++
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include "Types.h"
|
||||
|
||||
namespace zxing {
|
||||
|
||||
/**
|
||||
* ByteArray is an extension of std::vector<unsigned char>.
|
||||
*/
|
||||
class ByteArray : public std::vector<uint8_t>
|
||||
{
|
||||
public:
|
||||
ByteArray() {}
|
||||
ByteArray(std::initializer_list<uint8_t> list) : std::vector<uint8_t>(list) {}
|
||||
explicit ByteArray(int len) : std::vector<uint8_t>(len, 0) {}
|
||||
int length() const { return static_cast<int>(size()); }
|
||||
const zxing::byte* bytePtr() const { return reinterpret_cast<const zxing::byte*>(data()); }
|
||||
zxing::byte* bytePtr() { return reinterpret_cast<zxing::byte*>(data()); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -32,68 +32,70 @@ std::vector<CharacterSetECI*> CharacterSetECI::ECItables;
|
||||
|
||||
bool CharacterSetECI::inited = CharacterSetECI::init_tables();
|
||||
|
||||
#define ADD_CHARACTER_SET(VALUES, STRINGS) \
|
||||
{ static int values[] = {VALUES, -1}; \
|
||||
static char const* strings[] = {STRINGS, 0}; \
|
||||
addCharacterSet(values, strings); }
|
||||
#define COMMA ,
|
||||
|
||||
#define XC ,
|
||||
#define ADD_CHARACTER_SET(VALUES, STRINGS) \
|
||||
{ int values[] = {VALUES}; \
|
||||
const char *strings[] = {STRINGS}; \
|
||||
addCharacterSet(std::vector<int>(values, values + sizeof(values) / sizeof(values[0])), \
|
||||
std::vector<const char*>(strings, strings + sizeof(strings) / sizeof(strings[0]))); }
|
||||
|
||||
bool CharacterSetECI::init_tables() {
|
||||
ADD_CHARACTER_SET(0 XC 2, "Cp437");
|
||||
ADD_CHARACTER_SET(1 XC 3, "ISO8859_1" XC "ISO-8859-1");
|
||||
ADD_CHARACTER_SET(4, "ISO8859_2" XC "ISO-8859-2");
|
||||
ADD_CHARACTER_SET(5, "ISO8859_3" XC "ISO-8859-3");
|
||||
ADD_CHARACTER_SET(6, "ISO8859_4" XC "ISO-8859-4");
|
||||
ADD_CHARACTER_SET(7, "ISO8859_5" XC "ISO-8859-5");
|
||||
ADD_CHARACTER_SET(8, "ISO8859_6" XC "ISO-8859-6");
|
||||
ADD_CHARACTER_SET(9, "ISO8859_7" XC "ISO-8859-7");
|
||||
ADD_CHARACTER_SET(10, "ISO8859_8" XC "ISO-8859-8");
|
||||
ADD_CHARACTER_SET(11, "ISO8859_9" XC "ISO-8859-9");
|
||||
ADD_CHARACTER_SET(12, "ISO8859_10" XC "ISO-8859-10");
|
||||
ADD_CHARACTER_SET(13, "ISO8859_11" XC "ISO-8859-11");
|
||||
ADD_CHARACTER_SET(15, "ISO8859_13" XC "ISO-8859-13");
|
||||
ADD_CHARACTER_SET(16, "ISO8859_14" XC "ISO-8859-14");
|
||||
ADD_CHARACTER_SET(17, "ISO8859_15" XC "ISO-8859-15");
|
||||
ADD_CHARACTER_SET(18, "ISO8859_16" XC "ISO-8859-16");
|
||||
ADD_CHARACTER_SET(20, "SJIS" XC "Shift_JIS");
|
||||
ADD_CHARACTER_SET(21, "Cp1250" XC "windows-1250");
|
||||
ADD_CHARACTER_SET(22, "Cp1251" XC "windows-1251");
|
||||
ADD_CHARACTER_SET(23, "Cp1252" XC "windows-1252");
|
||||
ADD_CHARACTER_SET(24, "Cp1256" XC "windows-1256");
|
||||
ADD_CHARACTER_SET(25, "UnicodeBigUnmarked" XC "UTF-16BE" XC "UnicodeBig");
|
||||
ADD_CHARACTER_SET(26, "UTF8" XC "UTF-8");
|
||||
ADD_CHARACTER_SET(27 XC 170, "ASCII" XC "US-ASCII");
|
||||
ADD_CHARACTER_SET(1 COMMA 3, "ISO8859_1" COMMA "ISO-8859-1")
|
||||
ADD_CHARACTER_SET(0 COMMA 2, "Cp437");
|
||||
ADD_CHARACTER_SET(4, "ISO8859_2" COMMA "ISO-8859-2");
|
||||
ADD_CHARACTER_SET(5, "ISO8859_3" COMMA "ISO-8859-3");
|
||||
ADD_CHARACTER_SET(6, "ISO8859_4" COMMA "ISO-8859-4");
|
||||
ADD_CHARACTER_SET(7, "ISO8859_5" COMMA "ISO-8859-5");
|
||||
ADD_CHARACTER_SET(8, "ISO8859_6" COMMA "ISO-8859-6");
|
||||
ADD_CHARACTER_SET(9, "ISO8859_7" COMMA "ISO-8859-7");
|
||||
ADD_CHARACTER_SET(10, "ISO8859_8" COMMA "ISO-8859-8");
|
||||
ADD_CHARACTER_SET(11, "ISO8859_9" COMMA "ISO-8859-9");
|
||||
ADD_CHARACTER_SET(12, "ISO8859_10" COMMA "ISO-8859-10");
|
||||
ADD_CHARACTER_SET(13, "ISO8859_11" COMMA "ISO-8859-11");
|
||||
ADD_CHARACTER_SET(15, "ISO8859_13" COMMA "ISO-8859-13");
|
||||
ADD_CHARACTER_SET(16, "ISO8859_14" COMMA "ISO-8859-14");
|
||||
ADD_CHARACTER_SET(17, "ISO8859_15" COMMA "ISO-8859-15");
|
||||
ADD_CHARACTER_SET(18, "ISO8859_16" COMMA "ISO-8859-16");
|
||||
ADD_CHARACTER_SET(20, "SJIS" COMMA "Shift_JIS");
|
||||
ADD_CHARACTER_SET(21, "Cp1250" COMMA "windows-1250");
|
||||
ADD_CHARACTER_SET(22, "Cp1251" COMMA "windows-1251");
|
||||
ADD_CHARACTER_SET(23, "Cp1252" COMMA "windows-1252");
|
||||
ADD_CHARACTER_SET(24, "Cp1256" COMMA "windows-1256");
|
||||
ADD_CHARACTER_SET(25, "UnicodeBigUnmarked" COMMA "UTF-16BE" COMMA "UnicodeBig");
|
||||
ADD_CHARACTER_SET(26, "UTF8" COMMA "UTF-8");
|
||||
ADD_CHARACTER_SET(27 COMMA 170, "ASCII" COMMA "US-ASCII");
|
||||
ADD_CHARACTER_SET(28, "Big5");
|
||||
ADD_CHARACTER_SET(29, "GB18030" XC "GB2312" XC "EUC_CN" XC "GBK");
|
||||
ADD_CHARACTER_SET(30, "EUC_KR" XC "EUC-KR");
|
||||
ADD_CHARACTER_SET(29, "GB18030" COMMA "GB2312" COMMA "EUC_CN" COMMA "GBK");
|
||||
ADD_CHARACTER_SET(30, "EUC_KR" COMMA "EUC-KR");
|
||||
|
||||
std::atexit(removeAllCharacterSets);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef XC
|
||||
|
||||
CharacterSetECI::CharacterSetECI(int const* values,
|
||||
char const* const* names)
|
||||
: Counted(), values_(values), names_(names) {}
|
||||
CharacterSetECI::CharacterSetECI(const std::vector<int> values, const std::vector<const char*> names)
|
||||
: Counted(), values_(values)
|
||||
{
|
||||
for(size_t i=0; i<names.size(); i++)
|
||||
names_.push_back(std::string(names[i]));
|
||||
}
|
||||
|
||||
char const* CharacterSetECI::name() const {
|
||||
return names_[0];
|
||||
return names_[0].c_str();
|
||||
}
|
||||
|
||||
int CharacterSetECI::getValue() const {
|
||||
return values_[0];
|
||||
}
|
||||
|
||||
void CharacterSetECI::addCharacterSet(int const* values, char const* const* names) {
|
||||
void CharacterSetECI::addCharacterSet(const std::vector<int> values, const std::vector<const char*> names) {
|
||||
CharacterSetECI* charSet = new CharacterSetECI(values, names);
|
||||
for(int const* values_tmp = values; *values_tmp != -1; values_tmp++) {
|
||||
VALUE_TO_ECI[*values_tmp] = charSet;
|
||||
for(size_t i=0; i<values.size(); i++) {
|
||||
VALUE_TO_ECI[values[i]] = charSet;
|
||||
}
|
||||
for(char const* const* names_tmp = names; *names_tmp; names_tmp++) {
|
||||
NAME_TO_ECI[string(*names_tmp)] = charSet;
|
||||
for(size_t i=0; i<names.size(); i++) {
|
||||
NAME_TO_ECI[std::string(names[i])] = charSet;
|
||||
}
|
||||
|
||||
ECItables.push_back(charSet);
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
|
||||
#ifndef __CHARACTERSET_ECI__
|
||||
#define __CHARACTERSET_ECI__
|
||||
#ifndef ZXING_CHARACTERSET_ECI
|
||||
#define ZXING_CHARACTERSET_ECI
|
||||
|
||||
/*
|
||||
* Copyright 2008-2011 ZXing authors
|
||||
@ -35,12 +35,12 @@ private:
|
||||
static bool inited;
|
||||
static bool init_tables();
|
||||
|
||||
int const* const values_;
|
||||
char const* const* const names_;
|
||||
std::vector<int> values_;
|
||||
std::vector<std::string> names_;
|
||||
|
||||
CharacterSetECI(int const* values, char const* const* names);
|
||||
CharacterSetECI(const std::vector<int> values, const std::vector<const char*> names);
|
||||
|
||||
static void addCharacterSet(int const* value, char const* const* encodingNames);
|
||||
static void addCharacterSet(const std::vector<int> value, const std::vector<const char*> encodingNames);
|
||||
|
||||
public:
|
||||
char const* name() const;
|
||||
@ -54,4 +54,5 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_CHARACTERSET_ECI
|
||||
|
||||
|
36
src/zxing/zxing/common/Counted.cpp
Normal file
36
src/zxing/zxing/common/Counted.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "Counted.h"
|
||||
|
||||
namespace zxing {
|
||||
|
||||
Counted::Counted() :
|
||||
count_(0)
|
||||
{
|
||||
}
|
||||
|
||||
Counted::~Counted()
|
||||
{
|
||||
}
|
||||
|
||||
Counted *Counted::retain()
|
||||
{
|
||||
count_++;
|
||||
return this;
|
||||
}
|
||||
|
||||
void Counted::release()
|
||||
{
|
||||
count_--;
|
||||
if (count_ == 0) {
|
||||
count_ = 0xDEADF001;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
int Counted::count() const
|
||||
{
|
||||
return count_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __COUNTED_H__
|
||||
#define __COUNTED_H__
|
||||
#ifndef ZXING_COUNTED_H
|
||||
#define ZXING_COUNTED_H
|
||||
|
||||
/*
|
||||
* Copyright 2010 ZXing authors All rights reserved.
|
||||
@ -27,28 +27,16 @@ class Counted {
|
||||
private:
|
||||
unsigned int count_;
|
||||
public:
|
||||
Counted() :
|
||||
count_(0) {
|
||||
}
|
||||
virtual ~Counted() {
|
||||
}
|
||||
Counted *retain() {
|
||||
count_++;
|
||||
return this;
|
||||
}
|
||||
void release() {
|
||||
count_--;
|
||||
if (count_ == 0) {
|
||||
count_ = 0xDEADF001;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
Counted();
|
||||
|
||||
virtual ~Counted();
|
||||
|
||||
Counted *retain();
|
||||
|
||||
void release();
|
||||
|
||||
/* return the current count for denugging purposes or similar */
|
||||
int count() const {
|
||||
return count_;
|
||||
}
|
||||
int count() const;
|
||||
};
|
||||
|
||||
/* counting reference to reference-counted objects */
|
||||
@ -137,4 +125,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // __COUNTED_H__
|
||||
#endif // ZXING_COUNTED_H
|
||||
|
@ -24,20 +24,20 @@
|
||||
using namespace std;
|
||||
using namespace zxing;
|
||||
|
||||
DecoderResult::DecoderResult(ArrayRef<byte> rawBytes,
|
||||
DecoderResult::DecoderResult(ArrayRef<zxing::byte> rawBytes,
|
||||
Ref<String> text,
|
||||
ArrayRef< ArrayRef<byte> >& byteSegments,
|
||||
ArrayRef< ArrayRef<zxing::byte> >& byteSegments,
|
||||
string const& ecLevel, string charSet) :
|
||||
rawBytes_(rawBytes),
|
||||
text_(text),
|
||||
byteSegments_(byteSegments),
|
||||
ecLevel_(ecLevel), charSet_(charSet) {}
|
||||
|
||||
DecoderResult::DecoderResult(ArrayRef<byte> rawBytes,
|
||||
DecoderResult::DecoderResult(ArrayRef<zxing::byte> rawBytes,
|
||||
Ref<String> text)
|
||||
: rawBytes_(rawBytes), text_(text),charSet_("") {}
|
||||
|
||||
ArrayRef<byte> DecoderResult::getRawBytes() {
|
||||
ArrayRef<zxing::byte> DecoderResult::getRawBytes() {
|
||||
return rawBytes_;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __DECODER_RESULT_H__
|
||||
#define __DECODER_RESULT_H__
|
||||
#ifndef ZXING_DECODER_RESULT_H
|
||||
#define ZXING_DECODER_RESULT_H
|
||||
|
||||
/*
|
||||
* DecoderResult.h
|
||||
@ -30,26 +30,26 @@ namespace zxing {
|
||||
|
||||
class DecoderResult : public Counted {
|
||||
private:
|
||||
ArrayRef<byte> rawBytes_;
|
||||
ArrayRef<zxing::byte> rawBytes_;
|
||||
Ref<String> text_;
|
||||
ArrayRef< ArrayRef<byte> > byteSegments_;
|
||||
ArrayRef< ArrayRef<zxing::byte> > byteSegments_;
|
||||
std::string ecLevel_;
|
||||
std::string charSet_;
|
||||
|
||||
public:
|
||||
DecoderResult(ArrayRef<byte> rawBytes,
|
||||
DecoderResult(ArrayRef<zxing::byte> rawBytes,
|
||||
Ref<String> text,
|
||||
ArrayRef< ArrayRef<byte> >& byteSegments,
|
||||
ArrayRef< ArrayRef<zxing::byte> >& byteSegments,
|
||||
std::string const& ecLevel,
|
||||
std::string charSet = "");
|
||||
|
||||
DecoderResult(ArrayRef<byte> rawBytes, Ref<String> text);
|
||||
DecoderResult(ArrayRef<zxing::byte> rawBytes, Ref<String> text);
|
||||
|
||||
ArrayRef<byte> getRawBytes();
|
||||
ArrayRef<zxing::byte> getRawBytes();
|
||||
Ref<String> getText();
|
||||
std::string charSet();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __DECODER_RESULT_H__
|
||||
#endif // ZXING_DECODER_RESULT_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __DETECTOR_RESULT_H__
|
||||
#define __DETECTOR_RESULT_H__
|
||||
#ifndef ZXING_DETECTOR_RESULT_H
|
||||
#define ZXING_DETECTOR_RESULT_H
|
||||
|
||||
/*
|
||||
* DetectorResult.h
|
||||
@ -40,4 +40,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // __DETECTOR_RESULT_H__
|
||||
#endif // ZXING_DETECTOR_RESULT_H
|
||||
|
@ -36,7 +36,7 @@ namespace zxing {
|
||||
const int LUMINANCE_BITS = 5;
|
||||
const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
|
||||
const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
|
||||
const ArrayRef<byte> EMPTY (0);
|
||||
const ArrayRef<zxing::byte> EMPTY (0);
|
||||
|
||||
GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref<LuminanceSource> source)
|
||||
: Binarizer(source), luminances(EMPTY), buckets(LUMINANCE_BUCKETS) {}
|
||||
@ -45,7 +45,7 @@ GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {}
|
||||
|
||||
void GlobalHistogramBinarizer::initArrays(int luminanceSize) {
|
||||
if (luminances->size() < luminanceSize) {
|
||||
luminances = ArrayRef<byte>(luminanceSize);
|
||||
luminances = ArrayRef<zxing::byte>(luminanceSize);
|
||||
}
|
||||
// for (int x = 0; x < LUMINANCE_BUCKETS; x++) {
|
||||
// buckets[x] = 0;
|
||||
@ -64,7 +64,7 @@ Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
|
||||
}
|
||||
|
||||
initArrays(width);
|
||||
ArrayRef<byte> localLuminances = source.getRow(y, luminances);
|
||||
ArrayRef<zxing::byte> localLuminances = source.getRow(y, luminances);
|
||||
if (false) {
|
||||
std::cerr << "gbr " << y << " r ";
|
||||
for(int i=0, e=localLuminances->size(); i < e; ++i) {
|
||||
@ -108,7 +108,7 @@ Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
|
||||
ArrayRef<int> localBuckets = buckets;
|
||||
for (int y = 1; y < 5; y++) {
|
||||
int row = height * y / 5;
|
||||
ArrayRef<byte> localLuminances = source.getRow(row, luminances);
|
||||
ArrayRef<zxing::byte> localLuminances = source.getRow(row, luminances);
|
||||
int right = (width << 2) / 5;
|
||||
for (int x = width / 5; x < right; x++) {
|
||||
int pixel = localLuminances[x] & 0xff;
|
||||
@ -118,7 +118,7 @@ Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
|
||||
|
||||
int blackPoint = estimateBlackPoint(localBuckets);
|
||||
|
||||
ArrayRef<byte> localLuminances = source.getMatrix();
|
||||
ArrayRef<zxing::byte> localLuminances = source.getMatrix();
|
||||
for (int y = 0; y < height; y++) {
|
||||
int offset = y * width;
|
||||
for (int x = 0; x < width; x++) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __GLOBALHISTOGRAMBINARIZER_H__
|
||||
#define __GLOBALHISTOGRAMBINARIZER_H__
|
||||
#ifndef ZXING_GLOBALHISTOGRAMBINARIZER_H
|
||||
#define ZXING_GLOBALHISTOGRAMBINARIZER_H
|
||||
/*
|
||||
* GlobalHistogramBinarizer.h
|
||||
* zxing
|
||||
@ -29,7 +29,7 @@ namespace zxing {
|
||||
|
||||
class GlobalHistogramBinarizer : public Binarizer {
|
||||
private:
|
||||
ArrayRef<byte> luminances;
|
||||
ArrayRef<zxing::byte> luminances;
|
||||
ArrayRef<int> buckets;
|
||||
public:
|
||||
GlobalHistogramBinarizer(Ref<LuminanceSource> source);
|
||||
@ -45,4 +45,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif /* GLOBALHISTOGRAMBINARIZER_H_ */
|
||||
#endif /* ZXING_GLOBALHISTOGRAMBINARIZER_H */
|
||||
|
@ -29,7 +29,7 @@ using zxing::LuminanceSource;
|
||||
namespace zxing {
|
||||
|
||||
GreyscaleLuminanceSource::
|
||||
GreyscaleLuminanceSource(ArrayRef<byte> greyData,
|
||||
GreyscaleLuminanceSource(ArrayRef<zxing::byte> greyData,
|
||||
int dataWidth, int dataHeight,
|
||||
int left, int top,
|
||||
int width, int height)
|
||||
@ -43,13 +43,13 @@ GreyscaleLuminanceSource(ArrayRef<byte> greyData,
|
||||
}
|
||||
}
|
||||
|
||||
ArrayRef<byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
|
||||
ArrayRef<zxing::byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<zxing::byte> row) const {
|
||||
if (y < 0 || y >= this->getHeight()) {
|
||||
throw IllegalArgumentException("Requested row is outside the image.");
|
||||
}
|
||||
int width = getWidth();
|
||||
if (!row || row->size() < width) {
|
||||
ArrayRef<byte> temp (width);
|
||||
ArrayRef<zxing::byte> temp (width);
|
||||
row = temp;
|
||||
}
|
||||
int offset = (y + top_) * dataWidth_ + left_;
|
||||
@ -57,12 +57,12 @@ ArrayRef<byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<byte> row) const
|
||||
return row;
|
||||
}
|
||||
|
||||
ArrayRef<byte> GreyscaleLuminanceSource::getMatrix() const {
|
||||
ArrayRef<zxing::byte> GreyscaleLuminanceSource::getMatrix() const {
|
||||
if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) {
|
||||
return greyData_;
|
||||
} else {
|
||||
int size = getWidth() * getHeight();
|
||||
ArrayRef<byte> result (size);
|
||||
ArrayRef<zxing::byte> result (size);
|
||||
for (int row = 0; row < getHeight(); row++) {
|
||||
memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth());
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __GREYSCALE_LUMINANCE_SOURCE__
|
||||
#define __GREYSCALE_LUMINANCE_SOURCE__
|
||||
#ifndef ZXING_GREYSCALE_LUMINANCE_SOURCE
|
||||
#define ZXING_GREYSCALE_LUMINANCE_SOURCE
|
||||
/*
|
||||
* GreyscaleLuminanceSource.h
|
||||
* zxing
|
||||
@ -28,18 +28,18 @@ class GreyscaleLuminanceSource : public LuminanceSource {
|
||||
|
||||
private:
|
||||
typedef LuminanceSource Super;
|
||||
ArrayRef<byte> greyData_;
|
||||
ArrayRef<zxing::byte> greyData_;
|
||||
const int dataWidth_;
|
||||
const int dataHeight_;
|
||||
const int left_;
|
||||
const int top_;
|
||||
|
||||
public:
|
||||
GreyscaleLuminanceSource(ArrayRef<byte> greyData, int dataWidth, int dataHeight, int left,
|
||||
GreyscaleLuminanceSource(ArrayRef<zxing::byte> greyData, int dataWidth, int dataHeight, int left,
|
||||
int top, int width, int height);
|
||||
|
||||
ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const;
|
||||
ArrayRef<byte> getMatrix() const;
|
||||
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
|
||||
ArrayRef<zxing::byte> getMatrix() const;
|
||||
|
||||
bool isRotateSupported() const {
|
||||
return true;
|
||||
@ -50,4 +50,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_GREYSCALE_LUMINANCE_SOURCE
|
||||
|
@ -30,7 +30,7 @@ namespace zxing {
|
||||
// be able to traverse the greyData correctly, which does not get
|
||||
// rotated.
|
||||
GreyscaleRotatedLuminanceSource::
|
||||
GreyscaleRotatedLuminanceSource(ArrayRef<byte> greyData,
|
||||
GreyscaleRotatedLuminanceSource(ArrayRef<zxing::byte> greyData,
|
||||
int dataWidth, int dataHeight,
|
||||
int left, int top,
|
||||
int width, int height)
|
||||
@ -45,13 +45,13 @@ GreyscaleRotatedLuminanceSource(ArrayRef<byte> greyData,
|
||||
}
|
||||
|
||||
// The API asks for rows, but we're rotated, so we return columns.
|
||||
ArrayRef<byte>
|
||||
GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
|
||||
ArrayRef<zxing::byte>
|
||||
GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef<zxing::byte> row) const {
|
||||
if (y < 0 || y >= getHeight()) {
|
||||
throw IllegalArgumentException("Requested row is outside the image.");
|
||||
}
|
||||
if (!row || row->size() < getWidth()) {
|
||||
row = ArrayRef<byte>(getWidth());
|
||||
row = ArrayRef<zxing::byte>(getWidth());
|
||||
}
|
||||
int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_));
|
||||
using namespace std;
|
||||
@ -68,10 +68,10 @@ GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
|
||||
return row;
|
||||
}
|
||||
|
||||
ArrayRef<byte> GreyscaleRotatedLuminanceSource::getMatrix() const {
|
||||
ArrayRef<byte> result (getWidth() * getHeight());
|
||||
ArrayRef<zxing::byte> GreyscaleRotatedLuminanceSource::getMatrix() const {
|
||||
ArrayRef<zxing::byte> result (getWidth() * getHeight());
|
||||
for (int y = 0; y < getHeight(); y++) {
|
||||
byte* row = &result[y * getWidth()];
|
||||
zxing::byte* row = &result[y * getWidth()];
|
||||
int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_));
|
||||
for (int x = 0; x < getWidth(); x++) {
|
||||
row[x] = greyData_[offset];
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __GREYSCALE_ROTATED_LUMINANCE_SOURCE__
|
||||
#define __GREYSCALE_ROTATED_LUMINANCE_SOURCE__
|
||||
#ifndef ZXING_GREYSCALE_ROTATED_LUMINANCE_SOURCE
|
||||
#define ZXING_GREYSCALE_ROTATED_LUMINANCE_SOURCE
|
||||
/*
|
||||
* GreyscaleRotatedLuminanceSource.h
|
||||
* zxing
|
||||
@ -28,19 +28,19 @@ namespace zxing {
|
||||
class GreyscaleRotatedLuminanceSource : public LuminanceSource {
|
||||
private:
|
||||
typedef LuminanceSource Super;
|
||||
ArrayRef<byte> greyData_;
|
||||
ArrayRef<zxing::byte> greyData_;
|
||||
const int dataWidth_;
|
||||
const int left_;
|
||||
const int top_;
|
||||
|
||||
public:
|
||||
GreyscaleRotatedLuminanceSource(ArrayRef<byte> greyData, int dataWidth, int dataHeight,
|
||||
GreyscaleRotatedLuminanceSource(ArrayRef<zxing::byte> greyData, int dataWidth, int dataHeight,
|
||||
int left, int top, int width, int height);
|
||||
|
||||
ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const;
|
||||
ArrayRef<byte> getMatrix() const;
|
||||
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
|
||||
ArrayRef<zxing::byte> getMatrix() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_GREYSCALE_ROTATED_LUMINANCE_SOURCE
|
||||
|
@ -36,7 +36,7 @@ Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimension, Ref<
|
||||
Ref<BitMatrix> bits(new BitMatrix(dimension));
|
||||
vector<float> points(dimension << 1, (const float)0.0f);
|
||||
for (int y = 0; y < dimension; y++) {
|
||||
int max = points.size();
|
||||
int max = int(points.size());
|
||||
float yValue = (float)y + 0.5f;
|
||||
for (int x = 0; x < max; x += 2) {
|
||||
points[x] = (float)(x >> 1) + 0.5f;
|
||||
@ -57,7 +57,7 @@ Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimensionX, int
|
||||
Ref<BitMatrix> bits(new BitMatrix(dimensionX, dimensionY));
|
||||
vector<float> points(dimensionX << 1, (const float)0.0f);
|
||||
for (int y = 0; y < dimensionY; y++) {
|
||||
int max = points.size();
|
||||
int max = int(points.size());
|
||||
float yValue = (float)y + 0.5f;
|
||||
for (int x = 0; x < max; x += 2) {
|
||||
points[x] = (float)(x >> 1) + 0.5f;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __GRID_SAMPLER_H__
|
||||
#define __GRID_SAMPLER_H__
|
||||
#ifndef ZXING_GRID_SAMPLER_H
|
||||
#define ZXING_GRID_SAMPLER_H
|
||||
|
||||
/*
|
||||
* GridSampler.h
|
||||
@ -42,4 +42,4 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __GRID_SAMPLER_H__
|
||||
#endif // ZXING_GRID_SAMPLER_H
|
||||
|
@ -59,7 +59,7 @@ Ref<BitMatrix> HybridBinarizer::getBlackMatrix() {
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) {
|
||||
ArrayRef<byte> luminances = source.getMatrix();
|
||||
ArrayRef<zxing::byte> luminances = source.getMatrix();
|
||||
int subWidth = width >> BLOCK_SIZE_POWER;
|
||||
if ((width & BLOCK_SIZE_MASK) != 0) {
|
||||
subWidth++;
|
||||
@ -94,7 +94,7 @@ namespace {
|
||||
}
|
||||
|
||||
void
|
||||
HybridBinarizer::calculateThresholdForBlock(ArrayRef<byte> luminances,
|
||||
HybridBinarizer::calculateThresholdForBlock(ArrayRef<zxing::byte> luminances,
|
||||
int subWidth,
|
||||
int subHeight,
|
||||
int width,
|
||||
@ -130,7 +130,7 @@ HybridBinarizer::calculateThresholdForBlock(ArrayRef<byte> luminances,
|
||||
}
|
||||
}
|
||||
|
||||
void HybridBinarizer::thresholdBlock(ArrayRef<byte> luminances,
|
||||
void HybridBinarizer::thresholdBlock(ArrayRef<zxing::byte> luminances,
|
||||
int xoffset,
|
||||
int yoffset,
|
||||
int threshold,
|
||||
@ -157,7 +157,7 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
ArrayRef<int> HybridBinarizer::calculateBlackPoints(ArrayRef<byte> luminances,
|
||||
ArrayRef<int> HybridBinarizer::calculateBlackPoints(ArrayRef<zxing::byte> luminances,
|
||||
int subWidth,
|
||||
int subHeight,
|
||||
int width,
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __HYBRIDBINARIZER_H__
|
||||
#define __HYBRIDBINARIZER_H__
|
||||
#ifndef ZXING_HYBRIDBINARIZER_H
|
||||
#define ZXING_HYBRIDBINARIZER_H
|
||||
/*
|
||||
* HybridBinarizer.h
|
||||
* zxing
|
||||
@ -42,19 +42,19 @@ namespace zxing {
|
||||
private:
|
||||
// We'll be using one-D arrays because C++ can't dynamically allocate 2D
|
||||
// arrays
|
||||
ArrayRef<int> calculateBlackPoints(ArrayRef<byte> luminances,
|
||||
ArrayRef<int> calculateBlackPoints(ArrayRef<zxing::byte> luminances,
|
||||
int subWidth,
|
||||
int subHeight,
|
||||
int width,
|
||||
int height);
|
||||
void calculateThresholdForBlock(ArrayRef<byte> luminances,
|
||||
void calculateThresholdForBlock(ArrayRef<zxing::byte> luminances,
|
||||
int subWidth,
|
||||
int subHeight,
|
||||
int width,
|
||||
int height,
|
||||
ArrayRef<int> blackPoints,
|
||||
Ref<BitMatrix> const& matrix);
|
||||
void thresholdBlock(ArrayRef<byte>luminances,
|
||||
void thresholdBlock(ArrayRef<zxing::byte>luminances,
|
||||
int xoffset,
|
||||
int yoffset,
|
||||
int threshold,
|
||||
@ -64,4 +64,4 @@ namespace zxing {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_HYBRIDBINARIZER_H
|
||||
|
@ -24,4 +24,4 @@ using zxing::IllegalArgumentException;
|
||||
|
||||
IllegalArgumentException::IllegalArgumentException() : Exception() {}
|
||||
IllegalArgumentException::IllegalArgumentException(const char *msg) : Exception(msg) {}
|
||||
IllegalArgumentException::~IllegalArgumentException() throw() {}
|
||||
IllegalArgumentException::~IllegalArgumentException() ZXING_NOEXCEPT {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __ILLEGAL_ARGUMENT_EXCEPTION_H__
|
||||
#define __ILLEGAL_ARGUMENT_EXCEPTION_H__
|
||||
#ifndef ZXING_ILLEGAL_ARGUMENT_EXCEPTION_H
|
||||
#define ZXING_ILLEGAL_ARGUMENT_EXCEPTION_H
|
||||
|
||||
/*
|
||||
* IllegalArgumentException.h
|
||||
@ -28,9 +28,9 @@ class IllegalArgumentException : public Exception {
|
||||
public:
|
||||
IllegalArgumentException();
|
||||
IllegalArgumentException(const char *msg);
|
||||
~IllegalArgumentException() throw();
|
||||
~IllegalArgumentException() ZXING_NOEXCEPT;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __ILLEGAL_ARGUMENT_EXCEPTION_H__
|
||||
#endif // ZXING_ILLEGAL_ARGUMENT_EXCEPTION_H
|
||||
|
@ -87,7 +87,7 @@ Ref<PerspectiveTransform> PerspectiveTransform::times(Ref<PerspectiveTransform>
|
||||
}
|
||||
|
||||
void PerspectiveTransform::transformPoints(vector<float> &points) {
|
||||
int max = points.size();
|
||||
int max = int(points.size());
|
||||
for (int i = 0; i < max; i += 2) {
|
||||
float x = points[i];
|
||||
float y = points[i + 1];
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __PERSPECTIVE_TANSFORM_H__
|
||||
#define __PERSPECTIVE_TANSFORM_H__
|
||||
#ifndef ZXING_PERSPECTIVE_TANSFORM_H
|
||||
#define ZXING_PERSPECTIVE_TANSFORM_H
|
||||
|
||||
/*
|
||||
* PerspectiveTransform.h
|
||||
@ -46,4 +46,4 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __PERSPECTIVE_TANSFORM_H__
|
||||
#endif // ZXING_PERSPECTIVE_TANSFORM_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __POINT_H__
|
||||
#define __POINT_H__
|
||||
#ifndef ZXING_POINT_H
|
||||
#define ZXING_POINT_H
|
||||
|
||||
/*
|
||||
* Point.h
|
||||
@ -44,4 +44,4 @@ public:
|
||||
Point end;
|
||||
};
|
||||
}
|
||||
#endif // POINT_H_
|
||||
#endif // ZXING_POINT_H
|
||||
|
@ -39,12 +39,12 @@ const std::string& String::getText() const {
|
||||
|
||||
char String::charAt(int i) const { return text_[i]; }
|
||||
|
||||
int String::size() const { return text_.size(); }
|
||||
int String::size() const { return int(text_.size()); }
|
||||
|
||||
int String::length() const { return text_.size(); }
|
||||
int String::length() const { return int(text_.size()); }
|
||||
|
||||
Ref<String> String::substring(int i) const {
|
||||
return Ref<String>(new String(text_.substr(i)));
|
||||
Ref<String> String::substring(int i, int j) const {
|
||||
return Ref<String>(new String(text_.substr(i, j)));
|
||||
}
|
||||
|
||||
void String::append(const std::string &tail) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __STR_H__
|
||||
#define __STR_H__
|
||||
#ifndef ZXING_STR_H
|
||||
#define ZXING_STR_H
|
||||
|
||||
/*
|
||||
* Str.h
|
||||
@ -37,7 +37,7 @@ public:
|
||||
explicit String(const std::string &text);
|
||||
explicit String(int);
|
||||
char charAt(int) const;
|
||||
Ref<String> substring(int) const;
|
||||
Ref<String> substring(int, int = -1) const;
|
||||
const std::string& getText() const;
|
||||
int size() const;
|
||||
void append(std::string const& tail);
|
||||
@ -48,4 +48,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // __COMMON__STRING_H__
|
||||
#endif // ZXING_STR_H
|
||||
|
@ -36,7 +36,7 @@ char const* const StringUtils::ISO88591 = "ISO8859-1";
|
||||
const bool StringUtils::ASSUME_SHIFT_JIS = false;
|
||||
|
||||
string
|
||||
StringUtils::guessEncoding(byte* bytes, int length,
|
||||
StringUtils::guessEncoding(zxing::byte* bytes, int length,
|
||||
Hashtable const& hints) {
|
||||
Hashtable::const_iterator i = hints.find(DecodeHints::CHARACTER_SET);
|
||||
if (i != hints.end()) {
|
||||
@ -65,11 +65,10 @@ StringUtils::guessEncoding(byte* bytes, int length,
|
||||
//int isoHighChars = 0;
|
||||
int isoHighOther = 0;
|
||||
|
||||
typedef byte byte;
|
||||
boolean utf8bom = length > 3 &&
|
||||
bytes[0] == (byte) 0xEF &&
|
||||
bytes[1] == (byte) 0xBB &&
|
||||
bytes[2] == (byte) 0xBF;
|
||||
bytes[0] == (zxing::byte) 0xEF &&
|
||||
bytes[1] == (zxing::byte) 0xBB &&
|
||||
bytes[2] == (zxing::byte) 0xBF;
|
||||
|
||||
for (int i = 0;
|
||||
i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8);
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
|
||||
#ifndef __STRING_UTILS__
|
||||
#define __STRING_UTILS__
|
||||
#ifndef ZXING_STRING_UTILS_H
|
||||
#define ZXING_STRING_UTILS_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2011 ZXing authors
|
||||
@ -44,7 +44,7 @@ public:
|
||||
|
||||
typedef std::map<DecodeHintType, std::string> Hashtable;
|
||||
|
||||
static std::string guessEncoding(byte *bytes, int length, Hashtable const& hints);
|
||||
static std::string guessEncoding(zxing::byte *bytes, int length, Hashtable const& hints);
|
||||
|
||||
static std::string intToStr(int number);
|
||||
};
|
||||
@ -52,4 +52,5 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_STRING_UTILS_H
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __TYPES_H__
|
||||
#define __TYPES_H__
|
||||
#ifndef ZXING_TYPES_H
|
||||
#define ZXING_TYPES_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@ -13,4 +13,4 @@ typedef bool boolean;
|
||||
|
||||
}
|
||||
|
||||
#endif // __COMMON__TYPES_H__
|
||||
#endif // ZXING_TYPES_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __ZXING_COMMON_DETECTOR_MATH_H__
|
||||
#define __ZXING_COMMON_DETECTOR_MATH_H__
|
||||
#ifndef ZXING_COMMON_DETECTOR_MATH_H
|
||||
#define ZXING_COMMON_DETECTOR_MATH_H
|
||||
/*
|
||||
* Copyright 2012 ZXing authors All rights reserved.
|
||||
*
|
||||
@ -40,4 +40,5 @@ class Math {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_COMMON_DETECTOR_MATH_H
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __ZXING_COMMON_DETECTOR_MATHUTILS_H__
|
||||
#define __ZXING_COMMON_DETECTOR_MATHUTILS_H__
|
||||
#ifndef ZXING_COMMON_DETECTOR_MATHUTILS_H
|
||||
#define ZXING_COMMON_DETECTOR_MATHUTILS_H
|
||||
/*
|
||||
* Copyright 2012 ZXing authors All rights reserved.
|
||||
*
|
||||
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
namespace zxing {
|
||||
namespace common {
|
||||
@ -48,10 +49,19 @@ class MathUtils {
|
||||
int yDiff = aY - bY;
|
||||
return sqrt(float(xDiff * xDiff + yDiff * yDiff));
|
||||
}
|
||||
|
||||
static inline int sum(std::vector<int> array) {
|
||||
int count = 0;
|
||||
for (int a : array) {
|
||||
count += a;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_COMMON_DETECTOR_MATHUTILS_H
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
|
||||
#ifndef __MONOCHROMERECTANGLEDETECTOR_H__
|
||||
#define __MONOCHROMERECTANGLEDETECTOR_H__
|
||||
#ifndef ZXING_MONOCHROMERECTANGLEDETECTOR_H
|
||||
#define ZXING_MONOCHROMERECTANGLEDETECTOR_H
|
||||
|
||||
/*
|
||||
* MonochromeRectangleDetector.h
|
||||
@ -59,4 +59,4 @@ class MonochromeRectangleDetector : public Counted {
|
||||
|
||||
}
|
||||
|
||||
#endif // __MONOCHROMERECTANGLEDETECTOR_H__
|
||||
#endif // ZXING_MONOCHROMERECTANGLEDETECTOR_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __WHITERECTANGLEDETECTOR_H__
|
||||
#define __WHITERECTANGLEDETECTOR_H__
|
||||
#ifndef ZXING_WHITERECTANGLEDETECTOR_H
|
||||
#define ZXING_WHITERECTANGLEDETECTOR_H
|
||||
|
||||
/*
|
||||
* WhiteRectangleDetector.h
|
||||
@ -56,4 +56,5 @@ class WhiteRectangleDetector : public Counted {
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ZXING_WHITERECTANGLEDETECTOR_H
|
||||
|
||||
|
@ -38,16 +38,21 @@ Ref<GenericGF> GenericGF::AZTEC_DATA_8 = DATA_MATRIX_FIELD_256;
|
||||
Ref<GenericGF> GenericGF::MAXICODE_FIELD_64 = AZTEC_DATA_6;
|
||||
|
||||
namespace {
|
||||
int INITIALIZATION_THRESHOLD = 0;
|
||||
size_t INITIALIZATION_THRESHOLD = 0;
|
||||
}
|
||||
|
||||
GenericGF::GenericGF(int primitive_, int size_, int b)
|
||||
GenericGF::GenericGF(int primitive_, size_t size_, int b)
|
||||
: size(size_), primitive(primitive_), generatorBase(b), initialized(false) {
|
||||
if (size <= INITIALIZATION_THRESHOLD) {
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GenericGF::~GenericGF()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void GenericGF::initialize() {
|
||||
expTable = std::vector<int>(size);
|
||||
logTable = std::vector<int>(size);
|
||||
|
@ -35,10 +35,13 @@ namespace zxing {
|
||||
std::vector<int> logTable;
|
||||
Ref<GenericGFPoly> zero;
|
||||
Ref<GenericGFPoly> one;
|
||||
int size;
|
||||
size_t size;
|
||||
int primitive;
|
||||
int generatorBase;
|
||||
bool initialized;
|
||||
|
||||
GenericGF(int primitive, size_t size, int b);
|
||||
~GenericGF();
|
||||
|
||||
void initialize();
|
||||
void checkInit();
|
||||
@ -53,8 +56,6 @@ namespace zxing {
|
||||
static Ref<GenericGF> DATA_MATRIX_FIELD_256;
|
||||
static Ref<GenericGF> MAXICODE_FIELD_64;
|
||||
|
||||
GenericGF(int primitive, int size, int b);
|
||||
|
||||
Ref<GenericGFPoly> getZero();
|
||||
Ref<GenericGFPoly> getOne();
|
||||
int getSize();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __REED_SOLOMON_DECODER_H__
|
||||
#define __REED_SOLOMON_DECODER_H__
|
||||
#ifndef ZXING_REED_SOLOMON_DECODER_H
|
||||
#define ZXING_REED_SOLOMON_DECODER_H
|
||||
|
||||
/*
|
||||
* ReedSolomonDecoder.h
|
||||
@ -46,4 +46,4 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __REED_SOLOMON_DECODER_H__
|
||||
#endif // ZXING_REED_SOLOMON_DECODER_H
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user