0

I want to generate a barcode image using zxing library (or another good library if you know).

I generate the barcode image using:

Intent intent = new Intent("com.google.zxing.client.android.ENCODE");

intent.putExtra("ENCODE_FORMAT", "CODE_128");
intent.putExtra("ENCODE_DATA", objectsId.get(position));

startActivity(intent);

how can i get the barcode image as bitmap or the path to the barcode image?

currently i am using the zxing library

Adir Rahamim
  • 453
  • 1
  • 12
  • 31

2 Answers2

1

Using zxing, you cannot retrieve the barcode image using intent. The barcode can only be displayed by the zxing activity.

If you want to handle the barcode image yourself, you will have to integrate the library in your code, which is slightly more complicated, or find another library.

You can get some information here: Embed Zxing library without using Barcode Scanner app

Community
  • 1
  • 1
nicopico
  • 3,606
  • 1
  • 28
  • 30
  • thanks, i will try it...also, what is the recommeneded "ENCODE_FORMAT" for my code above? Also, if i have a zxing barcode app installed on my android phone, it makes me problem with code above..is there any solution for this? thanks alot – Adir Rahamim May 06 '13 at 17:02
  • The recommended way is to use the [`IntentIntegrator.shareText(CharSequence, CharSequence)`](http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java#374) method provided by zxing. I cannot really help you about ENCODE_FORMAT as I never used this library for encoding – nicopico May 06 '13 at 17:08
  • thanks alot, can you give me an example of how do i use the IntentIntegrator.shareText in my app? also is there additional commands? – Adir Rahamim May 06 '13 at 17:47
0

Here is your answer you are looking for may be.

Try this tutorial. you will get the QR-CODE/BAR-CODE in the imageview residing in your app. http://www.mysamplecode.com/2012/09/android-generate-qr-code-using-zxing.html

after getting your Bar-Code in the imageview, you can convert this as a bitmap as

ImageView v1 = (ImageView)findViewById(R.id.mImage);
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();

now you have your bitmap, you can play with it now.

Hope this helps you.

Qadir Hussain
  • 8,721
  • 13
  • 89
  • 124
  • also see my question I have asked the same http://stackoverflow.com/questions/16292893/how-to-store-the-generated-qr-code-as-an-image-in-sdcard-zxing-library – Qadir Hussain May 06 '13 at 19:39
  • thansk alot, that is exactly what i want, does it matter what is the "ENCODE_FORMAT" to use? – Adir Rahamim May 06 '13 at 20:25
  • Yes if you use ("ENCODE_FORMAT", "CODE_128"), i think this will generate a bar code and if you are using ("ENCODE_FORMAT", "QR_CODE"), this will generate a QR Code. you can google it for the differnces, I recomend you to use QR-CODE instead of Bar CODE. QR-CODE is very rapidly decoded by the android devices, while bar code takes more time to be decoded. – Qadir Hussain May 07 '13 at 04:41