Search in sources :

Example 31 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CreateDatamatrixBarcode method createADataMatrixBarcode.

public static void createADataMatrixBarcode(String dataDir) throws IOException {
    BarCodeBuilder objBuilder = new BarCodeBuilder();
    objBuilder.setEncodeType(com.aspose.barcode.EncodeTypes.DATA_MATRIX);
    objBuilder.setCodeText("1234567890");
    objBuilder.save(dataDir + "datamatrix.bmp");
    objBuilder.save(dataDir + "datamatrix.emf", com.aspose.barcode.BarCodeImageFormat.Emf);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 32 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CreatingAPdf417Barcode method pdf417ErrorCorrectionLevel.

public static void pdf417ErrorCorrectionLevel(String dataDir) {
    BarCodeBuilder b = new BarCodeBuilder();
    b.setEncodeType(com.aspose.barcode.EncodeTypes.PDF_417);
    b.setPdf417ErrorLevel(Pdf417ErrorLevel.Level8);
    b.setCodeText("12345");
    b.save(dataDir + "pdf417ErrorCorrectionLevel.bmp");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 33 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CreatingAPdf417Barcode method pdf417CompactionMode.

public static void pdf417CompactionMode(String dataDir) {
    BarCodeBuilder builder = new BarCodeBuilder("This is text data", com.aspose.barcode.EncodeTypes.PDF_417);
    // Set Pdf417 Compaction Mode to Text
    builder.setPdf417CompactionMode(Pdf417CompactionMode.Text);
    // Save the image to disk in PNG format
    builder.save(dataDir + "pdf417CompactionMode.png");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 34 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CreatingAQRBarcode method QRBarcodeWithImage.

public static void QRBarcodeWithImage(String dataDir) throws IOException {
    // Define barcode image height & width
    int QRCODE_IMAGE_HEIGHT = 300;
    int QRCODE_IMAGE_WIDTH = 300;
    // Create an instance of BarCodeBuilder class
    // Set the barcode text
    // Set the barcode symbology
    BarCodeBuilder builder = new BarCodeBuilder("123456789", com.aspose.barcode.EncodeTypes.QR);
    // Set the error level
    builder.setQRErrorLevel(com.aspose.barcode.QRErrorLevel.LevelH);
    // Set the Graphics Unit
    builder.setGraphicsUnit(2);
    // Generate the barocde image and save it as image in an object of BufferedImage class
    java.awt.image.BufferedImage image = builder.getCustomSizeBarCodeImage(QRCODE_IMAGE_WIDTH, QRCODE_IMAGE_HEIGHT, false);
    System.out.println("ImageHeight: " + image.getHeight());
    // Load the image in an object of BufferedImage class - this is the image that you want to embed into the barcode image.
    java.awt.image.BufferedImage overlay = javax.imageio.ImageIO.read(new java.io.File("wifi_logo.jpg"));
    // Calculate the height & width
    int deltaHeight = image.getHeight() - overlay.getHeight();
    int deltaWidth = image.getWidth() - overlay.getWidth();
    // Create a new empty image
    java.awt.image.BufferedImage combined = new java.awt.image.BufferedImage(QRCODE_IMAGE_WIDTH, QRCODE_IMAGE_HEIGHT, java.awt.image.BufferedImage.TYPE_INT_ARGB);
    // Get the Graphics2D object
    java.awt.Graphics2D g = (java.awt.Graphics2D) combined.getGraphics();
    // Draw the primary image (barcode image) on the canvas
    g.drawImage(image, 0, 0, null);
    g.setComposite(java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.SRC_OVER, 1f));
    // Draw the second image (logo image) on the canvas inside the barcode image
    g.drawImage(overlay, (int) Math.round(deltaWidth / 2), (int) Math.round(deltaHeight / 2), null);
    // Create and save the final very of the image with barcode and logo inside it
    java.io.File imageFile = new java.io.File("qrcode_with_logo.png");
    javax.imageio.ImageIO.write(combined, "PNG", imageFile);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 35 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CreatingAQRBarcode method rotation.

public static void rotation(String dataDir) throws IOException {
    BarCodeBuilder b = new BarCodeBuilder();
    b.setEncodeType(com.aspose.barcode.EncodeTypes.QR);
    b.setCodeText("1234567890");
    // Hide code text
    b.setCodeLocation(CodeLocation.None);
    b.setRotationAngleF(90);
    b.save(dataDir + "rotation_qr.bmp", BarCodeImageFormat.Bmp);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Aggregations

BarCodeBuilder (com.aspose.barcode.BarCodeBuilder)56 BufferedImage (java.awt.image.BufferedImage)4 File (java.io.File)3 MarginsF (com.aspose.barcode.MarginsF)2 Font (java.awt.Font)2 Graphics (java.awt.Graphics)2 Image (java.awt.Image)2 Caption (com.aspose.barcode.Caption)1 EnableChecksum (com.aspose.barcode.EnableChecksum)1 Resolution (com.aspose.barcode.Resolution)1 BarCodeReader (com.aspose.barcode.barcoderecognition.BarCodeReader)1 MediaTracker (java.awt.MediaTracker)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1