Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS ZXingScannerView - BarcodeReader createLuminanceSource-Delegate #47

Closed
schmittch opened this issue Jul 9, 2013 · 1 comment
Closed

Comments

@schmittch
Copy link

I have made some local modifications on the source in src/ZXing.Net.Mobile/MonoTouch/ZXingScannerView.cs:255 (Master-Branch 2013-06-21 08:51). Please see my comments [schmittch Mod 2013-07-09] below.

            /* ZXingScannerView.cs:254 ... */

            var barcodeReader = new BarcodeReader(null, (img) =>     
            {
                var src = new RGBLuminanceSource(img); //, bmp.Width, bmp.Height);

#if false
/* [schmittch Mod 2013-07-09]: UIDeviceOrientation has more cases
 *                             (Unknown, Portrait, PortraitUpsideDown, LandscapeLeft, LandscapeRight, FaceUp, FaceDown)
 *                             than for the algorithem are interesting. ...
 */

                //Don't try and rotate properly if we're autorotating anyway
                if (options.AutoRotate.HasValue && options.AutoRotate.Value)
                    return src;

                switch (UIDevice.CurrentDevice.Orientation)
                {
                    case UIDeviceOrientation.Portrait:
                        return src.rotateCounterClockwise().rotateCounterClockwise().rotateCounterClockwise();
                    case UIDeviceOrientation.PortraitUpsideDown:
                        return src.rotateCounterClockwise().rotateCounterClockwise().rotateCounterClockwise();
                    case UIDeviceOrientation.LandscapeLeft:
                        return src;
                    case UIDeviceOrientation.LandscapeRight:
                        return src;
                }

                return src;
#else
/* [schmittch Mod 2013-07-09]: ... Therefore, UIInterfaceOrientation should be used to avoid undefined states. */

                //Don't try and rotate properly if we're autorotating anyway
                if (options.AutoRotate.HasValue && options.AutoRotate.Value)
                {
                    return src;
                }
                else
                {
                    switch (UIApplication.SharedApplication.StatusBarOrientation)
                    {
                        case UIInterfaceOrientation.Portrait:
                            return src.rotateCounterClockwise().rotateCounterClockwise().rotateCounterClockwise();
                        case UIInterfaceOrientation.PortraitUpsideDown:
                            return src.rotateCounterClockwise().rotateCounterClockwise().rotateCounterClockwise();
                        default:
                            return src;
                    }
                }
#endif

            }, null, null); //(p, w, h, f) => new RGBLuminanceSource(p, w, h, RGBLuminanceSource.BitmapFormat.Unknown));

            /* ... */

Otherwise, a great library!

@Redth Redth closed this as completed in 6daf294 Jul 24, 2013
@Redth
Copy link
Owner

Redth commented Jul 24, 2013

Thanks, didn't realize this was an available way to check!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants