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(); }
public static javax.microedition.lcdui.Image createImage(javax.microedition.lcdui.Image image, int x, int y, int width, int height) { Image ret = Image.createImage(width, height); ret.getGraphics().drawImageRegion(image, 0, 0, x, y, width, height, 0); return(ret); }