1 /****************************************************************************
\r
3 ** Trolltech hereby grants a license to use the Qt/Eclipse Integration
\r
4 ** plug-in (the software contained herein), in binary form, solely for the
\r
5 ** purpose of creating code to be used with Trolltech's Qt software.
\r
7 ** Qt Designer is licensed under the terms of the GNU General Public
\r
8 ** License versions 2.0 and 3.0 ("GPL License"). Trolltech offers users the
\r
9 ** right to use certain no GPL licensed software under the terms of its GPL
\r
10 ** Exception version 1.2 (http://trolltech.com/products/qt/gplexception).
\r
12 ** THIS SOFTWARE IS PROVIDED BY TROLLTECH AND ITS CONTRIBUTORS (IF ANY) "AS
\r
13 ** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
\r
14 ** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
\r
15 ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
\r
16 ** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
17 ** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
\r
18 ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
\r
19 ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
20 ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
21 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
22 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
\r
24 ** Since we now have the GPL exception I think that the "special exception
\r
25 ** is no longer needed. The license text proposed above (other than the
\r
26 ** special exception portion of it) is the BSD license and we have added
\r
27 ** the BSD license as a permissible license under the exception.
\r
29 ****************************************************************************/
\r
31 #include "QQrDecoder.h"
\r
32 //#include <zxing/qrcode/QRCodeReader.h>
\r
33 #include <zxing/MultiFormatReader.h>
\r
35 #include <zxing/common/GlobalHistogramBinarizer.h>
\r
36 #include <zxing/Binarizer.h>
\r
37 #include <zxing/BinaryBitmap.h>
\r
38 #include <QFileDialog>
\r
39 #include <QGraphicsView>
\r
44 using namespace zxing;
\r
45 //using namespace zxing::qrcode;
\r
47 QQrDecoder::QQrDecoder(QWidget *parent): QMainWindow(parent)
\r
50 connect(ui.startDecode, SIGNAL(clicked()), this, SLOT(findAndDecode()));
\r
51 connect(ui.cameraWidget, SIGNAL(imageCaptured(QImage)), this, SLOT(decodeImage(QImage)));
\r
52 connect(ui.cameraWidget, SIGNAL(logMessage(QString)), ui.resultLabel, SLOT(setText(QString)));
\r
55 QQrDecoder::~QQrDecoder()
\r
59 void QQrDecoder::InitializeSymbianCamera()
\r
64 void QQrDecoder::findAndDecode()
\r
66 ui.cameraWidget->CaptureImage();
\r
69 void QQrDecoder::decodeImage(QImage originalImage)
\r
71 MultiFormatReader decoder;
\r
73 image.setImage(originalImage);
\r
78 Ref<LuminanceSource> imageRef(new CameraImageWrapper(image));
\r
79 GlobalHistogramBinarizer* binz = new GlobalHistogramBinarizer(imageRef);
\r
81 Ref<Binarizer> bz (binz);
\r
82 BinaryBitmap* bb = new BinaryBitmap(bz);
\r
84 Ref<BinaryBitmap> ref(bb);
\r
86 res = decoder.decode(ref);
\r
88 QString string = QString(res->getText()->getText().c_str());
\r
89 ui.resultLabel->setText(string);
\r
91 catch(zxing::Exception& e)
\r
93 ui.resultLabel->setText("Error");
\r
97 void QQrDecoder::reloadFormatedPicture(int x)
\r