private static string DoZoomAndRead(CancellationTokenSource cts, Bitmap capturedImage)
        {
            if (cts.IsCancellationRequested)
            {
                return(null);
            }

            string resultStr = null;
            int    height    = capturedImage.Height;
            int    width     = capturedImage.Width;

            for (int i = 0; i < 10; i++)
            {
                height += (int)Math.Round(height / 100F * 10F);
                width  += (int)Math.Round(width / 100F * 10F);

                capturedImage = ImageUtils.ResizeImage(cts, capturedImage, width, height);
                resultStr     = ZxingUtils.DecodeInner(cts, capturedImage);
                if (!string.IsNullOrEmpty(resultStr))
                {
                    break;
                }
            }

            return(resultStr);
        }
        private static string Decode(CancellationTokenSource cts, byte[] byteArray)
        {
            if (byteArray == null)
            {
                return(null);
            }

            if (byteArray.Length == 0)
            {
                return(null);
            }

            string resultStr;

            using (var memoryStream = new MemoryStream(byteArray))
            {
                using (var image = Image.FromStream(memoryStream))
                {
                    using (var capturedImage = (Bitmap)image.Clone())
                    {
                        resultStr = ZxingUtils.DecodeInner(cts, capturedImage);

                        if (string.IsNullOrEmpty(resultStr))
                        {
                            resultStr = DoZoomAndRotateByCommonAngles(cts, capturedImage);
                        }
                    }
                }
            }

            return(resultStr);
        }
        private static string DoZoomAndRotate(CancellationTokenSource cts, ICloneable capturedImage, int z)
        {
            if (cts.IsCancellationRequested)
            {
                return(null);
            }

            string resultStr;

            using (var capturedImageTmp = (Bitmap)capturedImage.Clone())
            {
                using (var capturedImageTmpNew = ImageUtils.RotateImage(capturedImageTmp, z))
                {
                    resultStr = ZxingUtils.DecodeInner(cts, capturedImageTmpNew);

                    if (!string.IsNullOrEmpty(resultStr))
                    {
                        return(resultStr);
                    }

                    resultStr = DoZoomAndRead(cts, capturedImageTmpNew);
                }
            }

            return(resultStr);
        }