Quantcast

ZXing port to mono for Android

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ZXing port to mono for Android

Johnsor
Hey...
Anybody know of such a port?
I can find ports to iOS and wp7

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

efontana
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

Elan Hasson
That is awesome.

Thanks for sharing this!

On Tue, Sep 27, 2011 at 7:37 AM, efontana <[hidden email]> wrote:
https://github.com/JohnACarruthers/zxing.MonoDroid

--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/ZXing-port-to-mono-for-Android-tp4840736p4845023.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

Johnsor
In reply to this post by efontana
This actually works, thanks for the info.
Anybody has an example on how to handle the build in Camera to get the barcodes ?
I've looked on the API demo / graphics / camera view, but there is a long way.

Regards
Johnsor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

Mike Child
In reply to this post by Elan Hasson
If you already have the app "Barcode Scanner" (made by zxing) then reading barcodes can be as simple as passing an Intent to their app.

  Intent intent = new Intent("com.google.zxing.client.android.SCAN");
  intent.setPackage("com.google.zxing.client.android");
  StartActivityForResult(intent,0);


Mike Child


On Tue, Sep 27, 2011 at 8:16 AM, Elan Hasson <[hidden email]> wrote:
That is awesome.

Thanks for sharing this!


On Tue, Sep 27, 2011 at 7:37 AM, efontana <[hidden email]> wrote:
https://github.com/JohnACarruthers/zxing.MonoDroid

--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/ZXing-port-to-mono-for-Android-tp4840736p4845023.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

efontana
In reply to this post by efontana
If you do use this, watch out with large megapixel cameras, you'll want to use this, otherwise
it could take minutes to decode the bitmap.

I fixed it by doing the following:

private byte[] convertArray(int[] array)
{
byte[] newarray = new byte[array.Length * 3];

  for (int i = 0; i < array.Length; i++)
  {

    newarray[i * 3] = (byte)array[i];
    newarray[i * 3 + 1] = (byte)(array[i] >> 8);
    newarray[i * 3 + 2] = (byte)(array[i] >> 16);

  }
  return newarray;
}
int[] pixels = new int[_backBitmap.Width * _backBitmap.Height];

_backBitmap.GetPixels(pixels, 0, _backBitmap.Width, 0, 0, _backBitmap.Width, _backBitmap.Height);

byte[] pixelArray = convertArray(pixels);
LuminanceSource source = new RGBLuminanceSource(pixelArray, _backBitmap.Width, _backBitmap.Height);
iPhone and Android Developer www.ericfontana.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

efontana
In reply to this post by Johnsor
Well, first you use the camera intent:

  Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture);

      string xp = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Name, "Android/data/com.yourdoman.here/file/capturedBadge.jpg");
      Java.IO.File xfile = new Java.IO.File(xp);
      xfile.ParentFile.Mkdirs();
      xfile.CreateNewFile();
     

// URI for the snapped image.
      _badgeFileUri = Android.Net.Uri.FromFile(xfile);


      intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, _badgeFileUri);
      StartActivityForResult(intent, TAKE_PICTURE);


Now, in OnActivityResult
   Console.WriteLine("Picture received! {0}", _badgeFileUri.Path);

            Android.Graphics.BitmapFactory.Options options = new Android.Graphics.BitmapFactory.Options();
            options.InSampleSize = 8; // save memory!

            using (var _backBitmap = Android.Graphics.BitmapFactory.DecodeFile(_badgeFileUri.Path, options))
            {

              int[] pixels = new int[_backBitmap.Width * _backBitmap.Height];
              _backBitmap.GetPixels(pixels, 0, _backBitmap.Width, 0, 0, _backBitmap.Width, _backBitmap.Height);

              byte[] pixelArray = convertArray(pixels);

   Reader barcodeReader = new MultiFormatReader();
                Console.WriteLine("Creating Luminance Source... {0} x {1}", _backBitmap.Width, _backBitmap.Height);

                LuminanceSource source = new RGBLuminanceSource(pixelArray, _backBitmap.Width, _backBitmap.Height);

                BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

                var result = barcodeReader.decode(bitmap);
                Toast.MakeText(this, string.Format("Code Received: {0}", result), ToastLength.Short).Show();
           


iPhone and Android Developer www.ericfontana.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

Redth
Old thread revived.... Has anyone figured out how to do this with the Camera on the fly?  Eg: The barcode scanner app automatically is always looking at the live camera feed for a barcode...

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

Martin Bowling
Check out Nirvanai's update of the zxing.Mono* and his sample https://github.com/nirvanai/zxing.MonoTouch/tree/master/sample/QrSample.Android

-- 
Martin Bowling
Sent with Sparrow

On Thursday, June 14, 2012 at 8:53 AM, Redth wrote:

Old thread revived.... Has anyone figured out how to do this with the Camera
on the fly? Eg: The barcode scanner app automatically is always looking at
the live camera feed for a barcode...



--
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list

UNSUBSCRIBE INFORMATION:


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZXing port to mono for Android

mimimimi
This post has NOT been accepted by the mailing list yet.
In reply to this post by Johnsor
There is now an official port of this project on codeplex http://zxingnet.codeplex.com/ To install ZXing Barcode Scanning Library .Net Port, run the following command in the Package Manager Console and there are also other barcode scanner in c# that incorporate android. google and search
Loading...