Decoding on WM5

in

Hi,

I tested the QRCode application with several images, but it does not work under Windows Mobile(Sometimes it Works) , but on the PC version it works without any problems.
On Windows Mobile it gives me a message of "IndexOutOfRangeException".
And also , it takes more than 15s to decode a picture on WM, this is not the case with the PC version .

Any one have this problem, and how to solve it ?
I think that a C++ version will be faster on WM.......

Excuse me for my bad English :) , i speak French !
Thanks.

Comments

too slow

I has never meet such problem but this library's deocding is very slow on SmartDevice.
I had tryied to decode a VGA-lowquality jpg file and take 41[sec] for this decoding! ! And bottleneck is the Bitmap::getPixel method. It is slow on the ARM PXA270.
The QRCodeDecoder::imageToIntArray method calling getPixel(s) to take a 2D int-type array for the image. That just taking over in the processing time.

Optimization

I just downloaded the API to test for QR decoding, and since I read your comments, I noticed too that decoding speed was quite slow.

Following Bighand7375 comment, I looked at the code that was using that GetPixel method and implemented another way of getting the int[][] array required for decoding with the Bitmap.LockBits and Bitmap.UnlockBits methods. On the picture I was testing, decoding was nearly 40 times faster but this may be meaningless on other pictures.

Based on the latest available download, there are 3 files to update :

- Add the following prototype to the interface in QRCodeMobileLib\data\QRCodeImage.cs
int[][] GetPixelsLock();

- Add the following method in QRCodeMobileLib\data\QRCodeBitmap.cs

public int[][] GetPixelsLock() {
BitmapData bData = image.LockBits(
new Rectangle(0, 0, image.Width, image.Height),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppRgb
);
int bpp = 4;
int nBytes = image.Height * image.Width * bpp;
int[][] pixels = new int[image.Width][];

for (int x = 0; x < image.Width; x++) {
pixels[x] = new int[image.Height];
for (int y = 0; y < image.Height; y++) {
int offset = (y * bData.Stride) + (x * bpp);

byte b = Marshal.ReadByte(bData.Scan0, offset);
byte g = Marshal.ReadByte(bData.Scan0, offset + 1);
byte r = Marshal.ReadByte(bData.Scan0, offset + 2);

pixels[x][y] =
(int)(255 << 24) +
(int)(r << 16) +
(int)(g << 8) +
(int)b;
}
}

image.UnlockBits(bData);

return pixels;
}

- And finally, in QRCodeMobileLib\QRCodeDecoder.cs change the following line in the decode method

int[][] intImage = imageToIntArray(qrCodeImage);

by

int[][] intImage = qrCodeImage.GetPixelsLock();

That should do the trick (at least it works a lot better for me).

(the formatting system of this forum is quite weird, hope its still readable though)

I have the same problem. Has

I have the same problem. Has anyone found a fix? Please help!

Back to top