Umair
Umair

Reputation: 5481

Barcode scan using a portion of the camera view

I want to scan a barcode and show the camera view in full screen but want to scan only when the barcode is in the centre of the square region as shown below:

enter image description here

Is this possible using windows phone 8?

Any tricks to do this?

Upvotes: 0

Views: 210

Answers (1)

Chubosaurus Software
Chubosaurus Software

Reputation: 8161

If you're using 8.1 the thing you're trying to do is available in the default Camera App it's called Bing Vision. If you're using 8.0 you can just click on the Search button and Tap the Vision icon, which basically does the same thing. If you want to program this functionality yourself, then it really depends on what Barcode Library you want to use.

I would recommend ZXing. Website here: ZXing CodeProject

So basically you need to setup a simple camera app and create a scanning operation every few seconds or so.

01) Get the preview of the camera into a Writeable Bitmap like so

cam.GetPreviewBufferArgb32(wbitmap.Pixels);    
wbitmap.Invalidate();
// crop your bitmap to whatever that RECT is

02) Decode your bitmap

Result r = br.Decode(wbitmap);   // where br is your BarcodeReader

03) Display your Result with r.Text

Upvotes: 1

Related Questions