Issue 925 in zxing: Scanner rectangle not centered

149 views
Skip to first unread message

zx...@googlecode.com

unread,
Jul 27, 2011, 2:27:27 PM7/27/11
to zx...@googlegroups.com
Status: New
Owner: ----

New issue 925 by rocket18...@gmail.com: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

IMPORTANT: Please don't ask questions by filing bugs. Instead, send an
email to zx...@googlegroups.com.

What steps will reproduce the problem?
1.Using zxing 1.7 source code
2.
3.

What is the expected output? What do you see instead?

Expected output: The viewfinder in the device's screen that shows the
scanner input.
Instead: I can see the viewfinder but the rectangle is not centered, I
haven't modified anything to the source code and the rectangle shows in one
of the device's screen corner (bottom, left) even using the emulator.
However the text that says "Place a barcode inside the viewfinder..." is
centered.

What version of the product are you using? On what operating system?

1.7, android 2.2


Please provide any additional information below.

How can I center the rectangle, because neither using the emulator nor my
device (Xperia X10) the viewfinder's rectangle appears in the center. Any
help would be much appreciated. Thanks in advance.

zx...@googlecode.com

unread,
Jul 31, 2011, 3:32:29 PM7/31/11
to zx...@googlegroups.com

Comment #1 on issue 925 by sro...@gmail.com: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

This has always been due to the device misreporting its preview size, I
think. So I'd suspect that is also an issue here. However if you have
access to the dev tools and debugger it would be very useful to see what
figures it's returning for the camera and screen size. That would point out
the root of the problem.

zx...@googlecode.com

unread,
Aug 2, 2011, 1:25:21 PM8/2/11
to zx...@googlegroups.com

Comment #2 on issue 925 by mcoll...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

I did observe this issue and restarted the device whereupon the square was
centered. I think its' a problem with the device orientation as the square
would have been perfect if the layout were reversed.

zx...@googlecode.com

unread,
Aug 2, 2011, 2:14:04 PM8/2/11
to zx...@googlegroups.com

Comment #3 on issue 925 by rocket18...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

I've tried many times and the rectangle never appeared centered. I attach
an image showing how the viewfinder displays using the emulator.
In my real device a Xperia X10 with android 2.2 the viewfinder displays in
exact the same way, that is not centered.
Thanks for your help.

Attachments:
Untitled.png 89.3 KB

zx...@googlecode.com

unread,
Sep 2, 2011, 8:51:42 AM9/2/11
to zx...@googlegroups.com
Updates:
Status: NotABug

Comment #4 on issue 925 by sro...@gmail.com: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

(No comment was entered for this change.)

zx...@googlecode.com

unread,
Feb 7, 2012, 7:41:04 AM2/7/12
to zx...@googlegroups.com

Comment #5 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

i am also facing the problem of centered rectangle.
How to resolve this.
Thanks in advance

zx...@googlecode.com

unread,
Feb 7, 2012, 9:13:56 AM2/7/12
to zx...@googlegroups.com

Comment #6 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

You might try the latest build which has a workaround for some devices,
which might address this.

zx...@googlecode.com

unread,
Feb 8, 2012, 12:32:07 AM2/8/12
to zx...@googlegroups.com

Comment #7 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

I may try with the latest build.
Can you tell me what changes are there so I can try manually make the
changes to support this issue


zx...@googlecode.com

unread,
Feb 8, 2012, 4:08:54 AM2/8/12
to zx...@googlegroups.com

Comment #8 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

I'm thinking of this bit in CameraConfigurationManager.java:

// We're landscape-only, and have apparently seen issues with display
thinking it's portrait
// when waking from sleep. If it's not landscape, assume it's mistaken
and reverse them:
if (width < height) {
Log.i(TAG, "Display reports portrait orientation; assuming this is
incorrect");
int temp = width;
width = height;
height = temp;
}

zx...@googlecode.com

unread,
Feb 8, 2012, 4:41:10 AM2/8/12
to zx...@googlegroups.com

Comment #9 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

Does this mean that i have to change the above mentioned condition to
width > height


zx...@googlecode.com

unread,
Feb 8, 2012, 6:18:41 AM2/8/12
to zx...@googlegroups.com

Comment #10 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

No, why?

zx...@googlecode.com

unread,
Feb 8, 2012, 6:24:42 AM2/8/12
to zx...@googlegroups.com

Comment #11 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

I was asking because I am not able to center the scan rectangle.


zx...@googlecode.com

unread,
Feb 8, 2012, 6:37:45 AM2/8/12
to zx...@googlegroups.com

Comment #12 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

... and you asked if there were changes that might address that, and that's
what I posted.

zx...@googlecode.com

unread,
Feb 9, 2012, 12:15:19 AM2/9/12
to zx...@googlegroups.com

Comment #13 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

currently me working on 1.7 release for android, and here I dont get the
scan rectangle in center.
i tested this on many phones of different screen resolution but gets the
same rectangle box at the top right corner of screen.

zx...@googlecode.com

unread,
Mar 16, 2012, 1:32:43 AM3/16/12
to zx...@googlegroups.com

Comment #14 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

This issue has not been solved in 2.0
I am still getting a surface in right top corner instead of center.
how do i solve this???

zx...@googlecode.com

unread,
Mar 16, 2012, 5:14:45 AM3/16/12
to zx...@googlegroups.com

Comment #15 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

You'd have to post any information to help. It certainly does work on every
device I know of, and has been fixed even for the devices with bugs in this
thread.

zx...@googlecode.com

unread,
Mar 28, 2012, 6:34:39 AM3/28/12
to zx...@googlegroups.com

Comment #16 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

I am using Samsung Tab and requires the applicaton to run on all android
devices.
also scanning is critical operation of my device

zx...@googlecode.com

unread,
Apr 6, 2012, 5:31:40 PM4/6/12
to zx...@googlegroups.com

Comment #17 on issue 925 by ivan.cav...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

I have solved the issue with replacing the way that the height and width
are determined:

DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
float density = metrics.density;
int width = Float.valueOf(metrics.widthPixels / density).intValue();
int height = Float.valueOf(metrics.heightPixels /
density).intValue();

This will accomodate the density of the screen which can be different for
each device and the width and height reported by the phone are relative to
this density.

For example the samsung galaxy SII reports dimensions 800x600 and density
1.5 and the Samsung Galaxy Y reports dimensiions 320x240 and density 0.75.

Note: The original method used (display.getWidth() and display.getHeight())
are deprecated for usage and will never work on the latest android versions
(higher then 13).

zx...@googlecode.com

unread,
Apr 6, 2012, 5:35:42 PM4/6/12
to zx...@googlegroups.com

Comment #18 on issue 925 by ivan.cav...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

By the way, the change is in the CameraConfigurationManager or you can pass
then in the intent.

zx...@googlecode.com

unread,
Apr 6, 2012, 6:37:21 PM4/6/12
to zx...@googlegroups.com

Comment #20 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

These methods are not deprecated in the version of Android this app
supports, which is 2.1+. They do work as before on API 13+. They are merely
deprecated.

The density is irrelevant here -- it's sizing dimensions in pixels based on
pixels available. For example, the Galaxy Y really has a 320x240 screen. If
you considered it to have otherwise, this would not work.

i am not sure therefore why your change happens to work for you, but it
does not work on other devices.

zx...@googlecode.com

unread,
Apr 6, 2012, 6:41:23 PM4/6/12
to zx...@googlegroups.com

Comment #19 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

These methods are not deprecated in the version of Android this app

zx...@googlecode.com

unread,
Apr 10, 2012, 6:42:00 AM4/10/12
to zx...@googlegroups.com

Comment #21 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

it works fime for small screen resolution but for larger screen size like
Tablet, its does not adjust the view.

zx...@googlecode.com

unread,
Apr 10, 2012, 8:40:21 AM4/10/12
to zx...@googlegroups.com

Comment #22 on issue 925 by srowen: Scanner rectangle not centered
http://code.google.com/p/zxing/issues/detail?id=925

Nope, it works on tablets too. I have 2 of them. I really am struggling to
find actionable information here.

zx...@googlecode.com

unread,
Apr 11, 2012, 2:22:55 AM4/11/12
to zx...@googlegroups.com

Comment #23 on issue 925 by 18.agar...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

How to rotate the view,, as in the scanned barcode it rotated by 90
degree...
and do need to do any changes to support it for tablet...can u give the
entire source code of the class or the concerned method...

zx...@googlecode.com

unread,
Jun 3, 2012, 7:27:52 PM6/3/12
to zx...@googlegroups.com

Comment #24 on issue 925 by chrisd1...@gmail.com: Scanner rectangle not
centered
http://code.google.com/p/zxing/issues/detail?id=925

Comment 17 contained the code that did the trick for me.

I was having this issue on my Nexus One, Galaxy S II, Motorola Droid, and
Galaxy S.

zx...@googlecode.com

unread,
Oct 22, 2014, 3:06:59 PM10/22/14
to zx...@googlegroups.com

Comment #25 on issue 925 by johan040...@gmail.com: Scanner rectangle not
centered
https://code.google.com/p/zxing/issues/detail?id=925

Comment 17 is working on my Samsung 7" Tablet

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

zx...@googlecode.com

unread,
Feb 5, 2015, 3:42:38 PM2/5/15
to zx...@googlegroups.com

Comment #26 on issue 925 by javic...@gmail.com: Scanner rectangle not
centered
https://code.google.com/p/zxing/issues/detail?id=925

Comment 17, but in what method you made the change?
Reply all
Reply to author
Forward
0 new messages