1 #include "ZXingBarcodeReaderAppView.h"
\r
4 #include <zxing/qrcode/QRCodeReader.h>
\r
5 #include <zxing/MultiFormatReader.h>
\r
7 #include <zxing/common/GlobalHistogramBinarizer.h>
\r
8 #include <zxing/Binarizer.h>
\r
9 #include <zxing/BinaryBitmap.h>
\r
10 #include <CameraImage.h>
\r
12 #include <aknmessagequerydialog.h>
\r
13 #include "ZXingBarcodeReader_0xEF24C10A.rsg"
\r
15 using namespace zxing;
\r
16 using namespace zxing::qrcode;
\r
18 void CZXingBarcodeReaderAppView::StartTimer()
\r
20 const TInt tickInterval=2000000;
\r
21 iPeriodic=CPeriodic::NewL(0); // neutral priority
\r
23 //CleanupStack::PushL(iPeriodic);
\r
25 iPeriodic->Start(tickInterval,tickInterval,TCallBack(&CZXingBarcodeReaderAppView::Tick, this));
\r
27 // CleanupStack::PopAndDestroy(iPeriodic);
\r
30 TInt CZXingBarcodeReaderAppView::Tick(TAny* aObject)
\r
32 // cast, and call non-static function
\r
33 ((CZXingBarcodeReaderAppView*)aObject)->decodeBackbufferImage();
\r
37 void CZXingBarcodeReaderAppView::decodeBackbufferImage()
\r
39 MultiFormatReader decoder;
\r
42 image.setImage(iBackBuffer);
\r
49 Ref<LuminanceSource> imageRef(new CameraImage(image));
\r
50 GlobalHistogramBinarizer* binz = new GlobalHistogramBinarizer(imageRef);
\r
52 Ref<Binarizer> bz (binz);
\r
53 BinaryBitmap* bb = new BinaryBitmap(bz);
\r
55 Ref<BinaryBitmap> ref(bb);
\r
57 res = decoder.decode(ref);
\r
59 string string = res->getText()->getText();
\r
60 HBufC8 *pHeap8 = HBufC8::NewMaxLC(string.size());
\r
61 pHeap8->Des().Copy((const TUint8 *)string.c_str());
\r
63 HBufC *pHeap16 = HBufC::NewMaxLC(pHeap8->Length());
\r
64 pHeap16->Des().Copy(*pHeap8);
\r
66 ShowResultL(*pHeap16);
\r
68 catch(zxing::Exception& e)
\r
70 /*string string = "Error...retrying...";
\r
71 HBufC8 *pHeap8 = HBufC8::NewMaxLC(string.size());
\r
72 pHeap8->Des().Copy((const TUint8 *)string.c_str());
\r
74 HBufC *pHeap16 = HBufC::NewMaxLC(pHeap8->Length());
\r
75 pHeap16->Des().Copy(*pHeap8);
\r
77 ShowResultL(*pHeap16);*/
\r
81 void CZXingBarcodeReaderAppView::ShowResultL(TDesC16& message)
\r
85 CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog ();
\r
87 dlg->PrepareLC(R_TEXT_QUERY_DIALOG );
\r
89 //HBufC* title = NULL;
\r
90 //title = iEikonEnv->AllocReadResourceLC ( TEXT_DIALOG_TITLE );
\r
91 dlg->QueryHeading ()->SetTextL (_L("Information") );
\r
93 dlg->SetMessageTextL ( message );
\r
97 CleanupStack::PopAndDestroy();
\r