コード例 #1
0
    internal virtual void  cameraCanvasCaptured(sbyte[] pngData)
    {
        cameraCanvas.stop();
        displayCanvas.Image = 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 (System.IO.IOException ioe)
        {
        }
        QRCodeDecoder decoder = new QRCodeDecoder();

        QRCodeDecoder.setCanvas(displayCanvas);
        try
        {
            decodedTextBox.DecodedString = 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();
    }
コード例 #2
0
    public virtual 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();
    }
コード例 #3
0
    public virtual void  drawCross(Point point, 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(point.getX() - 5, point.getY(), point.getX() + 5, point.getY());
        g.drawLine(point.getX(), point.getY() - 5, point.getX(), point.getY() + 5);
        image = bufImage;
        repaint();
    }
コード例 #4
0
    public virtual 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();
    }
コード例 #5
0
    public virtual 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();
    }
コード例 #6
0
    public virtual void  drawMatrix(bool[][] 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();
    }
コード例 #7
0
 public J2MEImage(Image image)
 {
     this.image = image;
     intImage   = new int[image.Width * image.Height];
     image.getRGB(this.intImage, 0, image.Width, 0, 0, image.Width, image.Height);
 }