Tenho uma imagem de código de barras sendo gerada pelo barbecue
, essa imagem esta armazenada em uma instância de Graphics2D
.
Queria saber como coloco essa imagem em uma instância de JRDesignImage
pra ela ser compilada e impressa.
Código
//Criar o Design do relatório
JasperDesign report = new JasperDesign();
report.setName("teste");
report.setPageWidth((int)Math.round((90 * 72) / 25.4f)); //9cm
report.setPageHeight((int)Math.round((45 * 72) / 25.4f)); //4.5cm
report.setBottomMargin(0);
report.setTopMargin(0);
report.setLeftMargin(0);
report.setRightMargin(0);
report.setColumnWidth(report.getPageWidth());
//Criar a banda de detalhes
JRDesignBand band = new JRDesignBand();
band.setHeight(report.getPageHeight());
//Criar o componente de imagem
JRDesignImage imagem = new JRDesignImage(report);
imagem.setWidth((int)Math.round((50 * 72) / 25.4f));
imagem.setHeight((int)Math.round((40 * 72) / 25.4f));
imagem.setX((int)Math.round((20 * 72) / 25.4f));
imagem.setY((int)Math.round((5 * 72) / 25.4f));
Barcode barcode = BarcodeFactory.createUPCA("91231234567");
BufferedImage image = new BufferedImage(barcode.getWidth(), barcode.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g = (Graphics2D)image.getGraphics();
g.setBackground(Color.BLUE);
barcode.draw(g, 0, 0);
Aqui seria o ponto onde eu passaria a imagem, mas não tenho ideia de como fazer isso, já olhei na documentação, mas não tive nenhuma luz.
Delphi
monto isso sossegado, mas preciso de uma versão multi-plataforma.