Adir Rahamim
Adir Rahamim

Reputation: 453

Create a bitmap barcode

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

Upvotes: 0

Views: 1346

Answers (2)

Qadir Hussain
Qadir Hussain

Reputation: 8856

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.

Upvotes: 0

nicopico
nicopico

Reputation: 3636

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

Upvotes: 1

Related Questions