コード例 #1
0
        // Note that we don't try rotation without the try harder flag, even if rotation was supported.
        public virtual Result decode(BinaryBitmap image, System.Collections.Hashtable hints)
        {
            var retval = doDecode(image, hints);

            if (retval.HasValue())
            {
                return(retval);
            }
            else
            {
                bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER);
                if (tryHarder && image.RotateSupported)
                {
                    BinaryBitmap rotatedImage = image.rotateCounterClockwise();
                    Result       result       = doDecode(rotatedImage, hints);

                    if (result == null)
                    {
                        return(null);
                    }

                    // Record that we found it rotated 90 degrees CCW / 270 degrees CW
                    System.Collections.Hashtable metadata = result.ResultMetadata;
                    int orientation = 270;
                    if (metadata != null && metadata.ContainsKey(ResultMetadataType.ORIENTATION))
                    {
                        // But if we found it reversed in doDecode(), add in that result here:
                        orientation = (orientation + ((System.Int32)metadata[ResultMetadataType.ORIENTATION])) % 360;
                    }
                    result.putMetadata(ResultMetadataType.ORIENTATION, (System.Object)orientation);
                    // Update result points
                    ResultPoint[] points = result.ResultPoints;
                    int           height = rotatedImage.Height;
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i] = new ResultPoint(height - points[i].Y - 1, points[i].X);
                    }
                    return(result);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #2
0
 // Note that we don't try rotation without the try harder flag, even if rotation was supported.
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap image, java.util.Map<com.google.zxing.DecodeHintType,?> hints) throws com.google.zxing.NotFoundException, com.google.zxing.FormatException
 public virtual Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
 {
     try
     {
       return doDecode(image, hints);
     }
     catch (NotFoundException nfe)
     {
       bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER);
       if (tryHarder && image.RotateSupported)
       {
     BinaryBitmap rotatedImage = image.rotateCounterClockwise();
     Result result = doDecode(rotatedImage, hints);
     // Record that we found it rotated 90 degrees CCW / 270 degrees CW
     //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
     //ORIGINAL LINE: java.util.Map<com.google.zxing.ResultMetadataType,?> metadata = result.getResultMetadata();
     IDictionary<ResultMetadataType, object> metadata = result.ResultMetadata;
     int orientation = 270;
     if (metadata != null && metadata.ContainsKey(ResultMetadataType.ORIENTATION))
     {
       // But if we found it reversed in doDecode(), add in that result here:
       orientation = (orientation + (int) metadata[ResultMetadataType.ORIENTATION]) % 360;
     }
     result.putMetadata(ResultMetadataType.ORIENTATION, orientation);
     // Update result points
     ResultPoint[] points = result.ResultPoints;
     if (points != null)
     {
       int height = rotatedImage.Height;
       for (int i = 0; i < points.Length; i++)
       {
         points[i] = new ResultPoint(height - points[i].Y - 1, points[i].X);
       }
     }
     return result;
       }
       else
       {
     throw nfe;
       }
     }
 }
コード例 #3
0
ファイル: OneDReader.cs プロジェクト: tomcat1234/WebQRReader
        // Note that we don't try rotation without the try harder flag, even if rotation was supported.
        public virtual Result decode2(BinaryBitmap image, Dictionary<object, object> hints)
        {
            try
            {
                return doDecode(image, hints);
            }
            catch (Exception re)
            {
                if (re.Message.IndexOf("ReaderException") < 0)
                    throw re;

                bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER);
                if (tryHarder && image.RotateSupported)
                {
                    BinaryBitmap rotatedImage = image.rotateCounterClockwise();
                    Result result = doDecode(rotatedImage, hints);
                    // Record that we found it rotated 90 degrees CCW / 270 degrees CW
                    Dictionary<object, object> metadata = result.ResultMetadata;
                    int orientation = 270;
                    if (metadata != null && metadata.ContainsKey(ResultMetadataType.ORIENTATION))
                    {
                        // But if we found it reversed in doDecode(), add in that result here:
                        orientation = (orientation + ((Int32) metadata[ResultMetadataType.ORIENTATION])) % 360;
                    }
                    result.putMetadata(ResultMetadataType.ORIENTATION, (Object) orientation);
                    // Update result points
                    ResultPoint[] points = result.ResultPoints;
                    int height = rotatedImage.Height;
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i] = new ResultPoint(height - points[i].Y - 1, points[i].X);
                    }
                    return result;
                }
                else
                {
                    throw re;
                }
            }
        }
コード例 #4
0
 // Note that we don't try rotation without the try harder flag, even if rotation was supported.
 // public virtual Result decode(BinaryBitmap image, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
 public virtual Result decode(BinaryBitmap image, System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
 {
     try
     {
         return(doDecode(image, hints));
     }
     catch (ReaderException re)
     {
         bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER);
         if (tryHarder && image.RotateSupported)
         {
             BinaryBitmap rotatedImage = image.rotateCounterClockwise();
             Result       result       = doDecode(rotatedImage, hints);
             // Record that we found it rotated 90 degrees CCW / 270 degrees CW
             // System.Collections.Hashtable metadata = result.ResultMetadata; // commented by .net follower (http://dotnetfollower.com)
             System.Collections.Generic.Dictionary <Object, Object> metadata = result.ResultMetadata; // added by .net follower (http://dotnetfollower.com)
             int orientation = 270;
             if (metadata != null && metadata.ContainsKey(ResultMetadataType.ORIENTATION))
             {
                 // But if we found it reversed in doDecode(), add in that result here:
                 orientation = (orientation + ((System.Int32)metadata[ResultMetadataType.ORIENTATION])) % 360;
             }
             result.putMetadata(ResultMetadataType.ORIENTATION, (System.Object)orientation);
             // Update result points
             ResultPoint[] points = result.ResultPoints;
             int           height = rotatedImage.Height;
             for (int i = 0; i < points.Length; i++)
             {
                 points[i] = new ResultPoint(height - points[i].Y - 1, points[i].X);
             }
             return(result);
         }
         else
         {
             throw re;
         }
     }
 }
コード例 #5
0
 // added by .net follower (http://dotnetfollower.com)
 // Note that we don't try rotation without the try harder flag, even if rotation was supported.
 // public virtual Result decode(BinaryBitmap image, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
 public virtual Result decode(BinaryBitmap image, System.Collections.Generic.Dictionary<Object, Object> hints)
 {
     try
     {
         return doDecode(image, hints);
     }
     catch (ReaderException re)
     {
         bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER);
         if (tryHarder && image.RotateSupported)
         {
             BinaryBitmap rotatedImage = image.rotateCounterClockwise();
             Result result = doDecode(rotatedImage, hints);
             // Record that we found it rotated 90 degrees CCW / 270 degrees CW
             // System.Collections.Hashtable metadata = result.ResultMetadata; // commented by .net follower (http://dotnetfollower.com)
             System.Collections.Generic.Dictionary<Object, Object> metadata = result.ResultMetadata; // added by .net follower (http://dotnetfollower.com)
             int orientation = 270;
             if (metadata != null && metadata.ContainsKey(ResultMetadataType.ORIENTATION))
             {
                 // But if we found it reversed in doDecode(), add in that result here:
                 orientation = (orientation + ((System.Int32) metadata[ResultMetadataType.ORIENTATION])) % 360;
             }
             result.putMetadata(ResultMetadataType.ORIENTATION, (System.Object) orientation);
             // Update result points
             ResultPoint[] points = result.ResultPoints;
             int height = rotatedImage.Height;
             for (int i = 0; i < points.Length; i++)
             {
                 points[i] = new ResultPoint(height - points[i].Y - 1, points[i].X);
             }
             return result;
         }
         else
         {
             throw re;
         }
     }
 }