See dynamicimage.

On Mon, May 27, 2013 at 12:12 AM, Delange <[email protected]> wrote:

> Hi,
> I'm trying to create a dynamic QR image on the screen.
>
>
> Html
>
>
> Wicket
> form.add(new Image("image5", getImage5Resource()));
> public ResourceReference getImage5Resource() {
>         return new ResourceReference(CompanyPanel.class, "image5")
>         {
>             @Override
>             public IResource getResource()
>             {
>                 final BufferedDynamicImageResource resource = new
> BufferedDynamicImageResource();
>                 final BufferedImage image = new BufferedImage(300, 300,
> BufferedImage.TYPE_INT_RGB);
>                 String text = "";
>
>                         String t="\n";
>                         text = ""
>                                         +"BEGIN:VCARD"+t
>                                         +"VERSION:2.1"+t
>                                         +"NOTE:This works!"+t
>                                         +"CATEGORIES:BUSINESS,WORK"+t
>                                         +"END:VCARD";
>
>
>                 drawQR( (Graphics2D)image.getGraphics() , text );
>                 resource.setImage(image);
>                 return resource;
>             }
>         };
>     }
>         void drawQR(Graphics2D graphics,String text)
>     {
>
>             try {
>                 BitMatrix byteMatrix = new QRCodeWriter().encode(text,
> BarcodeFormat.QR_CODE,     300, 300);
>                 int matrixWidth = byteMatrix.getWidth();
>
>                 //MatrixToImageWriter.writeToStream(byteMatrix, "png", new
> FileOutputStream(new File("qrcode_test.png" +"")));
>                 BufferedImage image = new BufferedImage(matrixWidth ,
> matrixWidth,
> BufferedImage.TYPE_INT_RGB);
>
>
>
>                 graphics = image.createGraphics();
>                 graphics.drawImage(image, 0, 0, 300, 300, null);
>
>
>                 System.out.println(text);
>
>             } catch (WriterException e) {
>
>                 e.printStackTrace();
>             } catch (Exception e) {
>
>                 e.printStackTrace();
>
>             }
>     }
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Dynamic-QR-image-tp4659029.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Reply via email to