开发者

how to decode bar code from a Bitmap in Android

开发者 https://www.devze.com 2023-04-13 04:20 出处:网络
I\'ve made an Adroid app for generating & decoding barcode in Code128. When I tried my own app against some Code128 barcode from a third party, it didn\'t work properly.

I've made an Adroid app for generating & decoding barcode in Code128. When I tried my own app against some Code128 barcode from a third party, it didn't work properly.

I've generated a barcode from the third party's site, http://generator.onbarcode.com/linear.aspx?TYPE=7&DATA=ID%3ao0123456789&UOM=0&X=1&Y=60&LEFT-MARGIN=0&RIGHT-MARGIN=0&TOP-MARGIN=0&BOTTOM-MARGIN=0&RESOLUTION=0&ROTATE=0&BARCODE-WIDTH=0&BARCODE-HEIGHT=0&SHOW-TEXT=true&TEXT-FONT=Arial|9|Regular&TextMargin=6&FORMAT=png&PROCESS-TILDE=false

as you can see, the barcode from above link begins with "1101...". and saved it as Bitmap in 16 bits locally and loaded it on Android emulator. While I scan the middle line of that bitmap and got following scanline in the middle of that bitmap:

[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2170914, -13026247, -16777216, -15197160, -4342083, -7565684, -15197160, -4342083, -1, -2170914, -13026247, -9736853, -1, -1, -1, -1, -1, -7565684, -16777216, -16777216, -9736853, -1, -1, -1, -1052689, -13026247, -9736853, -1, -1, -1, -1052689, -13026247, -10855078, -1052689, -13026247, -10855078, -1052689, -13026247, -16777216, -16249848, -4342083, -1, -1, -1, -6512996, -16249848, -4342083, -1, -1, -1, -6512996, -16777216, -16777216, -16777216, -16249848, -5394771, -1, -1052689, -11907766, -10855078, -1, -1, -6512996, -16777216, -16777216, -10855078, -1, -11907766, -10855078, -1, -1, -1, -1, -11907766, -16777216, -16777216, -16777216, -16777216, -16777216, -53947开发者_如何学C71, -5394771, -16777216, -5394771, -5394771, -16777216, -5394771, -5394771, -16777216, -16777216, -16777216, -16777216, -5394771, -5394771, -16777216, -16777216, -16777216, -16777216, -16777216, -11907766, -1, -10855078, -16777216, -16777216, -6512996, -1, -1, -10855078, -16777216, -16777216, -6512996, -5394771, -16249848, -16777216, -11907766, -1052689, -1, -5394771, -16249848, -16777216, -16777216, -16777216, -6512996, -5394771, -16249848, -16777216, -13026247, -1052689, -10855078, -16777216, -16777216, -16777216, -13026247, -1052689, -10855078, -13026247, -1052689, -10855078, -16777216, -16777216, -16777216, -13026247, -1052689, -9736853, -16777216, -16777216, -7565684, -1, -1, -1, -4342083, -16249848, -7565684, -1, -1, -1, -1, -1, -9736853, -13026247, -2170914, -9736853, -16777216, -16777216, -7565684, -1, -1, -9736853, -16777216, -16777216, -7565684, -4342083, -15197160, -16777216, -14078935, -2170914, -9736853, -16777216, -16777216, -16777216, -16777216, -16777216, -7565684, -3223602, -15197160, -7565684, -3223602, -15197160, -16777216, -14078935, -2170914, -1, -1, -1, -8684165, -14078935, -2170914, -1, -1, -1, -8684165, -16777216, -16777216, -8684165, -1, -1, -1, -3223602, -14078935, -16777216, -16777216, -16777216, -8684165, -3223602, -14078935, -8684165, -3223602, -14078935, -16777216, -15197160, -3223602, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

As you see from above dumped scanline data, the first eight continuous none "-1" integers represents "11" in barcode and my app then expects four continuous "-1", but it has only one "-1", followed by only 3 continuous none "-1", but my app expects there should exist 4 continuous none "-1" there. All in all, my app is totally confused by those scan data.

Can someone tell me if my expectations for numbers of occurrences of "-1" or none "-1" in scan data is right or not or I interpreted the scan data in wrong way? It's appreciated if you can shed the light of how to decode the scan data in a better way.

thanks in advance!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号