mirror of
https://github.com/status-im/qzxing.git
synced 2025-01-11 11:34:35 +00:00
Moving on to version V1.2. This brings Aztec support and big imporovement in speed for 1D barcodes. Also QML support is fixed. Binaries, sources and examples are updated to that version.
This commit is contained in:
parent
573dd17a59
commit
42da993970
@ -1,7 +1,8 @@
|
||||
#ifndef QZXING_GLOBAL_H
|
||||
#define QZXING_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore>
|
||||
#include <qglobal.h>
|
||||
|
||||
#if defined(QZXING_LIBRARY)
|
||||
# define QZXINGSHARED_EXPORT Q_DECL_EXPORT
|
||||
@ -9,4 +10,4 @@
|
||||
# define QZXINGSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // QZXING_GLOBAL_H
|
||||
#endif //QZXING_GLOBAL_H
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -50,7 +50,7 @@ public:
|
||||
#if QT_VERSION >= 0x040700
|
||||
static void registerQMLTypes()
|
||||
{
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 0, "QZXing");
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 2, "QZXing");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -61,6 +61,19 @@ public slots:
|
||||
*/
|
||||
QString decodeImage(QImage image);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML
|
||||
*/
|
||||
QString decodeImageQML(QObject *item);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML. Able to set the decoding
|
||||
* of a portion of the image.
|
||||
*/
|
||||
QString decodeSubImageQML(QObject* item,
|
||||
const double offsetX = 0 , const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
|
||||
signals:
|
||||
void decodingStarted();
|
||||
void decodingFinished(bool succeeded);
|
||||
@ -69,6 +82,7 @@ signals:
|
||||
private:
|
||||
void* decoder;
|
||||
DecoderFormatType supportedFormats;
|
||||
QObject* imageHandler;
|
||||
};
|
||||
|
||||
#endif // QZXING_H
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
binary/Qt_4.7.3_Symbian/InstallToDevice/QZXing_unsigned.sis
Normal file
BIN
binary/Qt_4.7.3_Symbian/InstallToDevice/QZXing_unsigned.sis
Normal file
Binary file not shown.
@ -32,7 +32,8 @@ public:
|
||||
DecoderFormat_EAN_13 = 32,
|
||||
DecoderFormat_CODE_128 = 64,
|
||||
DecoderFormat_CODE_39 = 128,
|
||||
DecoderFormat_ITF = 256
|
||||
DecoderFormat_ITF = 256,
|
||||
DecoderFormat_Aztec = 512
|
||||
} ;
|
||||
typedef unsigned int DecoderFormatType;
|
||||
|
||||
@ -49,7 +50,7 @@ public:
|
||||
#if QT_VERSION >= 0x040700
|
||||
static void registerQMLTypes()
|
||||
{
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 0, "QZXing");
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 2, "QZXing");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -60,6 +61,19 @@ public slots:
|
||||
*/
|
||||
QString decodeImage(QImage image);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML
|
||||
*/
|
||||
QString decodeImageQML(QObject *item);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML. Able to set the decoding
|
||||
* of a portion of the image.
|
||||
*/
|
||||
QString decodeSubImageQML(QObject* item,
|
||||
const double offsetX = 0 , const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
|
||||
signals:
|
||||
void decodingStarted();
|
||||
void decodingFinished(bool succeeded);
|
||||
@ -68,6 +82,7 @@ signals:
|
||||
private:
|
||||
void* decoder;
|
||||
DecoderFormatType supportedFormats;
|
||||
QObject* imageHandler;
|
||||
};
|
||||
|
||||
#endif // QZXING_H
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
binary/Qt_4.7.3_Symbian/release/armv5/lib/QZXing{00010200}.dso
Normal file
BIN
binary/Qt_4.7.3_Symbian/release/armv5/lib/QZXing{00010200}.dso
Normal file
Binary file not shown.
@ -50,7 +50,7 @@ public:
|
||||
#if QT_VERSION >= 0x040700
|
||||
static void registerQMLTypes()
|
||||
{
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 0, "QZXing");
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 2, "QZXing");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -61,6 +61,19 @@ public slots:
|
||||
*/
|
||||
QString decodeImage(QImage image);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML
|
||||
*/
|
||||
QString decodeImageQML(QObject *item);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML. Able to set the decoding
|
||||
* of a portion of the image.
|
||||
*/
|
||||
QString decodeSubImageQML(QObject* item,
|
||||
const double offsetX = 0 , const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
|
||||
signals:
|
||||
void decodingStarted();
|
||||
void decodingFinished(bool succeeded);
|
||||
@ -69,6 +82,7 @@ signals:
|
||||
private:
|
||||
void* decoder;
|
||||
DecoderFormatType supportedFormats;
|
||||
QObject* imageHandler;
|
||||
};
|
||||
|
||||
#endif // QZXING_H
|
||||
|
Binary file not shown.
Binary file not shown.
@ -42,8 +42,10 @@ symbian{
|
||||
}
|
||||
|
||||
win32{
|
||||
LIBS += -LC:/QtSDKProjects/QMLBarcodeScanner/Qt_4.7.4_Desktop_Mingw \
|
||||
LIBS += \
|
||||
-lQZXing
|
||||
|
||||
#-LC:/QtSDKProjects/QMLBarcodeScanner/Qt_4.7.4_Desktop_Mingw \
|
||||
}
|
||||
|
||||
# Please do not modify the following two lines. Required for deployment.
|
||||
|
22
examples/QMLBarcodeScanner/QMLBarcodeScanner.rss
Normal file
22
examples/QMLBarcodeScanner/QMLBarcodeScanner.rss
Normal file
@ -0,0 +1,22 @@
|
||||
// ============================================================================
|
||||
// * Generated by qmake (2.01a) (Qt 4.7.4) on: 2012-05-14T16:55:16
|
||||
// * This file is generated by qmake and should not be modified by the
|
||||
// * user.
|
||||
// ============================================================================
|
||||
|
||||
CHARACTER_SET UTF8
|
||||
#include <appinfo.rh>
|
||||
#include "QMLBarcodeScanner.loc"
|
||||
|
||||
RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
|
||||
{
|
||||
short_caption = STRING_r_short_caption;
|
||||
caption_and_icon =
|
||||
CAPTION_AND_ICON_INFO
|
||||
{
|
||||
caption = STRING_r_caption;
|
||||
number_of_icons = 0;
|
||||
icon_file = "\\resource\\apps\\QMLBarcodeScanner.mif";
|
||||
};
|
||||
}
|
||||
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 38 KiB |
Binary file not shown.
18
examples/QMLBarcodeScanner/QMLBarcodeScanner_reg.rss
Normal file
18
examples/QMLBarcodeScanner/QMLBarcodeScanner_reg.rss
Normal file
@ -0,0 +1,18 @@
|
||||
// ============================================================================
|
||||
// * Generated by qmake (2.01a) (Qt 4.7.4) on: 2012-05-14T16:55:16
|
||||
// * This file is generated by qmake and should not be modified by the
|
||||
// * user.
|
||||
// ============================================================================
|
||||
|
||||
#include <QMLBarcodeScanner.rsg>
|
||||
#include <appinfo.rh>
|
||||
|
||||
UID2 KUidAppRegistrationResourceFile
|
||||
UID3 0xE35E8B99
|
||||
|
||||
RESOURCE APP_REGISTRATION_INFO
|
||||
{
|
||||
app_file="QMLBarcodeScanner";
|
||||
localisable_resource_file="\\resource\\apps\\QMLBarcodeScanner";
|
||||
|
||||
}
|
@ -40,7 +40,7 @@
|
||||
|
||||
import Qt 4.7
|
||||
import QtMultimediaKit 1.1
|
||||
import QZXing 1.0
|
||||
import QZXing 1.2
|
||||
|
||||
Rectangle {
|
||||
id : cameraUI
|
||||
@ -60,10 +60,16 @@ Rectangle {
|
||||
exposureCompensation: stillControls.exposureCompensation
|
||||
|
||||
onImageCaptured : {
|
||||
decoder.decodeImage(preview);
|
||||
//decoder.decodeImage(preview);
|
||||
imageToDecode.source = preview
|
||||
decoder.decodeImageQML(imageToDecode);
|
||||
}
|
||||
}
|
||||
|
||||
Image{
|
||||
id: imageToDecode
|
||||
}
|
||||
|
||||
CaptureControls {
|
||||
id: stillControls
|
||||
anchors.fill: parent
|
||||
|
@ -1,4 +1,4 @@
|
||||
// checksum 0x78c version 0x60010
|
||||
// checksum 0xee24 version 0x70013
|
||||
/*
|
||||
This file was generated by the Qt Quick Application wizard of Qt Creator.
|
||||
QmlApplicationViewer is a convenience class containing mobile device specific
|
||||
@ -12,10 +12,10 @@
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtDeclarative/QDeclarativeComponent>
|
||||
#include <QtDeclarative/QDeclarativeEngine>
|
||||
#include <QtDeclarative/QDeclarativeContext>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
#include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
|
||||
|
||||
@ -50,12 +50,9 @@ static QmlJsDebuggingEnabler enableDebuggingHelper;
|
||||
|
||||
class QmlApplicationViewerPrivate
|
||||
{
|
||||
QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
|
||||
|
||||
QString mainQmlFile;
|
||||
QDeclarativeView *view;
|
||||
friend class QmlApplicationViewer;
|
||||
QString adjustPath(const QString &path);
|
||||
static QString adjustPath(const QString &path);
|
||||
};
|
||||
|
||||
QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
|
||||
@ -63,13 +60,11 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
|
||||
#ifdef Q_OS_UNIX
|
||||
#ifdef Q_OS_MAC
|
||||
if (!QDir::isAbsolutePath(path))
|
||||
return QCoreApplication::applicationDirPath()
|
||||
+ QLatin1String("/../Resources/") + path;
|
||||
return QString::fromLatin1("%1/../Resources/%2")
|
||||
.arg(QCoreApplication::applicationDirPath(), path);
|
||||
#else
|
||||
QString pathInInstallDir;
|
||||
const QString applicationDirPath = QCoreApplication::applicationDirPath();
|
||||
pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
|
||||
|
||||
const QString pathInInstallDir =
|
||||
QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
|
||||
if (QFileInfo(pathInInstallDir).exists())
|
||||
return pathInInstallDir;
|
||||
#endif
|
||||
@ -79,34 +74,17 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
|
||||
|
||||
QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
|
||||
: QDeclarativeView(parent)
|
||||
, d(new QmlApplicationViewerPrivate(this))
|
||||
, d(new QmlApplicationViewerPrivate())
|
||||
{
|
||||
connect(engine(), SIGNAL(quit()), SLOT(close()));
|
||||
setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
||||
// Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
|
||||
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
|
||||
#if !defined(NO_JSDEBUGGER)
|
||||
new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
|
||||
new QmlJSDebugger::JSDebuggerAgent(engine());
|
||||
#endif
|
||||
#if !defined(NO_QMLOBSERVER)
|
||||
new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
|
||||
: QDeclarativeView(parent)
|
||||
, d(new QmlApplicationViewerPrivate(view))
|
||||
{
|
||||
connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
|
||||
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
||||
// Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
|
||||
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
|
||||
#if !defined(NO_JSDEBUGGER)
|
||||
new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
|
||||
#endif
|
||||
#if !defined(NO_QMLOBSERVER)
|
||||
new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
|
||||
new QmlJSDebugger::QDeclarativeViewObserver(this, this);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -118,22 +96,18 @@ QmlApplicationViewer::~QmlApplicationViewer()
|
||||
|
||||
QmlApplicationViewer *QmlApplicationViewer::create()
|
||||
{
|
||||
#ifdef HARMATTAN_BOOSTER
|
||||
return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
|
||||
#else
|
||||
return new QmlApplicationViewer();
|
||||
#endif
|
||||
}
|
||||
|
||||
void QmlApplicationViewer::setMainQmlFile(const QString &file)
|
||||
{
|
||||
d->mainQmlFile = d->adjustPath(file);
|
||||
d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
|
||||
d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
|
||||
setSource(QUrl::fromLocalFile(d->mainQmlFile));
|
||||
}
|
||||
|
||||
void QmlApplicationViewer::addImportPath(const QString &path)
|
||||
{
|
||||
d->view->engine()->addImportPath(d->adjustPath(path));
|
||||
engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path));
|
||||
}
|
||||
|
||||
void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
|
||||
@ -182,11 +156,11 @@ void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
|
||||
void QmlApplicationViewer::showExpanded()
|
||||
{
|
||||
#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
|
||||
d->view->showFullScreen();
|
||||
showFullScreen();
|
||||
#elif defined(Q_WS_MAEMO_5)
|
||||
d->view->showMaximized();
|
||||
showMaximized();
|
||||
#else
|
||||
d->view->show();
|
||||
show();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// checksum 0x82ed version 0x60010
|
||||
// checksum 0x898f version 0x70013
|
||||
/*
|
||||
This file was generated by the Qt Quick Application wizard of Qt Creator.
|
||||
QmlApplicationViewer is a convenience class containing mobile device specific
|
||||
@ -38,7 +38,6 @@ public:
|
||||
void showExpanded();
|
||||
|
||||
private:
|
||||
explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
|
||||
class QmlApplicationViewerPrivate *d;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# checksum 0x368d version 0x60010
|
||||
# checksum 0x5b42 version 0x70013
|
||||
# This file was generated by the Qt Quick Application wizard of Qt Creator.
|
||||
# The code below adds the QmlApplicationViewer to the project and handles the
|
||||
# activation of QML debugging.
|
||||
@ -52,6 +52,7 @@ symbian {
|
||||
sourcePathSegments = $$split(source, \\)
|
||||
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
|
||||
target = $$replace(target, /, \\)
|
||||
target ~= s,\\\\\\.?\\\\,\\,
|
||||
!isEqual(source,$$target) {
|
||||
!isEmpty(copyCommand):copyCommand += &&
|
||||
isEqual(QMAKE_DIR_SEP, \\) {
|
||||
@ -96,6 +97,7 @@ symbian {
|
||||
target = $$replace(target, \\\\, /)
|
||||
sourcePathSegments = $$split(source, /)
|
||||
targetFullPath = $$target/$$last(sourcePathSegments)
|
||||
targetFullPath ~= s,/\\.?/,/,
|
||||
!isEqual(source,$$targetFullPath) {
|
||||
!isEmpty(copyCommand):copyCommand += &&
|
||||
copyCommand += $(MKDIR) \"$$target\"
|
||||
|
@ -71,6 +71,7 @@ QList<QVideoFrame::PixelFormat> MyVideoSurface::supportedPixelFormats(
|
||||
{
|
||||
if (handleType == QAbstractVideoBuffer::NoHandle) {
|
||||
return QList<QVideoFrame::PixelFormat>()
|
||||
<< QVideoFrame::Format_UYVY
|
||||
<< QVideoFrame::Format_RGB32
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QVideoFrame::Format_ARGB32_Premultiplied
|
||||
|
@ -153,6 +153,8 @@ QCameraControllerWidget::~QCameraControllerWidget()
|
||||
|
||||
void QCameraControllerWidget::enableCamera()
|
||||
{
|
||||
|
||||
//QVideoFrame::Format_UYVY;
|
||||
m_camera = new QCamera();
|
||||
m_camera->setCaptureMode(QCamera::CaptureStillImage);
|
||||
connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(error(QCamera::Error)));
|
||||
|
@ -41,7 +41,10 @@ QQrDecoder::QQrDecoder(QWidget *parent): QMainWindow(parent), decoder(this)
|
||||
ui.setupUi(this);
|
||||
connect(ui.centralwidget, SIGNAL(imageCaptured(QImage)), this, SLOT(decodeImage(QImage)));
|
||||
connect(&decoder, SIGNAL(tagFound(QString)), this, SLOT(reportTagFound(QString)));
|
||||
decoder.setDecoder( QZXing::DecoderFormat_DATA_MATRIX);//DecoderFormat_QR_CODE | DecoderFormat_EAN_13 );
|
||||
|
||||
//by default all decoders available are enabled
|
||||
//decoder.setDecoder( QZXing::DecoderFormat_DATA_MATRIX);
|
||||
//decoder.setDecoder( QZXing::DecoderFormat_Aztec );
|
||||
}
|
||||
|
||||
QQrDecoder::~QQrDecoder()
|
||||
|
@ -4,7 +4,7 @@ QT += core \
|
||||
gui \
|
||||
declarative
|
||||
|
||||
VERSION = 1.2.1
|
||||
VERSION = 1.3.0
|
||||
|
||||
CONFIG += mobility
|
||||
MOBILITY = multimedia #\
|
||||
|
@ -1,5 +1,5 @@
|
||||
// ============================================================================
|
||||
// * Generated by qmake (2.01a) (Qt 4.7.3) on: 2011-11-29T12:15:30
|
||||
// * Generated by qmake (2.01a) (Qt 4.7.3) on: 2012-05-14T15:44:30
|
||||
// * This file is generated by qmake and should not be modified by the
|
||||
// * user.
|
||||
// ============================================================================
|
||||
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 38 KiB |
@ -1,5 +1,5 @@
|
||||
// ============================================================================
|
||||
// * Generated by qmake (2.01a) (Qt 4.7.3) on: 2011-11-29T12:15:30
|
||||
// * Generated by qmake (2.01a) (Qt 4.7.3) on: 2012-05-14T15:44:30
|
||||
// * This file is generated by qmake and should not be modified by the
|
||||
// * user.
|
||||
// ============================================================================
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
#if QT_VERSION >= 0x040700
|
||||
static void registerQMLTypes()
|
||||
{
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 0, "QZXing");
|
||||
qmlRegisterType<QZXing>("QZXing", 1, 2, "QZXing");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -61,6 +61,19 @@ public slots:
|
||||
*/
|
||||
QString decodeImage(QImage image);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML
|
||||
*/
|
||||
QString decodeImageQML(QObject *item);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML. Able to set the decoding
|
||||
* of a portion of the image.
|
||||
*/
|
||||
QString decodeSubImageQML(QObject* item,
|
||||
const double offsetX = 0 , const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
|
||||
signals:
|
||||
void decodingStarted();
|
||||
void decodingFinished(bool succeeded);
|
||||
@ -69,6 +82,7 @@ signals:
|
||||
private:
|
||||
void* decoder;
|
||||
DecoderFormatType supportedFormats;
|
||||
QObject* imageHandler;
|
||||
};
|
||||
|
||||
#endif // QZXING_H
|
||||
|
@ -23,6 +23,7 @@ INCLUDEPATH += ./
|
||||
|
||||
HEADERS += QZXing_global.h \
|
||||
CameraImageWrapper.h \
|
||||
imagehandler.h \
|
||||
qzxing.h \
|
||||
zxing/ResultPointCallback.h \
|
||||
zxing/ResultPoint.h \
|
||||
@ -115,6 +116,7 @@ HEADERS += QZXing_global.h \
|
||||
|
||||
SOURCES += CameraImageWrapper.cpp \
|
||||
qzxing.cpp \
|
||||
imagehandler.cpp \
|
||||
zxing/ResultPointCallback.cpp \
|
||||
zxing/ResultPoint.cpp \
|
||||
zxing/Result.cpp \
|
||||
@ -209,13 +211,13 @@ symbian {
|
||||
addFiles.sources = QZXing.dll
|
||||
addFiles.path = !:/sys/bin
|
||||
DEPLOYMENT += addFiles
|
||||
#TARGET.CAPABILITY = All -TCB -AllFiles -DRM
|
||||
TARGET.CAPABILITY += NetworkServices \
|
||||
ReadUserData \
|
||||
WriteUserData \
|
||||
LocalServices \
|
||||
UserEnvironment \
|
||||
Location
|
||||
TARGET.CAPABILITY = All -TCB -AllFiles -DRM
|
||||
# TARGET.CAPABILITY += NetworkServices \
|
||||
# ReadUserData \
|
||||
# WriteUserData \
|
||||
# LocalServices \
|
||||
# UserEnvironment \
|
||||
# Location
|
||||
}
|
||||
|
||||
unix:!symbian {
|
||||
@ -234,18 +236,18 @@ win32{
|
||||
}
|
||||
|
||||
OTHER_FILES += \
|
||||
qtc_packaging/debian_fremantle/rules \
|
||||
qtc_packaging/debian_fremantle/README \
|
||||
qtc_packaging/debian_fremantle/copyright \
|
||||
qtc_packaging/debian_fremantle/control \
|
||||
qtc_packaging/debian_fremantle/compat \
|
||||
qtc_packaging/debian_fremantle/changelog \
|
||||
qtc_packaging/debian_harmattan/rules \
|
||||
qtc_packaging/debian_harmattan/README \
|
||||
qtc_packaging/debian_harmattan/manifest.aegis \
|
||||
qtc_packaging/debian_harmattan/copyright \
|
||||
qtc_packaging/debian_harmattan/control \
|
||||
qtc_packaging/debian_harmattan/compat \
|
||||
qtc_packaging/debian_harmattan/changelog \
|
||||
qtc_packaging/debian_fremantle/rules \
|
||||
qtc_packaging/debian_fremantle/README \
|
||||
qtc_packaging/debian_fremantle/copyright \
|
||||
qtc_packaging/debian_fremantle/control \
|
||||
qtc_packaging/debian_fremantle/compat \
|
||||
qtc_packaging/debian_fremantle/changelog
|
||||
qtc_packaging/debian_harmattan/changelog
|
||||
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#ifndef QZXING_GLOBAL_H
|
||||
#define QZXING_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore>
|
||||
#include <qglobal.h>
|
||||
|
||||
#if defined(QZXING_LIBRARY)
|
||||
# define QZXINGSHARED_EXPORT Q_DECL_EXPORT
|
||||
@ -9,4 +10,4 @@
|
||||
# define QZXINGSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // QZXING_GLOBAL_H
|
||||
#endif //QZXING_GLOBAL_H
|
||||
|
BIN
source/QZXing_unsigned.sis
Normal file
BIN
source/QZXing_unsigned.sis
Normal file
Binary file not shown.
118
source/eabi/QZXingu.def
Normal file
118
source/eabi/QZXingu.def
Normal file
@ -0,0 +1,118 @@
|
||||
EXPORTS
|
||||
_ZN6QZXing10setDecoderEj @ 1 NONAME
|
||||
_ZN6QZXing11decodeImageE6QImage @ 2 NONAME
|
||||
_ZN6QZXing11qt_metacallEN11QMetaObject4CallEiPPv @ 3 NONAME
|
||||
_ZN6QZXing11qt_metacastEPKc @ 4 NONAME
|
||||
_ZN6QZXing14decodeImageQMLEP7QObject @ 5 NONAME
|
||||
_ZN6QZXing15decodingStartedEv @ 6 NONAME
|
||||
_ZN6QZXing16decodingFinishedEb @ 7 NONAME
|
||||
_ZN6QZXing16staticMetaObjectE @ 8 NONAME DATA 16
|
||||
_ZN6QZXing17decodeSubImageQMLEP7QObjectdddd @ 9 NONAME
|
||||
_ZN6QZXing19getStaticMetaObjectEv @ 10 NONAME
|
||||
_ZN6QZXing8tagFoundE7QString @ 11 NONAME
|
||||
_ZN6QZXingC1EP7QObject @ 12 NONAME
|
||||
_ZN6QZXingC2EP7QObject @ 13 NONAME
|
||||
_ZNK6QZXing10metaObjectEv @ 14 NONAME
|
||||
_ZTI12ImageHandler @ 15 NONAME
|
||||
_ZTI18CameraImageWrapper @ 16 NONAME
|
||||
_ZTI6QZXing @ 17 NONAME
|
||||
_ZTIN5zxing10datamatrix16DataMatrixReaderE @ 18 NONAME
|
||||
_ZTIN5zxing10datamatrix17DetectorExceptionE @ 19 NONAME
|
||||
_ZTIN5zxing10datamatrix7VersionE @ 20 NONAME
|
||||
_ZTIN5zxing10datamatrix8DetectorE @ 21 NONAME
|
||||
_ZTIN5zxing11ResultPointE @ 22 NONAME
|
||||
_ZTIN5zxing12BinaryBitmapE @ 23 NONAME
|
||||
_ZTIN5zxing15FormatExceptionE @ 24 NONAME
|
||||
_ZTIN5zxing15HybridBinarizerE @ 25 NONAME
|
||||
_ZTIN5zxing15LuminanceSourceE @ 26 NONAME
|
||||
_ZTIN5zxing15ReaderExceptionE @ 27 NONAME
|
||||
_ZTIN5zxing17MultiFormatReaderE @ 28 NONAME
|
||||
_ZTIN5zxing17NotFoundExceptionE @ 29 NONAME
|
||||
_ZTIN5zxing19ResultPointCallbackE @ 30 NONAME
|
||||
_ZTIN5zxing20ReedSolomonExceptionE @ 31 NONAME
|
||||
_ZTIN5zxing24GlobalHistogramBinarizerE @ 32 NONAME
|
||||
_ZTIN5zxing24GreyscaleLuminanceSourceE @ 33 NONAME
|
||||
_ZTIN5zxing24IllegalArgumentExceptionE @ 34 NONAME
|
||||
_ZTIN5zxing31GreyscaleRotatedLuminanceSourceE @ 35 NONAME
|
||||
_ZTIN5zxing4oned10EAN8ReaderE @ 36 NONAME
|
||||
_ZTIN5zxing4oned10OneDReaderE @ 37 NONAME
|
||||
_ZTIN5zxing4oned10UPCAReaderE @ 38 NONAME
|
||||
_ZTIN5zxing4oned10UPCEReaderE @ 39 NONAME
|
||||
_ZTIN5zxing4oned11EAN13ReaderE @ 40 NONAME
|
||||
_ZTIN5zxing4oned12Code39ReaderE @ 41 NONAME
|
||||
_ZTIN5zxing4oned12UPCEANReaderE @ 42 NONAME
|
||||
_ZTIN5zxing4oned13Code128ReaderE @ 43 NONAME
|
||||
_ZTIN5zxing4oned21MultiFormatOneDReaderE @ 44 NONAME
|
||||
_ZTIN5zxing4oned23MultiFormatUPCEANReaderE @ 45 NONAME
|
||||
_ZTIN5zxing4oned9ITFReaderE @ 46 NONAME
|
||||
_ZTIN5zxing5aztec11AztecReaderE @ 47 NONAME
|
||||
_ZTIN5zxing5multi13MultiDetectorE @ 48 NONAME
|
||||
_ZTIN5zxing5multi16ByQuadrantReaderE @ 49 NONAME
|
||||
_ZTIN5zxing5multi17QRCodeMultiReaderE @ 50 NONAME
|
||||
_ZTIN5zxing5multi21MultipleBarcodeReaderE @ 51 NONAME
|
||||
_ZTIN5zxing5multi24MultiFinderPatternFinderE @ 52 NONAME
|
||||
_ZTIN5zxing5multi28GenericMultipleBarcodeReaderE @ 53 NONAME
|
||||
_ZTIN5zxing6ReaderE @ 54 NONAME
|
||||
_ZTIN5zxing6ResultE @ 55 NONAME
|
||||
_ZTIN5zxing6qrcode12QRCodeReaderE @ 56 NONAME
|
||||
_ZTIN5zxing6qrcode14QREdgeDetectorE @ 57 NONAME
|
||||
_ZTIN5zxing6qrcode22AlignmentPatternFinderE @ 58 NONAME
|
||||
_ZTIN5zxing6qrcode7VersionE @ 59 NONAME
|
||||
_ZTIN5zxing6qrcode8DataMaskE @ 60 NONAME
|
||||
_ZTIN5zxing6qrcode8DetectorE @ 61 NONAME
|
||||
_ZTIN5zxing8BitArrayE @ 62 NONAME
|
||||
_ZTIN5zxing9BinarizerE @ 63 NONAME
|
||||
_ZTIN5zxing9BitMatrixE @ 64 NONAME
|
||||
_ZTIN5zxing9ExceptionE @ 65 NONAME
|
||||
_ZTV12ImageHandler @ 66 NONAME
|
||||
_ZTV18CameraImageWrapper @ 67 NONAME
|
||||
_ZTV6QZXing @ 68 NONAME
|
||||
_ZTVN5zxing10datamatrix16DataMatrixReaderE @ 69 NONAME
|
||||
_ZTVN5zxing10datamatrix17DetectorExceptionE @ 70 NONAME
|
||||
_ZTVN5zxing10datamatrix7VersionE @ 71 NONAME
|
||||
_ZTVN5zxing10datamatrix8DetectorE @ 72 NONAME
|
||||
_ZTVN5zxing11ResultPointE @ 73 NONAME
|
||||
_ZTVN5zxing12BinaryBitmapE @ 74 NONAME
|
||||
_ZTVN5zxing15FormatExceptionE @ 75 NONAME
|
||||
_ZTVN5zxing15HybridBinarizerE @ 76 NONAME
|
||||
_ZTVN5zxing15LuminanceSourceE @ 77 NONAME
|
||||
_ZTVN5zxing15ReaderExceptionE @ 78 NONAME
|
||||
_ZTVN5zxing17MultiFormatReaderE @ 79 NONAME
|
||||
_ZTVN5zxing17NotFoundExceptionE @ 80 NONAME
|
||||
_ZTVN5zxing19ResultPointCallbackE @ 81 NONAME
|
||||
_ZTVN5zxing20ReedSolomonExceptionE @ 82 NONAME
|
||||
_ZTVN5zxing24GlobalHistogramBinarizerE @ 83 NONAME
|
||||
_ZTVN5zxing24GreyscaleLuminanceSourceE @ 84 NONAME
|
||||
_ZTVN5zxing24IllegalArgumentExceptionE @ 85 NONAME
|
||||
_ZTVN5zxing31GreyscaleRotatedLuminanceSourceE @ 86 NONAME
|
||||
_ZTVN5zxing4oned10EAN8ReaderE @ 87 NONAME
|
||||
_ZTVN5zxing4oned10OneDReaderE @ 88 NONAME
|
||||
_ZTVN5zxing4oned10UPCAReaderE @ 89 NONAME
|
||||
_ZTVN5zxing4oned10UPCEReaderE @ 90 NONAME
|
||||
_ZTVN5zxing4oned11EAN13ReaderE @ 91 NONAME
|
||||
_ZTVN5zxing4oned12Code39ReaderE @ 92 NONAME
|
||||
_ZTVN5zxing4oned12UPCEANReaderE @ 93 NONAME
|
||||
_ZTVN5zxing4oned13Code128ReaderE @ 94 NONAME
|
||||
_ZTVN5zxing4oned21MultiFormatOneDReaderE @ 95 NONAME
|
||||
_ZTVN5zxing4oned23MultiFormatUPCEANReaderE @ 96 NONAME
|
||||
_ZTVN5zxing4oned9ITFReaderE @ 97 NONAME
|
||||
_ZTVN5zxing5aztec11AztecReaderE @ 98 NONAME
|
||||
_ZTVN5zxing5multi13MultiDetectorE @ 99 NONAME
|
||||
_ZTVN5zxing5multi16ByQuadrantReaderE @ 100 NONAME
|
||||
_ZTVN5zxing5multi17QRCodeMultiReaderE @ 101 NONAME
|
||||
_ZTVN5zxing5multi21MultipleBarcodeReaderE @ 102 NONAME
|
||||
_ZTVN5zxing5multi24MultiFinderPatternFinderE @ 103 NONAME
|
||||
_ZTVN5zxing5multi28GenericMultipleBarcodeReaderE @ 104 NONAME
|
||||
_ZTVN5zxing6ReaderE @ 105 NONAME
|
||||
_ZTVN5zxing6ResultE @ 106 NONAME
|
||||
_ZTVN5zxing6qrcode12QRCodeReaderE @ 107 NONAME
|
||||
_ZTVN5zxing6qrcode14QREdgeDetectorE @ 108 NONAME
|
||||
_ZTVN5zxing6qrcode22AlignmentPatternFinderE @ 109 NONAME
|
||||
_ZTVN5zxing6qrcode7VersionE @ 110 NONAME
|
||||
_ZTVN5zxing6qrcode8DataMaskE @ 111 NONAME
|
||||
_ZTVN5zxing6qrcode8DetectorE @ 112 NONAME
|
||||
_ZTVN5zxing8BitArrayE @ 113 NONAME
|
||||
_ZTVN5zxing9BinarizerE @ 114 NONAME
|
||||
_ZTVN5zxing9BitMatrixE @ 115 NONAME
|
||||
_ZTVN5zxing9ExceptionE @ 116 NONAME
|
||||
|
44
source/imagehandler.cpp
Normal file
44
source/imagehandler.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "imagehandler.h"
|
||||
#include <QGraphicsObject>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QDebug>
|
||||
|
||||
ImageHandler::ImageHandler(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QImage ImageHandler::extractQImage(QObject *imageObj,
|
||||
const double offsetX, const double offsetY,
|
||||
const double width, const double height)
|
||||
{
|
||||
QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);
|
||||
|
||||
if (!item) {
|
||||
qDebug() << "Item is NULL";
|
||||
return QImage();
|
||||
}
|
||||
|
||||
QImage img(item->boundingRect().size().toSize(), QImage::Format_RGB32);
|
||||
img.fill(QColor(255, 255, 255).rgb());
|
||||
QPainter painter(&img);
|
||||
QStyleOptionGraphicsItem styleOption;
|
||||
item->paint(&painter, &styleOption);
|
||||
|
||||
if(offsetX == 0 && offsetY == 0 && width == 0 && height == 0)
|
||||
return img;
|
||||
else
|
||||
{
|
||||
return img.copy(offsetX, offsetY, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageHandler::save(QObject *imageObj, const QString &path,
|
||||
const double offsetX, const double offsetY,
|
||||
const double width, const double height)
|
||||
{
|
||||
QImage img = extractQImage(imageObj, offsetX, offsetY, width, height);
|
||||
img.save(path);
|
||||
}
|
23
source/imagehandler.h
Normal file
23
source/imagehandler.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef IMAGEHANDLER_H
|
||||
#define IMAGEHANDLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QImage>
|
||||
|
||||
class ImageHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ImageHandler(QObject *parent = 0);
|
||||
|
||||
QImage extractQImage(QObject *imageObj,
|
||||
const double offsetX = 0 , const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
|
||||
public slots:
|
||||
void save(QObject *item, const QString &path,
|
||||
const double offsetX = 0, const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
};
|
||||
|
||||
#endif // IMAGEHANDLER_H
|
BIN
source/libQZXing.so
Normal file
BIN
source/libQZXing.so
Normal file
Binary file not shown.
BIN
source/libQZXing.so.1
Normal file
BIN
source/libQZXing.so.1
Normal file
Binary file not shown.
BIN
source/libQZXing.so.1.2
Normal file
BIN
source/libQZXing.so.1.2
Normal file
Binary file not shown.
BIN
source/libQZXing.so.1.2.0
Normal file
BIN
source/libQZXing.so.1.2.0
Normal file
Binary file not shown.
@ -3,4 +3,4 @@ The Debian Package qzxing
|
||||
|
||||
Comments regarding the Package
|
||||
|
||||
-- unknown <> Wed, 16 Nov 2011 18:02:42 +0200
|
||||
-- unknown <> Mon, 14 May 2012 15:23:23 +0300
|
||||
|
@ -2,4 +2,4 @@ qzxing (0.0.1) unstable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
-- unknown <> Wed, 16 Nov 2011 18:02:42 +0200
|
||||
-- unknown <> Mon, 14 May 2012 15:23:23 +0300
|
||||
|
@ -12,4 +12,3 @@ Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: <insert up to 60 chars description>
|
||||
<insert long description, indented with spaces>
|
||||
XSBC-Maemo-Display-Name: QZXing
|
||||
XB-Maemo-Icon-26:
|
||||
|
@ -1,5 +1,5 @@
|
||||
This package was debianized by unknown <> on
|
||||
Wed, 16 Nov 2011 18:02:42 +0200.
|
||||
Mon, 14 May 2012 15:23:23 +0300.
|
||||
|
||||
It was downloaded from <url://example.com>
|
||||
|
||||
@ -32,7 +32,7 @@ License:
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License can be found in `/usr/share/common-licenses/GPL'.
|
||||
|
||||
The Debian packaging is (C) 2011, unknown <> and
|
||||
The Debian packaging is (C) 2012, unknown <> and
|
||||
is licensed under the GPL, see above.
|
||||
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
AutoGenerateAegisFile
|
||||
<!-- Aegis manifest declares the security credentials required by an
|
||||
application to run correctly. By default, a manifest file will be
|
||||
created or updated automatically as a part of build.
|
||||
|
||||
The detection of required credentials is based on static scan of
|
||||
application binaries. In some cases, the scan may not be able to
|
||||
detect the correct set of permissions. If this is the case, you must
|
||||
declare the credentials required by your application in this file.
|
||||
|
||||
To create a manifest file automatically as a part of build (DEFAULT):
|
||||
|
||||
* Make sure this file starts with the string "AutoGenerateAegisFile" (without quotes).
|
||||
* Alternatively, it can also be completely empty.
|
||||
|
||||
To provide a manifest yourself:
|
||||
|
||||
* List the correct credentials for the application in this file.
|
||||
* Some commented-out examples of often required tokens are provided.
|
||||
* Ensure the path to your application binary given in
|
||||
'<for path="/path/to/app" />' is correct.
|
||||
* Please do not request more credentials than what your application
|
||||
actually requires.
|
||||
|
||||
To disable manifest file:
|
||||
|
||||
* Replace this file with a file starting with the string "NoAegisFile" (without quotes).
|
||||
* Final application package will not contain a manifest.
|
||||
|
||||
-->
|
||||
<aegis>
|
||||
<request policy="add">
|
||||
|
||||
<!-- Make a GSM call, send text messages (SMS). -->
|
||||
<!--
|
||||
<credential name="Cellular" />
|
||||
-->
|
||||
|
||||
<!-- Access Facebook social data. -->
|
||||
<!--
|
||||
<credential name="FacebookSocial" />
|
||||
-->
|
||||
|
||||
<!-- Read access to data stored in tracker. -->
|
||||
<!--
|
||||
<credential name="TrackerReadAccess" />
|
||||
-->
|
||||
|
||||
<!-- Read and write access to data stored in tracker. -->
|
||||
<!--
|
||||
<credential name="TrackerWriteAccess" />
|
||||
-->
|
||||
|
||||
<!-- Read Location information. -->
|
||||
<!--
|
||||
<credential name="Location" />
|
||||
-->
|
||||
|
||||
<!-- Access to Audio, Multimedia and Camera. -->
|
||||
<!--
|
||||
<credential name="GRP::pulse-access" />
|
||||
<credential name="GRP::video" />
|
||||
<credential name="GRP::audio" />
|
||||
-->
|
||||
|
||||
</request>
|
||||
|
||||
<for path="/opt/QZXing/bin/QZXing" />
|
||||
<for path="applauncherd-launcher::/usr/bin/applauncherd.bin" id="" />
|
||||
</aegis>
|
@ -6,6 +6,7 @@
|
||||
#include <zxing/MultiFormatReader.h>
|
||||
#include <zxing/DecodeHints.h>
|
||||
#include "CameraImageWrapper.h"
|
||||
#include "imagehandler.h"
|
||||
|
||||
using namespace zxing;
|
||||
|
||||
@ -20,7 +21,9 @@ QZXing::QZXing(QObject *parent) : QObject(parent)
|
||||
DecoderFormat_EAN_13 |
|
||||
DecoderFormat_CODE_128 |
|
||||
DecoderFormat_CODE_39 |
|
||||
DecoderFormat_ITF);
|
||||
DecoderFormat_ITF |
|
||||
DecoderFormat_Aztec);
|
||||
imageHandler = new ImageHandler();
|
||||
}
|
||||
|
||||
void QZXing::setDecoder(DecoderFormatType hint)
|
||||
@ -87,3 +90,25 @@ QString QZXing::decodeImage(QImage image)
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
QString QZXing::decodeImageQML(QObject *item)
|
||||
{
|
||||
return decodeSubImageQML(item);
|
||||
}
|
||||
|
||||
QString QZXing::decodeSubImageQML(QObject* item,
|
||||
const double offsetX, const double offsetY,
|
||||
const double width, const double height)
|
||||
{
|
||||
if(item == NULL)
|
||||
{
|
||||
emit decodingFinished(false);
|
||||
return "";
|
||||
}
|
||||
|
||||
QImage img = ((ImageHandler*)imageHandler)->extractQImage(item, offsetX, offsetY, width, height);
|
||||
|
||||
return decodeImage(img);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace zxing {
|
||||
compact_(compact),
|
||||
nbDatablocks_(nbDatablocks),
|
||||
nbLayers_(nbLayers) {
|
||||
};
|
||||
}
|
||||
|
||||
bool AztecDetectorResult::isCompact() {
|
||||
return compact_;
|
||||
@ -42,4 +42,4 @@ namespace zxing {
|
||||
return nbLayers_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace zxing {
|
||||
|
||||
AztecReader::AztecReader() : decoder_() {
|
||||
// nothing
|
||||
};
|
||||
}
|
||||
|
||||
Ref<Result> AztecReader::decode(Ref<zxing::BinaryBitmap> image) {
|
||||
Detector detector(image->getBlackMatrix());
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <zxing/common/reedsolomon/GenericGF.h>
|
||||
#include <zxing/common/IllegalArgumentException.h>
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
using zxing::aztec::Decoder;
|
||||
using zxing::DecoderResult;
|
||||
using zxing::String;
|
||||
@ -49,7 +51,13 @@ namespace {
|
||||
char* ds = d;
|
||||
size_t dl = sizeof(d);
|
||||
iconv_t ic = iconv_open("UTF-8", "ISO-8859-1");
|
||||
iconv(ic, (const char**)&ss, &sl, &ds, &dl);
|
||||
|
||||
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
iconv(ic, (const char**)&ss, &sl, &ds, &dl); // for Symbian and Mingw
|
||||
#else
|
||||
iconv(ic, (char**)&ss, &sl, &ds, &dl); // for Harmattan
|
||||
#endif
|
||||
iconv_close(ic);
|
||||
d[sizeof(d)-dl] = 0;
|
||||
result.append(d);
|
||||
@ -281,7 +289,7 @@ Ref<String> Decoder::getEncodedData(Ref<zxing::BitArray> correctedBits) {
|
||||
|
||||
}
|
||||
|
||||
Ref<BitArray> Decoder::correctBits(Ref<zxing::BitArray> rawbits) {
|
||||
Ref<zxing::BitArray> Decoder::correctBits(Ref<zxing::BitArray> rawbits) {
|
||||
//return rawbits;
|
||||
// std::printf("decoding stuff:%d datablocks in %d layers\n", ddata_->getNBDatablocks(), ddata_->getNBLayers());
|
||||
|
||||
@ -333,10 +341,10 @@ Ref<BitArray> Decoder::correctBits(Ref<zxing::BitArray> rawbits) {
|
||||
// std::printf("trying reed solomon, numECCodewords:%d\n", numECCodewords);
|
||||
ReedSolomonDecoder rsDecoder(gf);
|
||||
rsDecoder.decode(dataWords, numECCodewords);
|
||||
} catch (ReedSolomonException rse) {
|
||||
} catch (ReedSolomonException& rse) {
|
||||
// std::printf("got reed solomon exception:%s, throwing formatexception\n", rse.what());
|
||||
throw FormatException("rs decoding failed");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
} catch (IllegalArgumentException& iae) {
|
||||
// std::printf("illegal argument exception: %s", iae.what());
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ void Detector::correctParameterData(Ref<zxing::BitArray> parameterData, bool com
|
||||
// std::printf("parameter data reed solomon\n");
|
||||
ReedSolomonDecoder rsDecoder(GenericGF::AZTEC_PARAM);
|
||||
rsDecoder.decode(parameterWords, numECCodewords);
|
||||
} catch (ReedSolomonException e) {
|
||||
} catch (ReedSolomonException& e) {
|
||||
// std::printf("reed solomon decoding failed\n");
|
||||
throw ReaderException("failed to decode parameter data");
|
||||
}
|
||||
@ -302,7 +302,7 @@ Ref<Point> Detector::getMatrixCenter() {
|
||||
pointC = cornerPoints[2];
|
||||
pointD = cornerPoints[3];
|
||||
|
||||
} catch (NotFoundException e) {
|
||||
} catch (NotFoundException& e) {
|
||||
|
||||
int cx = image_->getWidth() / 2;
|
||||
int cy = image_->getHeight() / 2;
|
||||
@ -325,7 +325,7 @@ Ref<Point> Detector::getMatrixCenter() {
|
||||
pointC = cornerPoints[2];
|
||||
pointD = cornerPoints[3];
|
||||
|
||||
} catch (NotFoundException e) {
|
||||
} catch (NotFoundException& e) {
|
||||
|
||||
pointA = getFirstDifferent(Ref<Point>(new Point(cx+15/2, cy-15/2)), false, 1, -1)->toResultPoint();
|
||||
pointB = getFirstDifferent(Ref<Point>(new Point(cx+15/2, cy+15/2)), false, 1, 1)->toResultPoint();
|
||||
|
@ -36,28 +36,28 @@ Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image, DecodeHints hints)
|
||||
Ref<BinaryBitmap> topLeft = image->crop(0, 0, halfWidth, halfHeight);
|
||||
try {
|
||||
return delegate_.decode(topLeft, hints);
|
||||
} catch (ReaderException re) {
|
||||
} catch (ReaderException& re) {
|
||||
// continue
|
||||
}
|
||||
|
||||
Ref<BinaryBitmap> topRight = image->crop(halfWidth, 0, halfWidth, halfHeight);
|
||||
try {
|
||||
return delegate_.decode(topRight, hints);
|
||||
} catch (ReaderException re) {
|
||||
} catch (ReaderException& re) {
|
||||
// continue
|
||||
}
|
||||
|
||||
Ref<BinaryBitmap> bottomLeft = image->crop(0, halfHeight, halfWidth, halfHeight);
|
||||
try {
|
||||
return delegate_.decode(bottomLeft, hints);
|
||||
} catch (ReaderException re) {
|
||||
} catch (ReaderException& re) {
|
||||
// continue
|
||||
}
|
||||
|
||||
Ref<BinaryBitmap> bottomRight = image->crop(halfWidth, halfHeight, halfWidth, halfHeight);
|
||||
try {
|
||||
return delegate_.decode(bottomRight, hints);
|
||||
} catch (ReaderException re) {
|
||||
} catch (ReaderException& re) {
|
||||
// continue
|
||||
}
|
||||
|
||||
|
@ -21,107 +21,107 @@
|
||||
namespace zxing {
|
||||
namespace multi {
|
||||
GenericMultipleBarcodeReader::GenericMultipleBarcodeReader(Reader& delegate) :
|
||||
delegate_(delegate)
|
||||
delegate_(delegate)
|
||||
{
|
||||
}
|
||||
|
||||
GenericMultipleBarcodeReader::~GenericMultipleBarcodeReader(){}
|
||||
|
||||
std::vector<Ref<Result> > GenericMultipleBarcodeReader::decodeMultiple(
|
||||
Ref<BinaryBitmap> image, DecodeHints hints)
|
||||
Ref<BinaryBitmap> image, DecodeHints hints)
|
||||
{
|
||||
std::vector<Ref<Result> > results;
|
||||
doDecodeMultiple(image, hints, results, 0, 0);
|
||||
if (results.empty()){
|
||||
throw ReaderException("No code detected");
|
||||
}
|
||||
return results;
|
||||
std::vector<Ref<Result> > results;
|
||||
doDecodeMultiple(image, hints, results, 0, 0);
|
||||
if (results.empty()){
|
||||
throw ReaderException("No code detected");
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
void GenericMultipleBarcodeReader::doDecodeMultiple(Ref<BinaryBitmap> image,
|
||||
DecodeHints hints, std::vector<Ref<Result> >& results, int xOffset, int yOffset)
|
||||
DecodeHints hints, std::vector<Ref<Result> >& results, int xOffset, int yOffset)
|
||||
{
|
||||
Ref<Result> result;
|
||||
try {
|
||||
result = delegate_.decode(image, hints);
|
||||
} catch (ReaderException re) {
|
||||
return;
|
||||
}
|
||||
bool alreadyFound = false;
|
||||
for (unsigned int i = 0; i < results.size(); i++) {
|
||||
Ref<Result> existingResult = results[i];
|
||||
if (existingResult->getText()->getText() == result->getText()->getText()) {
|
||||
alreadyFound = true;
|
||||
break;
|
||||
Ref<Result> result;
|
||||
try {
|
||||
result = delegate_.decode(image, hints);
|
||||
} catch (ReaderException& re) {
|
||||
return;
|
||||
}
|
||||
bool alreadyFound = false;
|
||||
for (unsigned int i = 0; i < results.size(); i++) {
|
||||
Ref<Result> existingResult = results[i];
|
||||
if (existingResult->getText()->getText() == result->getText()->getText()) {
|
||||
alreadyFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (alreadyFound) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (alreadyFound) {
|
||||
return;
|
||||
}
|
||||
|
||||
results.push_back(translateResultPoints(result, xOffset, yOffset));
|
||||
const std::vector<Ref<ResultPoint> > resultPoints = result->getResultPoints();
|
||||
if (resultPoints.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int width = image->getWidth();
|
||||
int height = image->getHeight();
|
||||
float minX = width;
|
||||
float minY = height;
|
||||
float maxX = 0.0f;
|
||||
float maxY = 0.0f;
|
||||
for (unsigned int i = 0; i < resultPoints.size(); i++) {
|
||||
Ref<ResultPoint> point = resultPoints[i];
|
||||
float x = point->getX();
|
||||
float y = point->getY();
|
||||
if (x < minX) {
|
||||
minX = x;
|
||||
results.push_back(translateResultPoints(result, xOffset, yOffset));
|
||||
const std::vector<Ref<ResultPoint> > resultPoints = result->getResultPoints();
|
||||
if (resultPoints.empty()) {
|
||||
return;
|
||||
}
|
||||
if (y < minY) {
|
||||
minY = y;
|
||||
}
|
||||
if (x > maxX) {
|
||||
maxX = x;
|
||||
}
|
||||
if (y > maxY) {
|
||||
maxY = y;
|
||||
}
|
||||
}
|
||||
|
||||
// Decode left of barcode
|
||||
if (minX > MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop(0, 0, (int) minX, height),
|
||||
hints, results, xOffset, yOffset);
|
||||
}
|
||||
// Decode above barcode
|
||||
if (minY > MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop(0, 0, width, (int) minY),
|
||||
hints, results, xOffset, yOffset);
|
||||
}
|
||||
// Decode right of barcode
|
||||
if (maxX < width - MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop((int) maxX, 0, width - (int) maxX, height),
|
||||
hints, results, xOffset + (int) maxX, yOffset);
|
||||
}
|
||||
// Decode below barcode
|
||||
if (maxY < height - MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop(0, (int) maxY, width, height - (int) maxY),
|
||||
hints, results, xOffset, yOffset + (int) maxY);
|
||||
}
|
||||
int width = image->getWidth();
|
||||
int height = image->getHeight();
|
||||
float minX = width;
|
||||
float minY = height;
|
||||
float maxX = 0.0f;
|
||||
float maxY = 0.0f;
|
||||
for (unsigned int i = 0; i < resultPoints.size(); i++) {
|
||||
Ref<ResultPoint> point = resultPoints[i];
|
||||
float x = point->getX();
|
||||
float y = point->getY();
|
||||
if (x < minX) {
|
||||
minX = x;
|
||||
}
|
||||
if (y < minY) {
|
||||
minY = y;
|
||||
}
|
||||
if (x > maxX) {
|
||||
maxX = x;
|
||||
}
|
||||
if (y > maxY) {
|
||||
maxY = y;
|
||||
}
|
||||
}
|
||||
|
||||
// Decode left of barcode
|
||||
if (minX > MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop(0, 0, (int) minX, height),
|
||||
hints, results, xOffset, yOffset);
|
||||
}
|
||||
// Decode above barcode
|
||||
if (minY > MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop(0, 0, width, (int) minY),
|
||||
hints, results, xOffset, yOffset);
|
||||
}
|
||||
// Decode right of barcode
|
||||
if (maxX < width - MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop((int) maxX, 0, width - (int) maxX, height),
|
||||
hints, results, xOffset + (int) maxX, yOffset);
|
||||
}
|
||||
// Decode below barcode
|
||||
if (maxY < height - MIN_DIMENSION_TO_RECUR) {
|
||||
doDecodeMultiple(image->crop(0, (int) maxY, width, height - (int) maxY),
|
||||
hints, results, xOffset, yOffset + (int) maxY);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Result> GenericMultipleBarcodeReader::translateResultPoints(Ref<Result> result, int xOffset, int yOffset){
|
||||
const std::vector<Ref<ResultPoint> > oldResultPoints = result->getResultPoints();
|
||||
if (oldResultPoints.empty()) {
|
||||
return result;
|
||||
}
|
||||
std::vector<Ref<ResultPoint> > newResultPoints;
|
||||
for (unsigned int i = 0; i < oldResultPoints.size(); i++) {
|
||||
Ref<ResultPoint> oldPoint = oldResultPoints[i];
|
||||
newResultPoints.push_back(Ref<ResultPoint>(new ResultPoint(oldPoint->getX() + xOffset, oldPoint->getY() + yOffset)));
|
||||
}
|
||||
return Ref<Result>(new Result(result->getText(), result->getRawBytes(), newResultPoints, result->getBarcodeFormat()));
|
||||
const std::vector<Ref<ResultPoint> > oldResultPoints = result->getResultPoints();
|
||||
if (oldResultPoints.empty()) {
|
||||
return result;
|
||||
}
|
||||
std::vector<Ref<ResultPoint> > newResultPoints;
|
||||
for (unsigned int i = 0; i < oldResultPoints.size(); i++) {
|
||||
Ref<ResultPoint> oldPoint = oldResultPoints[i];
|
||||
newResultPoints.push_back(Ref<ResultPoint>(new ResultPoint(oldPoint->getX() + xOffset, oldPoint->getY() + yOffset)));
|
||||
}
|
||||
return Ref<Result>(new Result(result->getText(), result->getRawBytes(), newResultPoints, result->getBarcodeFormat()));
|
||||
}
|
||||
|
||||
} // End zxing::multi namespace
|
||||
|
@ -43,7 +43,7 @@ std::vector<Ref<Result> > QRCodeMultiReader::decodeMultiple(Ref<BinaryBitmap> im
|
||||
// result->putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult->getByteSegments());
|
||||
// result->putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult->getECLevel().toString());
|
||||
results.push_back(result);
|
||||
} catch (ReaderException re) {
|
||||
} catch (ReaderException& re) {
|
||||
// ignore and continue
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ std::vector<Ref<DetectorResult> > MultiDetector::detectMulti(DecodeHints hints){
|
||||
for(unsigned int i = 0; i < info.size(); i++){
|
||||
try{
|
||||
result.push_back(processFinderPatternInfo(info[i]));
|
||||
} catch (ReaderException e){
|
||||
} catch (ReaderException& e){
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -17,78 +17,83 @@
|
||||
|
||||
#include "EAN13Reader.h"
|
||||
#include <zxing/ReaderException.h>
|
||||
#include <qglobal.h>
|
||||
|
||||
namespace zxing {
|
||||
namespace oned {
|
||||
namespace oned {
|
||||
|
||||
static const int FIRST_DIGIT_ENCODINGS[10] = {
|
||||
0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A
|
||||
};
|
||||
static const int FIRST_DIGIT_ENCODINGS[10] = {
|
||||
0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A
|
||||
};
|
||||
|
||||
EAN13Reader::EAN13Reader() { }
|
||||
EAN13Reader::EAN13Reader() { }
|
||||
|
||||
int EAN13Reader::decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
|
||||
std::string& resultString) {
|
||||
(void)startGuardBegin;
|
||||
const int countersLen = 4;
|
||||
int counters[countersLen] = { 0, 0, 0, 0 };
|
||||
int EAN13Reader::decodeMiddle(Ref<BitArray> row, int startGuardBegin, int startGuardEnd,
|
||||
std::string& resultString) {
|
||||
(void)startGuardBegin;
|
||||
const int countersLen = 4;
|
||||
int counters[countersLen] = { 0, 0, 0, 0 };
|
||||
|
||||
int end = row->getSize();
|
||||
int rowOffset = startGuardEnd;
|
||||
int lgPatternFound = 0;
|
||||
int end = row->getSize();
|
||||
int rowOffset = startGuardEnd;
|
||||
int lgPatternFound = 0;
|
||||
|
||||
for (int x = 0; x < 6 && rowOffset < end; x++) {
|
||||
for (int x = 0; x < 6 && rowOffset < end; x++) {
|
||||
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset,
|
||||
UPC_EAN_PATTERNS_L_AND_G_PATTERNS);
|
||||
UPC_EAN_PATTERNS_L_AND_G_PATTERNS);
|
||||
if (bestMatch < 0) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
resultString.append(1, (char) ('0' + bestMatch % 10));
|
||||
for (int i = 0; i < countersLen; i++) {
|
||||
rowOffset += counters[i];
|
||||
rowOffset += counters[i];
|
||||
}
|
||||
if (bestMatch >= 10) {
|
||||
lgPatternFound |= 1 << (5 - x);
|
||||
lgPatternFound |= 1 << (5 - x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!determineFirstDigit(resultString, lgPatternFound)) {
|
||||
if (!determineFirstDigit(resultString, lgPatternFound)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int middleRangeStart;
|
||||
int middleRangeEnd;
|
||||
if (findGuardPattern(row, rowOffset, true, (int*)getMIDDLE_PATTERN(),
|
||||
getMIDDLE_PATTERN_LEN(), &middleRangeStart, &middleRangeEnd)) {
|
||||
int middleRangeStart;
|
||||
int middleRangeEnd;
|
||||
if (findGuardPattern(row, rowOffset, true, (int*)getMIDDLE_PATTERN(),
|
||||
getMIDDLE_PATTERN_LEN(), &middleRangeStart, &middleRangeEnd)) {
|
||||
rowOffset = middleRangeEnd;
|
||||
for (int x = 0; x < 6 && rowOffset < end; x++) {
|
||||
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset,
|
||||
UPC_EAN_PATTERNS_L_PATTERNS);
|
||||
if (bestMatch < 0) {
|
||||
return -1;
|
||||
}
|
||||
resultString.append(1, (char) ('0' + bestMatch));
|
||||
for (int i = 0; i < countersLen; i++) {
|
||||
rowOffset += counters[i];
|
||||
}
|
||||
int bestMatch = decodeDigit(row, counters, countersLen, rowOffset,
|
||||
UPC_EAN_PATTERNS_L_PATTERNS);
|
||||
if (bestMatch < 0) {
|
||||
return -1;
|
||||
}
|
||||
resultString.append(1, (char) ('0' + bestMatch));
|
||||
for (int i = 0; i < countersLen; i++) {
|
||||
rowOffset += counters[i];
|
||||
}
|
||||
}
|
||||
return rowOffset;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool EAN13Reader::determineFirstDigit(std::string& resultString, int lgPatternFound) {
|
||||
for (int d = 0; d < 10; d++) {
|
||||
if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
|
||||
resultString.insert((char*)0, 1, (char) ('0' + d));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BarcodeFormat EAN13Reader::getBarcodeFormat(){
|
||||
return BarcodeFormat_EAN_13;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool EAN13Reader::determineFirstDigit(std::string& resultString, int lgPatternFound) {
|
||||
for (int d = 0; d < 10; d++) {
|
||||
if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
resultString.insert((char*)0, 1, (char) ('0' + d));
|
||||
#else
|
||||
resultString.insert(/*(char*)*/0, 1, (char) ('0' + d));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BarcodeFormat EAN13Reader::getBarcodeFormat(){
|
||||
return BarcodeFormat_EAN_13;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "UPCEReader.h"
|
||||
#include <zxing/ReaderException.h>
|
||||
#include <qglobal.h>
|
||||
|
||||
namespace zxing {
|
||||
namespace oned {
|
||||
@ -86,7 +87,11 @@ namespace zxing {
|
||||
for (int numSys = 0; numSys <= 1; numSys++) {
|
||||
for (int d = 0; d < 10; d++) {
|
||||
if (lgPatternFound == NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d]) {
|
||||
resultString.insert((char*)0, 1, (char) ('0' + numSys));
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
resultString.insert((char*)0, 1, (char) ((int)'0' + numSys));
|
||||
#else
|
||||
resultString.insert(/*(char*)*/0, 1, (char) ((int)'0' + numSys));
|
||||
#endif
|
||||
resultString.append(1, (char) ('0' + d));
|
||||
return true;
|
||||
}
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include <zxing/FormatException.h>
|
||||
#include <zxing/common/StringUtils.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
#ifndef NO_ICONV
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
@ -55,7 +58,7 @@ namespace {int GB2312_SUBSET = 1;}
|
||||
void DecodedBitStreamParser::append(std::string &result,
|
||||
string const& in,
|
||||
const char *src) {
|
||||
append(result, (unsigned char const*)in.c_str(), in.length(), src);
|
||||
append(result, (unsigned char const*)in.c_str(), in.length(), src);
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::append(std::string &result,
|
||||
@ -63,40 +66,45 @@ void DecodedBitStreamParser::append(std::string &result,
|
||||
size_t nIn,
|
||||
const char *src) {
|
||||
#ifndef NO_ICONV
|
||||
if (nIn == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
iconv_t cd = iconv_open(StringUtils::UTF8, src);
|
||||
if (cd == (iconv_t)-1) {
|
||||
result.append((const char *)bufIn, nIn);
|
||||
return;
|
||||
}
|
||||
|
||||
const int maxOut = 4 * nIn + 1;
|
||||
unsigned char* bufOut = new unsigned char[maxOut];
|
||||
|
||||
/*ICONV_CONST*/ char *fromPtr = (/*ICONV_CONST*/ char *)bufIn;
|
||||
size_t nFrom = nIn;
|
||||
char *toPtr = (char *)bufOut;
|
||||
size_t nTo = maxOut;
|
||||
|
||||
while (nFrom > 0) {
|
||||
size_t oneway = iconv(cd, (const char**)&fromPtr, &nFrom, &toPtr, &nTo);
|
||||
if (oneway == (size_t)(-1)) {
|
||||
iconv_close(cd);
|
||||
delete[] bufOut;
|
||||
throw ReaderException("error converting characters");
|
||||
if (nIn == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
iconv_close(cd);
|
||||
|
||||
int nResult = maxOut - nTo;
|
||||
bufOut[nResult] = '\0';
|
||||
result.append((const char *)bufOut);
|
||||
delete[] bufOut;
|
||||
iconv_t cd = iconv_open(StringUtils::UTF8, src);
|
||||
if (cd == (iconv_t)-1) {
|
||||
result.append((const char *)bufIn, nIn);
|
||||
return;
|
||||
}
|
||||
|
||||
const int maxOut = 4 * nIn + 1;
|
||||
unsigned char* bufOut = new unsigned char[maxOut];
|
||||
|
||||
/*ICONV_CONST*/ char *fromPtr = (/*ICONV_CONST*/ char *)bufIn;
|
||||
size_t nFrom = nIn;
|
||||
char *toPtr = (char *)bufOut;
|
||||
size_t nTo = maxOut;
|
||||
|
||||
while (nFrom > 0) {
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
size_t oneway = iconv(cd, (const char**)&fromPtr, &nFrom, &toPtr, &nTo); // for Symbian and Mingw
|
||||
#else
|
||||
result.append((const char *)bufIn, nIn);
|
||||
size_t oneway = iconv(cd, (char**)&fromPtr, &nFrom, &toPtr, &nTo); // for Harmattan
|
||||
#endif
|
||||
|
||||
if (oneway == (size_t)(-1)) {
|
||||
iconv_close(cd);
|
||||
delete[] bufOut;
|
||||
throw ReaderException("error converting characters");
|
||||
}
|
||||
}
|
||||
iconv_close(cd);
|
||||
|
||||
int nResult = maxOut - nTo;
|
||||
bufOut[nResult] = '\0';
|
||||
result.append((const char *)bufOut);
|
||||
delete[] bufOut;
|
||||
#else
|
||||
result.append((const char *)bufIn, nIn);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -106,7 +114,7 @@ void DecodedBitStreamParser::decodeHanziSegment(Ref<BitSource> bits_,
|
||||
BitSource& bits (*bits_);
|
||||
// Don't crash trying to read more bits than we have available.
|
||||
if (count * 13 > bits.available()) {
|
||||
throw FormatException();
|
||||
throw FormatException();
|
||||
}
|
||||
|
||||
// Each character will require 2 bytes. Read the characters as 2-byte pairs
|
||||
@ -115,58 +123,58 @@ void DecodedBitStreamParser::decodeHanziSegment(Ref<BitSource> bits_,
|
||||
unsigned char* buffer = new unsigned char[nBytes];
|
||||
int offset = 0;
|
||||
while (count > 0) {
|
||||
// Each 13 bits encodes a 2-byte character
|
||||
int twoBytes = bits.readBits(13);
|
||||
int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
|
||||
if (assembledTwoBytes < 0x003BF) {
|
||||
// In the 0xA1A1 to 0xAAFE range
|
||||
assembledTwoBytes += 0x0A1A1;
|
||||
} else {
|
||||
// In the 0xB0A1 to 0xFAFE range
|
||||
assembledTwoBytes += 0x0A6A1;
|
||||
}
|
||||
buffer[offset] = (unsigned char) ((assembledTwoBytes >> 8) & 0xFF);
|
||||
buffer[offset + 1] = (unsigned char) (assembledTwoBytes & 0xFF);
|
||||
offset += 2;
|
||||
count--;
|
||||
// Each 13 bits encodes a 2-byte character
|
||||
int twoBytes = bits.readBits(13);
|
||||
int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
|
||||
if (assembledTwoBytes < 0x003BF) {
|
||||
// In the 0xA1A1 to 0xAAFE range
|
||||
assembledTwoBytes += 0x0A1A1;
|
||||
} else {
|
||||
// In the 0xB0A1 to 0xFAFE range
|
||||
assembledTwoBytes += 0x0A6A1;
|
||||
}
|
||||
buffer[offset] = (unsigned char) ((assembledTwoBytes >> 8) & 0xFF);
|
||||
buffer[offset + 1] = (unsigned char) (assembledTwoBytes & 0xFF);
|
||||
offset += 2;
|
||||
count--;
|
||||
}
|
||||
|
||||
try {
|
||||
append(result, buffer, nBytes, StringUtils::GB2312);
|
||||
append(result, buffer, nBytes, StringUtils::GB2312);
|
||||
} catch (ReaderException const& re) {
|
||||
delete [] buffer;
|
||||
throw FormatException();
|
||||
delete [] buffer;
|
||||
throw FormatException();
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeKanjiSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
// Each character will require 2 bytes. Read the characters as 2-byte pairs
|
||||
// and decode as Shift_JIS afterwards
|
||||
size_t nBytes = 2 * count;
|
||||
unsigned char* buffer = new unsigned char[nBytes];
|
||||
int offset = 0;
|
||||
while (count > 0) {
|
||||
// Each 13 bits encodes a 2-byte character
|
||||
// Each character will require 2 bytes. Read the characters as 2-byte pairs
|
||||
// and decode as Shift_JIS afterwards
|
||||
size_t nBytes = 2 * count;
|
||||
unsigned char* buffer = new unsigned char[nBytes];
|
||||
int offset = 0;
|
||||
while (count > 0) {
|
||||
// Each 13 bits encodes a 2-byte character
|
||||
|
||||
int twoBytes = bits->readBits(13);
|
||||
int assembledTwoBytes = ((twoBytes / 0x0C0) << 8) | (twoBytes % 0x0C0);
|
||||
if (assembledTwoBytes < 0x01F00) {
|
||||
// In the 0x8140 to 0x9FFC range
|
||||
assembledTwoBytes += 0x08140;
|
||||
} else {
|
||||
// In the 0xE040 to 0xEBBF range
|
||||
assembledTwoBytes += 0x0C140;
|
||||
int twoBytes = bits->readBits(13);
|
||||
int assembledTwoBytes = ((twoBytes / 0x0C0) << 8) | (twoBytes % 0x0C0);
|
||||
if (assembledTwoBytes < 0x01F00) {
|
||||
// In the 0x8140 to 0x9FFC range
|
||||
assembledTwoBytes += 0x08140;
|
||||
} else {
|
||||
// In the 0xE040 to 0xEBBF range
|
||||
assembledTwoBytes += 0x0C140;
|
||||
}
|
||||
buffer[offset] = (unsigned char)(assembledTwoBytes >> 8);
|
||||
buffer[offset + 1] = (unsigned char)assembledTwoBytes;
|
||||
offset += 2;
|
||||
count--;
|
||||
}
|
||||
buffer[offset] = (unsigned char)(assembledTwoBytes >> 8);
|
||||
buffer[offset + 1] = (unsigned char)assembledTwoBytes;
|
||||
offset += 2;
|
||||
count--;
|
||||
}
|
||||
|
||||
append(result, buffer, nBytes, StringUtils::SHIFT_JIS);
|
||||
delete[] buffer;
|
||||
append(result, buffer, nBytes, StringUtils::SHIFT_JIS);
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits_,
|
||||
@ -175,163 +183,163 @@ void DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits_,
|
||||
CharacterSetECI* currentCharacterSetECI,
|
||||
ArrayRef< ArrayRef<unsigned char> >& byteSegments,
|
||||
Hashtable const& hints) {
|
||||
int nBytes = count;
|
||||
BitSource& bits (*bits_);
|
||||
// Don't crash trying to read more bits than we have available.
|
||||
if (count << 3 > bits.available()) {
|
||||
throw FormatException();
|
||||
}
|
||||
int nBytes = count;
|
||||
BitSource& bits (*bits_);
|
||||
// Don't crash trying to read more bits than we have available.
|
||||
if (count << 3 > bits.available()) {
|
||||
throw FormatException();
|
||||
}
|
||||
|
||||
ArrayRef<unsigned char> bytes_ (count);
|
||||
unsigned char* readBytes = &(*bytes_)[0];
|
||||
for (int i = 0; i < count; i++) {
|
||||
readBytes[i] = (unsigned char) bits.readBits(8);
|
||||
}
|
||||
string encoding;
|
||||
if (currentCharacterSetECI == 0) {
|
||||
// The spec isn't clear on this mode; see
|
||||
// section 6.4.5: t does not say which encoding to assuming
|
||||
// upon decoding. I have seen ISO-8859-1 used as well as
|
||||
// Shift_JIS -- without anything like an ECI designator to
|
||||
// give a hint.
|
||||
encoding = StringUtils::guessEncoding(readBytes, count, hints);
|
||||
} else {
|
||||
encoding = currentCharacterSetECI->name();
|
||||
}
|
||||
try {
|
||||
append(result, readBytes, nBytes, encoding.c_str());
|
||||
} catch (ReaderException const& re) {
|
||||
throw FormatException();
|
||||
}
|
||||
byteSegments->values().push_back(bytes_);
|
||||
ArrayRef<unsigned char> bytes_ (count);
|
||||
unsigned char* readBytes = &(*bytes_)[0];
|
||||
for (int i = 0; i < count; i++) {
|
||||
readBytes[i] = (unsigned char) bits.readBits(8);
|
||||
}
|
||||
string encoding;
|
||||
if (currentCharacterSetECI == 0) {
|
||||
// The spec isn't clear on this mode; see
|
||||
// section 6.4.5: t does not say which encoding to assuming
|
||||
// upon decoding. I have seen ISO-8859-1 used as well as
|
||||
// Shift_JIS -- without anything like an ECI designator to
|
||||
// give a hint.
|
||||
encoding = StringUtils::guessEncoding(readBytes, count, hints);
|
||||
} else {
|
||||
encoding = currentCharacterSetECI->name();
|
||||
}
|
||||
try {
|
||||
append(result, readBytes, nBytes, encoding.c_str());
|
||||
} catch (ReaderException const& re) {
|
||||
throw FormatException();
|
||||
}
|
||||
byteSegments->values().push_back(bytes_);
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::string &result, int count) {
|
||||
int nBytes = count;
|
||||
unsigned char* bytes = new unsigned char[nBytes];
|
||||
int i = 0;
|
||||
// Read three digits at a time
|
||||
while (count >= 3) {
|
||||
// Each 10 bits encodes three digits
|
||||
if (bits->available() < 10) {
|
||||
throw ReaderException("format exception");
|
||||
int nBytes = count;
|
||||
unsigned char* bytes = new unsigned char[nBytes];
|
||||
int i = 0;
|
||||
// Read three digits at a time
|
||||
while (count >= 3) {
|
||||
// Each 10 bits encodes three digits
|
||||
if (bits->available() < 10) {
|
||||
throw ReaderException("format exception");
|
||||
}
|
||||
int threeDigitsBits = bits->readBits(10);
|
||||
if (threeDigitsBits >= 1000) {
|
||||
ostringstream s;
|
||||
s << "Illegal value for 3-digit unit: " << threeDigitsBits;
|
||||
delete[] bytes;
|
||||
throw ReaderException(s.str().c_str());
|
||||
}
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[threeDigitsBits / 100];
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[(threeDigitsBits / 10) % 10];
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[threeDigitsBits % 10];
|
||||
count -= 3;
|
||||
}
|
||||
int threeDigitsBits = bits->readBits(10);
|
||||
if (threeDigitsBits >= 1000) {
|
||||
ostringstream s;
|
||||
s << "Illegal value for 3-digit unit: " << threeDigitsBits;
|
||||
delete[] bytes;
|
||||
throw ReaderException(s.str().c_str());
|
||||
if (count == 2) {
|
||||
if (bits->available() < 7) {
|
||||
throw ReaderException("format exception");
|
||||
}
|
||||
// Two digits left over to read, encoded in 7 bits
|
||||
int twoDigitsBits = bits->readBits(7);
|
||||
if (twoDigitsBits >= 100) {
|
||||
ostringstream s;
|
||||
s << "Illegal value for 2-digit unit: " << twoDigitsBits;
|
||||
delete[] bytes;
|
||||
throw ReaderException(s.str().c_str());
|
||||
}
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[twoDigitsBits / 10];
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[twoDigitsBits % 10];
|
||||
} else if (count == 1) {
|
||||
if (bits->available() < 4) {
|
||||
throw ReaderException("format exception");
|
||||
}
|
||||
// One digit left over to read
|
||||
int digitBits = bits->readBits(4);
|
||||
if (digitBits >= 10) {
|
||||
ostringstream s;
|
||||
s << "Illegal value for digit unit: " << digitBits;
|
||||
delete[] bytes;
|
||||
throw ReaderException(s.str().c_str());
|
||||
}
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[digitBits];
|
||||
}
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[threeDigitsBits / 100];
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[(threeDigitsBits / 10) % 10];
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[threeDigitsBits % 10];
|
||||
count -= 3;
|
||||
}
|
||||
if (count == 2) {
|
||||
if (bits->available() < 7) {
|
||||
throw ReaderException("format exception");
|
||||
}
|
||||
// Two digits left over to read, encoded in 7 bits
|
||||
int twoDigitsBits = bits->readBits(7);
|
||||
if (twoDigitsBits >= 100) {
|
||||
ostringstream s;
|
||||
s << "Illegal value for 2-digit unit: " << twoDigitsBits;
|
||||
delete[] bytes;
|
||||
throw ReaderException(s.str().c_str());
|
||||
}
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[twoDigitsBits / 10];
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[twoDigitsBits % 10];
|
||||
} else if (count == 1) {
|
||||
if (bits->available() < 4) {
|
||||
throw ReaderException("format exception");
|
||||
}
|
||||
// One digit left over to read
|
||||
int digitBits = bits->readBits(4);
|
||||
if (digitBits >= 10) {
|
||||
ostringstream s;
|
||||
s << "Illegal value for digit unit: " << digitBits;
|
||||
delete[] bytes;
|
||||
throw ReaderException(s.str().c_str());
|
||||
}
|
||||
bytes[i++] = ALPHANUMERIC_CHARS[digitBits];
|
||||
}
|
||||
append(result, bytes, nBytes, StringUtils::ASCII);
|
||||
delete[] bytes;
|
||||
append(result, bytes, nBytes, StringUtils::ASCII);
|
||||
delete[] bytes;
|
||||
}
|
||||
|
||||
char DecodedBitStreamParser::toAlphaNumericChar(size_t value) {
|
||||
if (value >= sizeof(DecodedBitStreamParser::ALPHANUMERIC_CHARS)) {
|
||||
throw FormatException();
|
||||
}
|
||||
return ALPHANUMERIC_CHARS[value];
|
||||
if (value >= sizeof(DecodedBitStreamParser::ALPHANUMERIC_CHARS)) {
|
||||
throw FormatException();
|
||||
}
|
||||
return ALPHANUMERIC_CHARS[value];
|
||||
}
|
||||
|
||||
void DecodedBitStreamParser::decodeAlphanumericSegment(Ref<BitSource> bits_,
|
||||
string& result,
|
||||
int count,
|
||||
bool fc1InEffect) {
|
||||
BitSource& bits (*bits_);
|
||||
ostringstream bytes;
|
||||
// Read two characters at a time
|
||||
while (count > 1) {
|
||||
if (bits.available() < 11) {
|
||||
throw FormatException();
|
||||
}
|
||||
int nextTwoCharsBits = bits.readBits(11);
|
||||
bytes << toAlphaNumericChar(nextTwoCharsBits / 45);
|
||||
bytes << toAlphaNumericChar(nextTwoCharsBits % 45);
|
||||
count -= 2;
|
||||
}
|
||||
if (count == 1) {
|
||||
// special case: one character left
|
||||
if (bits.available() < 6) {
|
||||
throw FormatException();
|
||||
}
|
||||
bytes << toAlphaNumericChar(bits.readBits(6));
|
||||
}
|
||||
// See section 6.4.8.1, 6.4.8.2
|
||||
string s = bytes.str();
|
||||
if (fc1InEffect) {
|
||||
// We need to massage the result a bit if in an FNC1 mode:
|
||||
ostringstream r;
|
||||
for (size_t i = 0; i < s.length(); i++) {
|
||||
if (s[i] != '%') {
|
||||
r << s[i];
|
||||
} else {
|
||||
if (i < s.length() - 1 && s[i + 1] == '%') {
|
||||
// %% is rendered as %
|
||||
r << s[i++];
|
||||
} else {
|
||||
// In alpha mode, % should be converted to FNC1 separator 0x1D
|
||||
r << (char)0x1D;
|
||||
BitSource& bits (*bits_);
|
||||
ostringstream bytes;
|
||||
// Read two characters at a time
|
||||
while (count > 1) {
|
||||
if (bits.available() < 11) {
|
||||
throw FormatException();
|
||||
}
|
||||
}
|
||||
int nextTwoCharsBits = bits.readBits(11);
|
||||
bytes << toAlphaNumericChar(nextTwoCharsBits / 45);
|
||||
bytes << toAlphaNumericChar(nextTwoCharsBits % 45);
|
||||
count -= 2;
|
||||
}
|
||||
s = r.str();
|
||||
}
|
||||
append(result, s, StringUtils::ASCII);
|
||||
if (count == 1) {
|
||||
// special case: one character left
|
||||
if (bits.available() < 6) {
|
||||
throw FormatException();
|
||||
}
|
||||
bytes << toAlphaNumericChar(bits.readBits(6));
|
||||
}
|
||||
// See section 6.4.8.1, 6.4.8.2
|
||||
string s = bytes.str();
|
||||
if (fc1InEffect) {
|
||||
// We need to massage the result a bit if in an FNC1 mode:
|
||||
ostringstream r;
|
||||
for (size_t i = 0; i < s.length(); i++) {
|
||||
if (s[i] != '%') {
|
||||
r << s[i];
|
||||
} else {
|
||||
if (i < s.length() - 1 && s[i + 1] == '%') {
|
||||
// %% is rendered as %
|
||||
r << s[i++];
|
||||
} else {
|
||||
// In alpha mode, % should be converted to FNC1 separator 0x1D
|
||||
r << (char)0x1D;
|
||||
}
|
||||
}
|
||||
}
|
||||
s = r.str();
|
||||
}
|
||||
append(result, s, StringUtils::ASCII);
|
||||
}
|
||||
|
||||
namespace {
|
||||
int parseECIValue(BitSource bits) {
|
||||
int parseECIValue(BitSource bits) {
|
||||
int firstByte = bits.readBits(8);
|
||||
if ((firstByte & 0x80) == 0) {
|
||||
// just one byte
|
||||
return firstByte & 0x7F;
|
||||
// just one byte
|
||||
return firstByte & 0x7F;
|
||||
}
|
||||
if ((firstByte & 0xC0) == 0x80) {
|
||||
// two bytes
|
||||
int secondByte = bits.readBits(8);
|
||||
return ((firstByte & 0x3F) << 8) | secondByte;
|
||||
// two bytes
|
||||
int secondByte = bits.readBits(8);
|
||||
return ((firstByte & 0x3F) << 8) | secondByte;
|
||||
}
|
||||
if ((firstByte & 0xE0) == 0xC0) {
|
||||
// three bytes
|
||||
int secondThirdBytes = bits.readBits(16);
|
||||
return ((firstByte & 0x1F) << 16) | secondThirdBytes;
|
||||
// three bytes
|
||||
int secondThirdBytes = bits.readBits(16);
|
||||
return ((firstByte & 0x1F) << 16) | secondThirdBytes;
|
||||
}
|
||||
throw FormatException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ref<DecoderResult>
|
||||
@ -339,70 +347,70 @@ DecodedBitStreamParser::decode(ArrayRef<unsigned char> bytes,
|
||||
Version* version,
|
||||
ErrorCorrectionLevel const& ecLevel,
|
||||
Hashtable const& hints) {
|
||||
Ref<BitSource> bits_ (new BitSource(bytes));
|
||||
BitSource& bits (*bits_);
|
||||
string result;
|
||||
CharacterSetECI* currentCharacterSetECI = 0;
|
||||
bool fc1InEffect = false;
|
||||
ArrayRef< ArrayRef<unsigned char> > byteSegments (size_t(0));
|
||||
Mode* mode = 0;
|
||||
do {
|
||||
// While still another segment to read...
|
||||
if (bits.available() < 4) {
|
||||
// OK, assume we're done. Really, a TERMINATOR mode should have been recorded here
|
||||
mode = &Mode::TERMINATOR;
|
||||
} else {
|
||||
try {
|
||||
mode = &Mode::forBits(bits.readBits(4)); // mode is encoded by 4 bits
|
||||
} catch (IllegalArgumentException const& iae) {
|
||||
throw iae;
|
||||
// throw FormatException.getFormatInstance();
|
||||
}
|
||||
}
|
||||
if (mode != &Mode::TERMINATOR) {
|
||||
if ((mode == &Mode::FNC1_FIRST_POSITION) || (mode == &Mode::FNC1_SECOND_POSITION)) {
|
||||
// We do little with FNC1 except alter the parsed result a bit according to the spec
|
||||
fc1InEffect = true;
|
||||
} else if (mode == &Mode::STRUCTURED_APPEND) {
|
||||
// not really supported; all we do is ignore it
|
||||
// Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue
|
||||
bits.readBits(16);
|
||||
} else if (mode == &Mode::ECI) {
|
||||
// Count doesn't apply to ECI
|
||||
int value = parseECIValue(bits);
|
||||
currentCharacterSetECI = CharacterSetECI::getCharacterSetECIByValue(value);
|
||||
if (currentCharacterSetECI == 0) {
|
||||
throw FormatException();
|
||||
}
|
||||
} else {
|
||||
// First handle Hanzi mode which does not start with character count
|
||||
if (mode == &Mode::HANZI) {
|
||||
//chinese mode contains a sub set indicator right after mode indicator
|
||||
int subset = bits.readBits(4);
|
||||
int countHanzi = bits.readBits(mode->getCharacterCountBits(version));
|
||||
if (subset == GB2312_SUBSET) {
|
||||
decodeHanziSegment(bits_, result, countHanzi);
|
||||
}
|
||||
Ref<BitSource> bits_ (new BitSource(bytes));
|
||||
BitSource& bits (*bits_);
|
||||
string result;
|
||||
CharacterSetECI* currentCharacterSetECI = 0;
|
||||
bool fc1InEffect = false;
|
||||
ArrayRef< ArrayRef<unsigned char> > byteSegments (size_t(0));
|
||||
Mode* mode = 0;
|
||||
do {
|
||||
// While still another segment to read...
|
||||
if (bits.available() < 4) {
|
||||
// OK, assume we're done. Really, a TERMINATOR mode should have been recorded here
|
||||
mode = &Mode::TERMINATOR;
|
||||
} else {
|
||||
// "Normal" QR code modes:
|
||||
// How many characters will follow, encoded in this mode?
|
||||
int count = bits.readBits(mode->getCharacterCountBits(version));
|
||||
if (mode == &Mode::NUMERIC) {
|
||||
decodeNumericSegment(bits_, result, count);
|
||||
} else if (mode == &Mode::ALPHANUMERIC) {
|
||||
decodeAlphanumericSegment(bits_, result, count, fc1InEffect);
|
||||
} else if (mode == &Mode::BYTE) {
|
||||
decodeByteSegment(bits_, result, count, currentCharacterSetECI, byteSegments, hints);
|
||||
} else if (mode == &Mode::KANJI) {
|
||||
decodeKanjiSegment(bits_, result, count);
|
||||
} else {
|
||||
throw FormatException();
|
||||
}
|
||||
try {
|
||||
mode = &Mode::forBits(bits.readBits(4)); // mode is encoded by 4 bits
|
||||
} catch (IllegalArgumentException const& iae) {
|
||||
throw iae;
|
||||
// throw FormatException.getFormatInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (mode != &Mode::TERMINATOR);
|
||||
if (mode != &Mode::TERMINATOR) {
|
||||
if ((mode == &Mode::FNC1_FIRST_POSITION) || (mode == &Mode::FNC1_SECOND_POSITION)) {
|
||||
// We do little with FNC1 except alter the parsed result a bit according to the spec
|
||||
fc1InEffect = true;
|
||||
} else if (mode == &Mode::STRUCTURED_APPEND) {
|
||||
// not really supported; all we do is ignore it
|
||||
// Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue
|
||||
bits.readBits(16);
|
||||
} else if (mode == &Mode::ECI) {
|
||||
// Count doesn't apply to ECI
|
||||
int value = parseECIValue(bits);
|
||||
currentCharacterSetECI = CharacterSetECI::getCharacterSetECIByValue(value);
|
||||
if (currentCharacterSetECI == 0) {
|
||||
throw FormatException();
|
||||
}
|
||||
} else {
|
||||
// First handle Hanzi mode which does not start with character count
|
||||
if (mode == &Mode::HANZI) {
|
||||
//chinese mode contains a sub set indicator right after mode indicator
|
||||
int subset = bits.readBits(4);
|
||||
int countHanzi = bits.readBits(mode->getCharacterCountBits(version));
|
||||
if (subset == GB2312_SUBSET) {
|
||||
decodeHanziSegment(bits_, result, countHanzi);
|
||||
}
|
||||
} else {
|
||||
// "Normal" QR code modes:
|
||||
// How many characters will follow, encoded in this mode?
|
||||
int count = bits.readBits(mode->getCharacterCountBits(version));
|
||||
if (mode == &Mode::NUMERIC) {
|
||||
decodeNumericSegment(bits_, result, count);
|
||||
} else if (mode == &Mode::ALPHANUMERIC) {
|
||||
decodeAlphanumericSegment(bits_, result, count, fc1InEffect);
|
||||
} else if (mode == &Mode::BYTE) {
|
||||
decodeByteSegment(bits_, result, count, currentCharacterSetECI, byteSegments, hints);
|
||||
} else if (mode == &Mode::KANJI) {
|
||||
decodeKanjiSegment(bits_, result, count);
|
||||
} else {
|
||||
throw FormatException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (mode != &Mode::TERMINATOR);
|
||||
|
||||
return Ref<DecoderResult>(new DecoderResult(bytes, Ref<String>(new String(result)), byteSegments, (string)ecLevel));
|
||||
return Ref<DecoderResult>(new DecoderResult(bytes, Ref<String>(new String(result)), byteSegments, (string)ecLevel));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user