Android Open Source - AndroidCouponAssistant Barcode Generator






From Project

Back to project page AndroidCouponAssistant.

License

The source code is released under:

MIT License

If you think the Android project AndroidCouponAssistant listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.corylucasjeffery.couponassistant;
//from   w ww . ja  v  a2s . c  om

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.util.Base64;
import android.util.Log;
import android.widget.ImageView;

import com.onbarcode.barcode.android.AndroidColor;
import com.onbarcode.barcode.android.AndroidFont;
import com.onbarcode.barcode.android.IBarcode;
import com.onbarcode.barcode.android.UPCA;

public class BarcodeGenerator {

        private ImageView iv;
        private String barcode_number;
        private Bitmap barcode_image;

        public BarcodeGenerator(ImageView iv, String barcode) {
            this.iv = iv;
            this.barcode_number = barcode;
        }

        public void getGeneratedBarcode() {
            //Create an image for drawing the barcode
            barcode_image = Bitmap.createBitmap(230,150, Bitmap.Config.ARGB_8888);
            Canvas c = new Canvas(barcode_image);

            //Create newly drawn barcode
            UPCA barcode = new UPCA();
            barcode.setData(barcode_number);
            barcode.setUom(IBarcode.UOM_PIXEL);
            barcode.setX(2f);
            barcode.setY(100f);
            barcode.setLeftMargin(0f);
            barcode.setRightMargin(0f);
            barcode.setTopMargin(0f);
            barcode.setBottomMargin(1f);
            barcode.setBarAlignment(1);
            barcode.setResolution(720);
            barcode.setShowText(true);
            barcode.setTextFont(new AndroidFont("Arial", Typeface.NORMAL, 12));
            barcode.setTextMargin(6);
            barcode.setTextColor(AndroidColor.black);
            barcode.setForeColor(AndroidColor.black);
            barcode.setBackColor(AndroidColor.white);
            RectF bounds = new RectF(0,0,0,0);
            try {
                barcode.drawBarcode(c, bounds);
            } catch (Exception e) {
                e.printStackTrace();
            }
            iv.setImageBitmap(barcode_image);
        }
    }




Java Source Code List

com.corylucasjeffery.couponassistant.BMPtoBlob.java
com.corylucasjeffery.couponassistant.BarcodeGenerator.java
com.corylucasjeffery.couponassistant.BlobtoBMP.java
com.corylucasjeffery.couponassistant.CameraPreview.java
com.corylucasjeffery.couponassistant.CouponAdapter.java
com.corylucasjeffery.couponassistant.Coupon.java
com.corylucasjeffery.couponassistant.DateChooserDialog.java
com.corylucasjeffery.couponassistant.DbGetCoupons.java
com.corylucasjeffery.couponassistant.DbPurchaseItem.java
com.corylucasjeffery.couponassistant.DbSubmitCoupon.java
com.corylucasjeffery.couponassistant.DbSubmitItem.java
com.corylucasjeffery.couponassistant.DbUserRegister.java
com.corylucasjeffery.couponassistant.DbUserStats.java
com.corylucasjeffery.couponassistant.GlobalCart.java
com.corylucasjeffery.couponassistant.Item.java
com.corylucasjeffery.couponassistant.ManualEntryDialog.java
com.corylucasjeffery.couponassistant.ParseUPC.java
com.corylucasjeffery.couponassistant.PhpWrapper.java
com.corylucasjeffery.couponassistant.ProgressBarHelper.java
com.corylucasjeffery.couponassistant.Statistics.java
com.corylucasjeffery.couponassistant.UserInfo.java
com.corylucasjeffery.couponassistant.ValueCodeDict.java
com.corylucasjeffery.couponassistant.activities.AndroidBarcodeView.java
com.corylucasjeffery.couponassistant.activities.CheckoutActivity.java
com.corylucasjeffery.couponassistant.activities.LoginActivity.java
com.corylucasjeffery.couponassistant.activities.MainActivity.java
com.corylucasjeffery.couponassistant.activities.SettingsActivity.java
com.corylucasjeffery.couponassistant.activities.ShowCouponsActivity.java
com.corylucasjeffery.couponassistant.activities.StatisticsActivity.java
com.google.zxing.integration.android.IntentIntegrator.java
com.google.zxing.integration.android.IntentResult.java