Click here to Skip to main content
15,886,689 members
Articles / Programming Languages / C#

Open Source QRCode Library

Rate me:
Please Sign up or sign in to vote.
4.92/5 (147 votes)
20 Sep 2007CPOL1 min read 5.9M   192.3K   421  
How to use QRCode library to encode and decode QRCode
using System;
using QRCodeUtility = ThoughtWorks.QRCode.Codec.Util.QRCodeUtility;

namespace ThoughtWorks.QRCode.Geom
{  
	public class Point
	{
        public const int RIGHT = 1;
        public const int BOTTOM = 2;
        public const int LEFT = 4;
        public const int TOP = 8;

        internal int x;
        internal int y;
	

		virtual public int X
		{
			get
			{
				return x;
			}
			
			set
			{
				this.x = value;
			}
			
		}
		virtual public int Y
		{
			get
			{
				return y;
			}
			
			set
			{
				this.y = value;
			}
			
		}
		
		
		public Point()
		{
			x = 0;
			y = 0;
		}
		public Point(int x, int y)
		{
			this.x = x;
			this.y = y;
		}
		
		public virtual void  translate(int dx, int dy)
		{
			this.x += dx;
			this.y += dy;
		}
		
		public virtual void  set_Renamed(int x, int y)
		{
			this.x = x;
			this.y = y;
		}
		
		public override String ToString()
		{
			return "(" + System.Convert.ToString(x) + "," + System.Convert.ToString(y) + ")";
		}
		
		public static Point getCenter(Point p1, Point p2)
		{
			return new Point((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
		}
		
		public bool equals(Point compare)
		{
			if (x == compare.x && y == compare.y)
				return true;
			else
				return false;
		}
		
		public virtual int distanceOf(Point other)
		{
			int x2 = other.X;
			int y2 = other.Y;
			return QRCodeUtility.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Malaysia Malaysia
A programmer for a long time, and still learning everyday.

A supporter for open source solutions, and have written quite a few open source software both in .NET and Java.

https://mengwangk.github.io/

Comments and Discussions