Example usage for com.itextpdf.text.pdf.qrcode BitMatrix getWidth

List of usage examples for com.itextpdf.text.pdf.qrcode BitMatrix getWidth

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf.qrcode BitMatrix getWidth.

Prototype

public int getWidth() 

Source Link

Usage

From source file:com.mui.halal.experiment.MatrixToImageWriter.java

License:Apache License

/**
 * Renders a {@link BitMatrix} as an image, where "false" bits are rendered
 * as white, and "true" bits are rendered as black.
 *///from w  w w .ja v a 2s  .  c o m
public static BufferedImage toBufferedImage(BitMatrix matrix) {
    int width = matrix.getWidth();
    int height = matrix.getHeight();
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
        }
    }
    return image;
}