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.her*e/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();
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/ZXing-port-to-mono-for-Android-tp4840736p4845769.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid