Search in sources :

Example 1 with Image

use of javax.microedition.lcdui.Image in project qrcode by yanbe.

the class J2MEImage method drawMatrix.

public void drawMatrix(boolean[][] matrix) {
    Image bufImage = Image.createImage(image.getWidth(), image.getHeight());
    Graphics g = bufImage.getGraphics();
    g.setColor(0xCCCCCC);
    for (int y = 0; y < matrix[0].length; y++) {
        for (int x = 0; x < matrix.length; x++) {
            if (matrix[x][y] == true)
                g.drawLine(x, y, x + 1, y);
        }
    }
    image = bufImage;
    repaint();
}
Also used : Graphics(javax.microedition.lcdui.Graphics) QRCodeImage(jp.sourceforge.qrcode.data.QRCodeImage) Image(javax.microedition.lcdui.Image) Point(jp.sourceforge.qrcode.geom.Point)

Example 2 with Image

use of javax.microedition.lcdui.Image in project qrcode by yanbe.

the class J2MEImage method drawLines.

public void drawLines(Line[] lines, int color) {
    Image bufImage = Image.createImage(image.getWidth(), image.getHeight());
    Graphics g = bufImage.getGraphics();
    g.drawImage(image, 0, 0, 0);
    g.setColor(color);
    for (int i = 0; i < lines.length - 1; i++) {
        g.drawLine(lines[i].getP1().getX(), lines[i].getP1().getY(), lines[i].getP2().getX(), lines[i].getP2().getY());
    }
    image = bufImage;
    repaint();
}
Also used : Graphics(javax.microedition.lcdui.Graphics) QRCodeImage(jp.sourceforge.qrcode.data.QRCodeImage) Image(javax.microedition.lcdui.Image) Point(jp.sourceforge.qrcode.geom.Point)

Example 3 with Image

use of javax.microedition.lcdui.Image in project qrcode by yanbe.

the class J2MEImage method cameraCanvasCaptured.

void cameraCanvasCaptured(byte[] pngData) {
    cameraCanvas.stop();
    displayCanvas.setImage(pngData);
    Display.getDisplay(this).setCurrent(displayCanvas);
    Image image = Image.createImage(pngData, 0, pngData.length);
    // TODO Uncomment below for demo on emulator
    try {
        image = Image.createImage("/qrcode.jpg");
    } catch (IOException ioe) {
    }
    QRCodeDecoder decoder = new QRCodeDecoder();
    QRCodeDecoder.setCanvas(displayCanvas);
    try {
        decodedTextBox.setDecodedString(new String(decoder.decode(new J2MEImage(image))));
    } catch (DecodingFailedException dfe) {
        displayCanvas.println("Decoding failed");
        displayCanvas.println("(" + dfe.getMessage() + ")");
        displayCanvas.println("--------");
        return;
    }
    displayCanvas.println("--------");
    displayCanvas.addViewDecodedStringCommand();
}
Also used : IOException(java.io.IOException) QRCodeImage(jp.sourceforge.qrcode.data.QRCodeImage) Image(javax.microedition.lcdui.Image) QRCodeDecoder(jp.sourceforge.qrcode.QRCodeDecoder) DecodingFailedException(jp.sourceforge.qrcode.exception.DecodingFailedException)

Example 4 with Image

use of javax.microedition.lcdui.Image in project qrcode by yanbe.

the class J2MEImage method drawPoints.

public void drawPoints(Point[] points, int color) {
    Image bufImage = Image.createImage(image.getWidth(), image.getHeight());
    Graphics g = bufImage.getGraphics();
    g.drawImage(image, 0, 0, 0);
    g.setColor(color);
    for (int i = 0; i < points.length - 1; i++) {
        g.drawLine(points[i].getX(), points[i].getY(), points[i].getX() + 1, points[i].getY());
    }
    image = bufImage;
    repaint();
}
Also used : Graphics(javax.microedition.lcdui.Graphics) QRCodeImage(jp.sourceforge.qrcode.data.QRCodeImage) Image(javax.microedition.lcdui.Image) Point(jp.sourceforge.qrcode.geom.Point)

Example 5 with Image

use of javax.microedition.lcdui.Image in project qrcode by yanbe.

the class J2MEImage method drawLine.

public void drawLine(Line line, int color) {
    Image bufImage = Image.createImage(image.getWidth(), image.getHeight());
    Graphics g = bufImage.getGraphics();
    g.drawImage(image, 0, 0, 0);
    g.setColor(color);
    g.drawLine(line.getP1().getX(), line.getP1().getY(), line.getP2().getX(), line.getP2().getY());
    image = bufImage;
    repaint();
}
Also used : Graphics(javax.microedition.lcdui.Graphics) QRCodeImage(jp.sourceforge.qrcode.data.QRCodeImage) Image(javax.microedition.lcdui.Image)

Aggregations

Image (javax.microedition.lcdui.Image)7 QRCodeImage (jp.sourceforge.qrcode.data.QRCodeImage)7 Graphics (javax.microedition.lcdui.Graphics)6 Point (jp.sourceforge.qrcode.geom.Point)4 IOException (java.io.IOException)1 QRCodeDecoder (jp.sourceforge.qrcode.QRCodeDecoder)1 DecodingFailedException (jp.sourceforge.qrcode.exception.DecodingFailedException)1