Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 703 forks source link

Stretched image in customOverlay layout. #470

Open stathis-kontogiannis opened 8 years ago

stathis-kontogiannis commented 8 years ago

My screen consists of 1/3 scan area and the rest is other layouts (buttons, images etc) i use the customOverlay property.Then, I start scanning but the scanning area seems to be stretched (in portait view) and a little bit "laggy". How i can fix this?

Hugoxz commented 8 years ago

I am with the same issue. I have many barcodes in a paper and some times the code had read is one above or one below, not the barcode at center of screen. I tried to read the sources and I found nothing like to limit the area of scanner.

ptsiogas commented 7 years ago

I have the exact same problem. I tries to play and tweak the returned CameraResolution at the CameraResolutionSelector, but in same devices (like Samsung Galaxy S7 edge) this tweak generates a "SetupCamera failed" error that comes with a black screen. I think that if this is a bug it should be fixed with high priority because we can't publish any app with stretched QR code scanner. If all the above are not bugs please provide us a working solution

Nikitkao commented 7 years ago

I have the same issue. Its strange that only few people notice that, I installed in new empty project that lib and camera image stretched anyway. Can someone help me?

Zexuz commented 7 years ago

10/10 can confirm ugly stretched hands..

Image with camera app (OP 3T) img_20170719_151019 screenshot using my own app. Code below screenshot_20170719-151026

using Android.App;
using Android.Widget;
using Android.OS;
using ZXing.Mobile;
using System;
using Android.Views;

namespace App1
{
    [Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
             SetContentView (Resource.Layout.Main);

            MobileBarcodeScanner.Initialize(Application);

            var btn = FindViewById<Button>(Resource.Id.button1);
            btn.Click += async (sender, e) => {

                var scanner = new ZXing.Mobile.MobileBarcodeScanner();

                scanner.UseCustomOverlay = true;
                scanner.CustomOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.Test, null);;

                var result = await scanner.Scan();

                if (result != null)
                    Console.WriteLine("Scanned Barcode: " + result.Text);
            };

        }
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
    p1:orientation="vertical"
    p1:minWidth="25px"
    p1:minHeight="25px"
    p1:layout_width="match_parent"
    p1:layout_height="100dp"
    p1:id="@+id/linearLayout1" />
gtbuchanan commented 7 years ago

I'm also experiencing this with the Xamarin Forms version on my Samsung Galaxy S4 (Android 6) and S8 (Android 7). It's notably worse in landscape mode.

riskeez commented 6 years ago

In Xamarin.Forms project I've faced with the same problem (tried versions 2.3.2 and 2.1.47).

I've tested it on Samsung S8 (Android 7), OnePlus 3T (Android 8), Asus Zenfone 5 (Android 5). The problem isn't related with custom or default overlays. I've tried other resolutions, other settings, but problem anyway exists.

Maybe someone found a solution?

UPDATED. I've found that the same project built on different machines works different. At one machine I got app with distorted camera, but on other - scanner in app works without distortion. Still trying to resolve it

Portrait mode portrait

PaulVrugt commented 6 years ago

Any progress on this? I'm experiencing the same issue

charmosz commented 6 years ago

Same here :(. Any ideas to solve this problem ?

anirbanbasu commented 6 years ago

Is this still not solved?!

esaavedra89 commented 4 years ago

Any solution to this problem?

igor-gregori commented 4 years ago

Maybe that helps:

https://msicc.net/how-to-avoid-a-distorted-android-camera-preview-with-zxing-net-mobile/