Skip to content

Commit 4f28138

Browse files
committed
Initial Commit
0 parents  commit 4f28138

File tree

214 files changed

+31443
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+31443
-0
lines changed

.gitattributes

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2+
bin
3+
[Bb]in
4+
obj
5+
[Oo]bj
6+
[Dd]ebug*/
7+
[Rr]elease*/
8+
9+
*.unsuccessfulbuild
10+
*.pidb
11+
*.userprefs
12+
*.suo
13+
*.resharper
14+
*.svn
15+
16+
17+
# mstest test results
18+
TestResults
19+
20+
#NuGet
21+
packages/
22+
23+
Xamarin/
24+
25+
binaries/

readme.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# zxing.MonoTouch
2+
ZXing (pronounced "zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java. Our focus is on using the built-in camera on mobile phones to photograph and decode barcodes on the device, without communicating with a server.
3+
This project is built from the official csharp port from SVN and may be missing functionality.
4+
5+
## Usage
6+
A simple example of using zxing.MonoDroid might look like this:
7+
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
using System.Net;
12+
using MonoTouch.Foundation;
13+
using MonoTouch.UIKit;
14+
using com.google.zxing;
15+
using com.google.zxing.common;
16+
17+
namespace Camera.iPhone
18+
{
19+
20+
public class Application
21+
{
22+
static void Main (string[] args)
23+
{
24+
UIApplication.Main (args);
25+
}
26+
}
27+
28+
// The name AppDelegate is referenced in the MainWindow.xib file.
29+
public partial class AppDelegate : UIApplicationDelegate
30+
{
31+
// This method is invoked when the application has loaded its UI and its ready to run
32+
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
33+
{
34+
// If you have defined a view, add it here:
35+
// window.AddSubview (navigationController.View);
36+
37+
window.MakeKeyAndVisible ();
38+
39+
try
40+
{
41+
var wc = new WebClient();
42+
var uri = new Uri("http://www.theipadfan.com/wp-content/uploads/2010/07/barcode.png");
43+
wc.DownloadFile(uri,"barcode.png");
44+
45+
UIImage image = UIImage.FromFile("barcode.png");
46+
var srcbitmap = new System.Drawing.Bitmap(image);
47+
48+
Reader barcodeReader = new MultiFormatReader();
49+
LuminanceSource source = new RGBLuminanceSource(srcbitmap, (int)image.Size.Width, (int)image.Size.Height);
50+
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
51+
var result = barcodeReader.decode(bitmap);
52+
label.Text = result.Text;
53+
} catch (Exception ex) {
54+
label.Text = ex.ToString();
55+
Console.WriteLine(ex.ToString());
56+
}
57+
58+
return true;
59+
}
60+
61+
// This method is required in iPhoneOS 3.0
62+
public override void OnActivated (UIApplication application)
63+
{
64+
}
65+
}
66+
}
67+
68+
## zxing
69+
ZXing is released under the Apache 2.0 license.
70+
ZXing can be found here: http://code.google.com/p/zxing/
71+
A copy of the Apache 2.0 license can be found here: http://www.apache.org/licenses/LICENSE-2.0
72+
73+
## System.Drawing
74+
The System.Drawing classes included are from the mono source code which is property of Novell.
75+
Copyright notice is intact in source code files.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with you package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using System;
2+
3+
using Android.App;
4+
using Android.Content;
5+
using Android.Content.PM;
6+
using Android.Runtime;
7+
using Android.Views;
8+
using Android.Widget;
9+
using Android.OS;
10+
11+
using ZxingSharp.Mobile;
12+
13+
namespace ZxingSharp.MonoForAndroid.Sample
14+
{
15+
[Activity (Label = "ZxingSharp", MainLauncher = true, ConfigurationChanges=ConfigChanges.Orientation|ConfigChanges.KeyboardHidden)]
16+
public class Activity1 : Activity
17+
{
18+
Button buttonScanCustomView;
19+
Button buttonScanDefaultView;
20+
21+
ZxingScanner scanner;
22+
23+
protected override void OnCreate (Bundle bundle)
24+
{
25+
base.OnCreate (bundle);
26+
27+
// Set our view from the "main" layout resource
28+
SetContentView (Resource.Layout.Main);
29+
30+
//Create a new instance of our Scanner
31+
scanner = new ZxingScanner(this);
32+
33+
buttonScanDefaultView = this.FindViewById<Button>(Resource.Id.buttonScanDefaultView);
34+
buttonScanDefaultView.Click += delegate {
35+
36+
//Tell our scanner to use the default overlay
37+
scanner.UseCustomOverlay = false;
38+
//We can customize the top and bottom text of the default overlay
39+
scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away";
40+
scanner.BottomText = "Wait for the barcode to automatically scan!";
41+
42+
//Start scanning
43+
scanner.StartScanning(ZxingScanningOptions.Default, (barcode) => {
44+
//Scanning finished callback
45+
HandleScanResult(barcode);
46+
});
47+
};
48+
49+
buttonScanCustomView = this.FindViewById<Button>(Resource.Id.buttonScanCustomView);
50+
buttonScanCustomView.Click += delegate {
51+
52+
//Tell our scanner we want to use a custom overlay instead of the default
53+
scanner.UseCustomOverlay = true;
54+
55+
//Inflate our custom overlay from a resource layout
56+
var zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);
57+
58+
//Find the button from our resource layout and wire up the click event
59+
var flashButton = zxingOverlay.FindViewById<Button>(Resource.Id.buttonZxingFlash);
60+
flashButton.Click += (sender, e) => {
61+
//Tell our scanner to toggle the torch/flash
62+
scanner.ToggleTorch();
63+
};
64+
65+
//Set our custom overlay
66+
scanner.CustomOverlay = zxingOverlay;
67+
68+
//Start scanning!
69+
scanner.StartScanning(ZxingScanningOptions.Default, (barcode) => {
70+
//Our scanning finished callback
71+
HandleScanResult(barcode);
72+
});
73+
74+
};
75+
}
76+
77+
void HandleScanResult (ZxingBarcodeResult result)
78+
{
79+
string msg = "";
80+
81+
if (result != null && !string.IsNullOrEmpty(result.Value))
82+
msg = "Found Barcode: " + result.Value;
83+
else
84+
msg = "Scanning Canceled!";
85+
86+
Toast.MakeText(this, msg, ToastLength.Short).Show();
87+
}
88+
}
89+
}
90+
91+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="ZxingSharp.MonoForAndroid.Sample">
3+
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
4+
<application android:label="ZxingSharp.MonoForAndroid.Sample"></application>
5+
<uses-permission android:name="android.permission.CAMERA" />
6+
<uses-permission android:name="android.permission.VIBRATE" />
7+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using Android.App;
4+
5+
// Information about this assembly is defined by the following attributes.
6+
// Change them to the values specific to your project.
7+
8+
[assembly: AssemblyTitle("ZxingSharp.MonoForAndroid.Sample")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("")]
13+
[assembly: AssemblyCopyright("20363")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
19+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
20+
21+
[assembly: AssemblyVersion("1.0.0")]
22+
23+
// The following attributes are used to specify the signing key for the assembly,
24+
// if desired. See the Mono documentation for more information about signing.
25+
26+
//[assembly: AssemblyDelaySign(false)]
27+
//[assembly: AssemblyKeyFile("")]
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.axml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable/
12+
icon.png
13+
14+
layout/
15+
main.axml
16+
17+
values/
18+
strings.xml
19+
20+
In order to get the build system to recognize Android resources, set the build action to
21+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
22+
instead operate on resource IDs. When you compile an Android application that uses resources,
23+
the build system will package the resources for distribution and generate a class called "R"
24+
(this is an Android convention) that contains the tokens for each one of the resources
25+
included. For example, for the above Resources layout, this is what the R class would expose:
26+
27+
public class R {
28+
public class drawable {
29+
public const int icon = 0x123;
30+
}
31+
32+
public class layout {
33+
public const int main = 0x456;
34+
}
35+
36+
public class strings {
37+
public const int first_string = 0xabc;
38+
public const int second_string = 0xbcd;
39+
}
40+
}
41+
42+
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43+
to reference the layout/main.axml file, or R.strings.first_string to reference the first
44+
string in the dictionary file values/strings.xml.

0 commit comments

Comments
 (0)