Ejemplo n.º 1
0
        private void btn_File_Click(object sender, System.EventArgs e)
        {
            string sRes="";
            OpenFileDialog ofn=new OpenFileDialog();
            if(ofn.ShowDialog()==DialogResult.OK){
                try {
                            Reader barcodeReader=
                                new com.google.zxing.MultiFormatReader();
                            System.Drawing.Bitmap srcbitmap =
                                new System.Drawing.Bitmap(ofn.FileName.ToString()); // Make a copy of the image in the Bitmap variable
                            //make a grey bitmap of it
                            bmp_util util=new bmp_util();
                            srcbitmap = util.ConvertToGrayscale(srcbitmap);

                            RGBLuminanceSource source =
                                new RGBLuminanceSource(srcbitmap, srcbitmap.Width, srcbitmap.Height);
                            com.google.zxing.BinaryBitmap bitmap=
                                new com.google.zxing.BinaryBitmap(new HybridBinarizer(source));
                            com.google.zxing.Result result = barcodeReader.decode(bitmap);
                            System.Console.WriteLine(result.Text);
                    sRes=result.Text;
                }
                catch (com.google.zxing.ReaderException zex) {
                    sRes=zex.Message;
                    System.Console.WriteLine(zex.Message);
                }
                catch (Exception ex) {
                    sRes=ex.Message;
                    System.Console.WriteLine(ex.Message);
                }
                tb.Text=sRes;
            }
        }
Ejemplo n.º 2
0
        private void btn_File_Click(object sender, System.EventArgs e)
        {
            string         sRes = "";
            OpenFileDialog ofn  = new OpenFileDialog();

            if (ofn.ShowDialog() == DialogResult.OK)
            {
                try {
                    Reader barcodeReader =
                        new com.google.zxing.MultiFormatReader();
                    System.Drawing.Bitmap srcbitmap =
                        new System.Drawing.Bitmap(ofn.FileName.ToString());                                         // Make a copy of the image in the Bitmap variable
                    //make a grey bitmap of it
                    bmp_util util = new bmp_util();
                    srcbitmap = util.ConvertToGrayscale(srcbitmap);

                    RGBLuminanceSource source =
                        new RGBLuminanceSource(srcbitmap, srcbitmap.Width, srcbitmap.Height);
                    com.google.zxing.BinaryBitmap bitmap =
                        new com.google.zxing.BinaryBitmap(new HybridBinarizer(source));
                    com.google.zxing.Result result = barcodeReader.decode(bitmap);
                    System.Console.WriteLine(result.Text);
                    sRes = result.Text;
                }
                catch (com.google.zxing.ReaderException zex) {
                    sRes = zex.Message;
                    System.Console.WriteLine(zex.Message);
                }
                catch (Exception ex) {
                    sRes = ex.Message;
                    System.Console.WriteLine(ex.Message);
                }
                tb.Text = sRes;
            }
        }
Ejemplo n.º 3
0
        public static String Decode(Image Image)
        {
            try
            {
                var hints = new Hashtable();
                hints.Add(DecodeHintType.TRY_HARDER, true);
                ArrayList fmts = new ArrayList();
                fmts.Add(BarcodeFormat.QR_CODE);
                hints.Add(DecodeHintType.POSSIBLE_FORMATS, fmts);

                var Bitmap = new Bitmap(Image);
                LuminanceSource source = new RGBLuminanceSource(Bitmap, Bitmap.Width, Bitmap.Height);
                var bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
                Reader reader = new MultiFormatReader();
                Result result = reader.decode(bitmap, hints);
                String DecodedString = result.Text;
                Console.WriteLine(DecodedString);
                return DecodedString;
            }
            catch (ReaderException ex)
            {
                return "";
            }
            catch (InvalidOperationException ex)
            {
                return "";
            }
        }
Ejemplo n.º 4
0
			public QrScanner (QrScannerActivity activity)
				: base (activity)
			{
				this.activity = activity;
				this.reader = new MultiFormatReader {
					Hints = new Hashtable {
						{ DecodeHintType.POSSIBLE_FORMATS, new ArrayList { BarcodeFormat.QR_CODE } }
					}
				};

				this.surface_holder = Holder;
				this.surface_holder.AddCallback (this);
				this.surface_holder.SetType (SurfaceType.PushBuffers);
			}
        public void StopWorker()
        {
            // starting timer
            if (WorkerTimer != null)
            {
                WorkerTimer.Invalidate();
                try { WorkerTimer.Dispose(); } catch { }
                WorkerTimer = null;
                try { NSRunLoop.Current.Dispose(); } catch { }
            }

            //Just in case
            _multiFormatReader = null;
            hints = null;
        }
Ejemplo n.º 6
0
        //解码操作
        private void button3_Click(object sender, EventArgs e)
        {
            MultiFormatReader mutiReader = new com.google.zxing.MultiFormatReader();
            Bitmap            img        = (Bitmap)Bitmap.FromFile(opFilePath);

            if (img == null)
            {
                return;
            }
            LuminanceSource ls = new RGBLuminanceSource(img, img.Width, img.Height);
            BinaryBitmap    bb = new BinaryBitmap(new com.google.zxing.common.HybridBinarizer(ls));

            Hashtable hints = new Hashtable();

            hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
            Result r = mutiReader.decode(bb, hints);

            txtMsg.Text = r.Text;
        }
        public string ReadBarcode(Bitmap BarcodeImage)
        {
            RGBLuminanceSource BarcodeSource = new RGBLuminanceSource(BarcodeImage, BarcodeImage.Width, BarcodeImage.Height);
            BinaryBitmap BarcodeImageBin = new BinaryBitmap(new GlobalHistogramBinarizer(BarcodeSource));
            MultiFormatReader BarcodeReader = new MultiFormatReader();
            try
            {
                Result BarcodeDecodeResult;
                BarcodeDecodeResult = BarcodeReader.decode(BarcodeImageBin);
                if (BarcodeDecodeResult.Text != null)
                    return BarcodeDecodeResult.Text;
                else
                    return "NoBarcode";

            }
            catch (Exception e)
            {
                return "Fail";
            }
        }
        private void BarCodeDetectTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Bitmap img = (Bitmap)pictureBox1.Image;
                Reader reader = new MultiFormatReader();
                RGBLuminanceSource source1 = new RGBLuminanceSource(img, img.Width, img.Height);
                BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source1));
                Result result = reader.decode(bitmap);

                textBox1.Text = result.Text;
                dekodirano = textBox1.Text;
                BarCodeDetectTimer.Stop();

            }
            catch (Exception)
            {
                statusStrip1.Text = "Greska pri dekodiranju";
            }
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Image img = Image.FromFile(this.openFileDialog1.FileName);                        
            Bitmap bmap;
            try
            {
                bmap = new Bitmap(img);
            }
            catch (System.IO.IOException ioe)
            {
                MessageBox.Show(ioe.ToString());
                return;
            }

            if (bmap == null)
            {
                MessageBox.Show("Could not decode image");
                return;
            }

            LuminanceSource source = new RGBLuminanceSource(bmap, bmap.Width, bmap.Height);
            com.google.zxing.BinaryBitmap bitmap = new com.google.zxing.BinaryBitmap(new COMMON.HybridBinarizer(source));
            Result result;
            try
            {
                result = new MultiFormatReader().decode(bitmap);
            }
            catch(ReaderException re)
            {
                MessageBox.Show(re.ToString());
                return;
            }
            
            MessageBox.Show(result.Text);        
        }
        private void Worker()
        {
            //iphone 4 : 960 x 640
            //iphone 3 : 320 x 480
            if (DeviceHardware.Version == DeviceHardware.HardwareVersion.iPhone4) {
                //picFrame = new RectangleF (0, 146 * 2, 320 * 2, 157 * 2);
                picFrame = new RectangleF(300, 300, 320 * 2, 157 * 2);
            }

            if (hints == null) {
                var list = new ArrayList ();
                list.Add (com.google.zxing.BarcodeFormat.EAN_8);
                list.Add (com.google.zxing.BarcodeFormat.EAN_13);

                hints = new Hashtable ();
                hints.Add (com.google.zxing.DecodeHintType.POSSIBLE_FORMATS, list);
                hints.Add (
                    com.google.zxing.DecodeHintType.NEED_RESULT_POINT_CALLBACK,
                    new ResultCallBack (this)
                );
            }

            if (_multiFormatOneDReader == null) {
                _multiFormatOneDReader = new com.google.zxing.oned.MultiFormatOneDReader (hints);
            }

            // Capturing screen image
              using (var screenImage = CGImage.ScreenImage.WithImageInRect(new RectangleF(0,0,640,960)))
            {

                UIImage image = UIImage.FromImage(screenImage);
                var srcbitmap = new System.Drawing.Bitmap (image);

                LuminanceSource source = null;
                BinaryBitmap bitmap = null;
                try {
                    source  = new RGBLuminanceSource(srcbitmap, (int)image.Size.Width, (int)image.Size.Height);
                    bitmap = new BinaryBitmap (new HybridBinarizer (source));
                          Reader barcodeReader = new MultiFormatReader();
                    Result bresult = null;
                    try
                    {
                        bresult = barcodeReader.decode(bitmap);}
                    catch(Exception ex){
                        //Console.Write(ex.ToString());
                    }

                    if(bresult != null)
                    {
                    var a = bresult.BarcodeFormat.Name;
                        BeepOrVibrate ();
                                _parentViewController.BarCodeScanned (bresult);
                    }
            //					QRCodeReader barcodeReader = new QRCodeReader ();
            //					source = new RGBLuminanceSource (
            //						srcbitmap,
            //						(int)screenImage.Width,
            //						(int)screenImage.Height
            //					);
            //					bitmap = new BinaryBitmap (new HybridBinarizer (source));
            //					Result result = null;
            //					try {
            //						result = barcodeReader.decode (bitmap);
            //					} catch (Exception ex) {
            //						Console.Write ("Result error: " + ex.ToString ());
            //					}
            //					if (result == null) {
            //						Console.Write ("result is null.");
            //					} else {
            //						Console.Write (result.BarcodeFormat);
            //					}
                    com.google.zxing.common.BitArray row = new com.google.zxing.common.BitArray (screenImage.Width);
                    int middle = screenImage.Height >> 1;
                    int rowStep = System.Math.Max (1, screenImage.Height >> (4));

                    for (int x = 0; x < 9; x++) {

                        // Scanning from the middle out. Determine which row we're looking at next:
                        int rowStepsAboveOrBelow = (x + 1) >> 1;
                        bool isAbove = (x & 0x01) == 0; // i.e. is x even?
                        int rowNumber = middle + rowStep * (isAbove ? rowStepsAboveOrBelow : - rowStepsAboveOrBelow);
                        if (rowNumber < 0 || rowNumber >= screenImage.Height) {
                            // Oops, if we run off the top or bottom, stop
                            break;
                        }

                        // Estimate black point for this row and load it:
                        try {
                            row = bitmap.getBlackRow (rowNumber, row);

                            var resultb = _multiFormatOneDReader.decodeRow (rowNumber, row, hints);
                            if (resultb.Text != null) {
                                BeepOrVibrate ();
                                _parentViewController.BarCodeScanned (resultb);

                                break;
                            } else {
                                continue;
                            }

                        } catch (ReaderException re) {
                            continue;
                        }

                    }

                    //					var result = _barcodeReader.decodeWithState(bitmap);
                    //
                    //					if(result.Text!=null)
                    //					{
                    //						_multiFormatOneDReader = null;
                    //						BeepOrVibrate();
                    //						_parentViewController.BarCodeScanned(result);
                    //					}

                } catch (Exception ex) {
                    Console.WriteLine (ex.Message);
                } finally {
                    if (bitmap != null)
                        bitmap = null;

                    if (source != null)
                        source = null;

                    if (srcbitmap != null)
                        srcbitmap = null;

                }

            }
        }
		public void StopWorker()
        {
            // starting timer
            if (WorkerTimer != null)
            {
                WorkerTimer.Invalidate();
				try { WorkerTimer.Dispose(); } catch { }
                WorkerTimer = null;
				try { NSRunLoop.Current.Dispose(); } catch { }
            }
			
			//Just in case
			_multiFormatReader = null;
			hints = null;
        }
			public ZxingScanner (ZxingViewController parent)
			{
				this.parent = parent;
				this.reader = new MultiFormatReader {
					Hints = new Hashtable {
						{ DecodeHintType.POSSIBLE_FORMATS, new ArrayList { 
							BarcodeFormat.UPC_A, BarcodeFormat.UPC_E , BarcodeFormat.CODE_128,
							BarcodeFormat.CODE_39, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8,
								BarcodeFormat.QR_CODE
							}  }
						, { DecodeHintType.TRY_HARDER, true }
					}
				};
			}
Ejemplo n.º 13
0
		public ZxingSurfaceView (ZxingActivity activity, ZxingScanningOptions options)
			: base (activity)
		{
			this.activity = activity;

			screenResolution = new Size(this.activity.WindowManager.DefaultDisplay.Width, this.activity.WindowManager.DefaultDisplay.Height);

			this.options = options;

			this.reader = new MultiFormatReader {
				Hints = new Hashtable {
					//Formats to use
					{ DecodeHintType.POSSIBLE_FORMATS, this.options.GetFormats() }
				}
			};

			this.surface_holder = Holder;
			this.surface_holder.AddCallback (this);
			this.surface_holder.SetType (SurfaceType.PushBuffers);



			this.tokenSource = new System.Threading.CancellationTokenSource();
		}
			public QrScanner (QrScannerViewController parent)
			{
				this.parent = parent;
				this.reader = new MultiFormatReader {
					Hints = new Hashtable {
						{ DecodeHintType.POSSIBLE_FORMATS, new ArrayList { BarcodeFormat.QR_CODE } }
					}
				};
			}
		private void Initialize()
		{
            ScanOnAutoFocus = true; // scanOnAutoFocus;

			// Gets the Dispatcher for the current application so we can invoke the UI-Thread to get
			// preview-image and fire our timer events
			uiDispatcher = Application.Current.RootVisual.Dispatcher;

			InitializeCamera();

			_reader = new MultiFormatReader();


            var hints = new System.Collections.Hashtable();
           
            hints.Add(DecodeHintType.POSSIBLE_FORMATS, this.Options.GetFormats());
            _reader.Hints = hints;

		}
        private void Worker()
        {
            if (hints == null)
            {
                hints = new Hashtable();
                hints.Add(com.google.zxing.DecodeHintType.POSSIBLE_FORMATS, this.Options.GetFormats());
                hints.Add(com.google.zxing.DecodeHintType.NEED_RESULT_POINT_CALLBACK, new ResultCallBack(this));
            }

            if (_multiFormatReader == null)
            {
                //_multiFormatReader = new com.google.zxing.oned.MultiFormatOneDReader(hints);
                _multiFormatReader       = new com.google.zxing.MultiFormatReader();
                _multiFormatReader.Hints = hints;
                //_multiFormatReader = new MultiFormatReader {
                //		Hints = new Hashtable {
                //			{ DecodeHintType.POSSIBLE_FORMATS, new ArrayList {
                //					BarcodeFormat.UPC_A, BarcodeFormat.UPC_E , BarcodeFormat.CODE_128,
                //					BarcodeFormat.CODE_39, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8
                //				} }
                //		}
                //	};
            }


            using (var ap = new NSAutoreleasePool())
            {
                // Capturing screen image
                using (var screenImage = CGImage.ScreenImage.WithImageInRect(picFrame))                 //.WithImageInRect(picFrame))
                {
                    using (var _theScreenImage = UIImage.FromImage(screenImage))
                        using (var srcbitmap = new Bitmap(_theScreenImage))
                        {
                            LuminanceSource source = null;
                            BinaryBitmap    bitmap = null;
                            try
                            {
                                //Console.WriteLine(screenImage.Width.ToString() + " x " + screenImage.Height.ToString());

                                //var cropY = (int)((screenImage.Height * 0.4) / 2);
                                source = new RGBLuminanceSource(srcbitmap, screenImage.Width, screenImage.Height);                         //.crop(0, cropY, 0, screenImage.Height - cropY - cropY);

                                //Console.WriteLine(source.Width + " x " + source.Height);

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


                                try
                                {
                                    var result = _multiFormatReader.decodeWithState(bitmap);                     //
                                    //var result = _multiFormatReader.decodeWithState (bitmap);

                                    //srcbitmap.Dispose();

                                    if (result.Text != null)
                                    {
                                        //BeepOrVibrate();
                                        _parentViewController.BarCodeScanned(result);
                                    }
                                }
                                catch (ReaderException)
                                {
                                }


                                /*
                                 *      com.google.zxing.common.BitArray row = new com.google.zxing.common.BitArray(screenImage.Width);
                                 *
                                 *      int middle = screenImage.Height >> 1;
                                 *      int rowStep = System.Math.Max(1, screenImage.Height >> (4));
                                 *
                                 *      for (int x = 0; x < 9; x++)
                                 *      {
                                 *
                                 *              // Scanning from the middle out. Determine which row we're looking at next:
                                 *              int rowStepsAboveOrBelow = (x + 1) >> 1;
                                 *              bool isAbove = (x & 0x01) == 0; // i.e. is x even?
                                 *              int rowNumber = middle + rowStep * (isAbove?rowStepsAboveOrBelow:- rowStepsAboveOrBelow);
                                 *              if (rowNumber < 0 || rowNumber >= screenImage.Height)
                                 *              {
                                 *                      // Oops, if we run off the top or bottom, stop
                                 *                      break;
                                 *              }
                                 *
                                 *              // Estimate black point for this row and load it:
                                 *              try
                                 *              {
                                 *                      row = bitmap.getBlackRow(rowNumber, row);
                                 *
                                 *
                                 *                      var resultb = _multiFormatReader.decodeRow(rowNumber, row, hints);
                                 *                      if(resultb.Text!=null)
                                 *                      {
                                 *                              Console.WriteLine("SCANNED");
                                 *                              BeepOrVibrate();
                                 *                              _parentViewController.BarCodeScanned(resultb);
                                 *
                                 *
                                 *                              break;
                                 *                      }
                                 *                      else {
                                 *                              continue;
                                 *                      }
                                 *
                                 *              }
                                 *              catch (ReaderException re)
                                 *              {
                                 *                      continue;
                                 *              }
                                 *
                                 *      }
                                 */


                                //					var result = _barcodeReader.decodeWithState(bitmap);
                                //
                                //					if(result.Text!=null)
                                //					{
                                //						_multiFormatOneDReader = null;
                                //						BeepOrVibrate();
                                //						_parentViewController.BarCodeScanned(result);
                                //					}
                            } catch (Exception ex) {
                                Console.WriteLine(ex.Message);
                            }
                            finally {
                                if (bitmap != null)
                                {
                                    bitmap = null;
                                }

                                if (source != null)
                                {
                                    source = null;
                                }

                                //  if(srcbitmap!=null)
                                //	srcbitmap = null;

                                //if (_theScreenImage != null)
                                //	_theScreenImage = null;
                            }
                        }
                }
            }

            GC.Collect();

            //Console.WriteLine("Done.");
        }
		private void Worker()
        {
       
				if(hints==null)
				{
					hints = new Hashtable();
					hints.Add(com.google.zxing.DecodeHintType.POSSIBLE_FORMATS, this.Options.GetFormats());
					hints.Add(com.google.zxing.DecodeHintType.NEED_RESULT_POINT_CALLBACK, new ResultCallBack(this));
				}
				
				if(_multiFormatReader == null)
				{
				//_multiFormatReader = new com.google.zxing.oned.MultiFormatOneDReader(hints);
				_multiFormatReader = new com.google.zxing.MultiFormatReader();
				_multiFormatReader.Hints = hints;
				//_multiFormatReader = new MultiFormatReader {
				//		Hints = new Hashtable {
				//			{ DecodeHintType.POSSIBLE_FORMATS, new ArrayList { 
				//					BarcodeFormat.UPC_A, BarcodeFormat.UPC_E , BarcodeFormat.CODE_128,
				//					BarcodeFormat.CODE_39, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8
				//				} }
				//		}
				//	};
				}
				
				
			using (var ap = new NSAutoreleasePool())
			{
				// Capturing screen image            
				using (var screenImage = CGImage.ScreenImage.WithImageInRect(picFrame)) //.WithImageInRect(picFrame))
	            {
					using (var _theScreenImage = UIImage.FromImage(screenImage))
					using (var srcbitmap = new Bitmap(_theScreenImage))
					{
						LuminanceSource source = null;
						BinaryBitmap bitmap = null;
						try 
						{
							//Console.WriteLine(screenImage.Width.ToString() + " x " + screenImage.Height.ToString());

							//var cropY = (int)((screenImage.Height * 0.4) / 2);
							source = new RGBLuminanceSource(srcbitmap, screenImage.Width, screenImage.Height); //.crop(0, cropY, 0, screenImage.Height - cropY - cropY);

							//Console.WriteLine(source.Width + " x " + source.Height);

			              	bitmap = new BinaryBitmap(new HybridBinarizer(source));
												
					
						try
						{
							var result = _multiFormatReader.decodeWithState(bitmap); //
							//var result = _multiFormatReader.decodeWithState (bitmap);
						
								//srcbitmap.Dispose();

							if(result.Text!=null)
							{
								//BeepOrVibrate();
								_parentViewController.BarCodeScanned(result);
							}
						}
						catch (ReaderException)
						{
						}

						
					/*
						com.google.zxing.common.BitArray row = new com.google.zxing.common.BitArray(screenImage.Width);
						
						int middle = screenImage.Height >> 1;
						int rowStep = System.Math.Max(1, screenImage.Height >> (4));
						
						for (int x = 0; x < 9; x++)
						{
							
							// Scanning from the middle out. Determine which row we're looking at next:
							int rowStepsAboveOrBelow = (x + 1) >> 1;
							bool isAbove = (x & 0x01) == 0; // i.e. is x even?
							int rowNumber = middle + rowStep * (isAbove?rowStepsAboveOrBelow:- rowStepsAboveOrBelow);
							if (rowNumber < 0 || rowNumber >= screenImage.Height)
							{
								// Oops, if we run off the top or bottom, stop
								break;
							}
							
							// Estimate black point for this row and load it:
							try
							{
								row = bitmap.getBlackRow(rowNumber, row);
								
								
								var resultb = _multiFormatReader.decodeRow(rowNumber, row, hints);
								if(resultb.Text!=null)
								{
									Console.WriteLine("SCANNED");
									BeepOrVibrate();
									_parentViewController.BarCodeScanned(resultb);
										
								
									break;
								}
								else {
									continue;
								}
								
							}
							catch (ReaderException re)
							{
								continue;
							}
					
						}
*/
						
						
	//					var result = _barcodeReader.decodeWithState(bitmap);
	//					
	//					if(result.Text!=null)
	//					{
	//						_multiFormatOneDReader = null;
	//						BeepOrVibrate();
	//						_parentViewController.BarCodeScanned(result);
	//					}
						
					} catch (Exception ex) {
						Console.WriteLine(ex.Message);
					}
					finally {
						if(bitmap!=null)
							bitmap = null;

						 if(source!=null)
							source = null;
						
		              //  if(srcbitmap!=null)
						//	srcbitmap = null;
					
						//if (_theScreenImage != null)
						//	_theScreenImage = null;

						
					}	
					}
				}
	      
	        }

			GC.Collect();

			//Console.WriteLine("Done.");

        }
Ejemplo n.º 18
0
        private string DecodeImage(Image image)
        {
            //image = image.Substring("data:image/png;base64,".Length);

            //var buffer = Convert.FromBase64String(image);
            //// TODO: I am saving the image on the hard disk but
            //// you could do whatever processing you want with it
            //string documentName = DateTime.Now.ToString("yyyyMMddHHmmssfff")+".png";
            //System.IO.File.WriteAllBytes(Server.MapPath("~/app_data/"+documentName), buffer);
            //byte[] bytes = Convert.FromBase64String(image);

            //Image _image;
            //using (MemoryStream ms = new MemoryStream(bytes))
            //{
            //    _image = Image.FromStream(ms);
            //}
            Result result = null;
            try
            {
                Reader reader = new com.google.zxing.MultiFormatReader();
                Bitmap image1 = new Bitmap(image);
                LuminanceSource source = new RGBLuminanceSource(image1, image1.Width, image1.Height);
                BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
                result = reader.decode(bitmap);
                //QRCodeDecoder decoder = new QRCodeDecoder();
                ////QRCodeDecoder.Canvas = new ConsoleCanvas();
                //String decodedString = decoder.decode(new QRCodeBitmapImage(new Bitmap(_image)));
                ////txtDecodedData.Text = decodedString;
            }
            catch
            {
                return null;
            }
            return result.Text;
        }